Modding:Wishes: Difference between revisions

From Caves of Qud Wiki
Jump to navigation Jump to search
(add modding ambox and navbox)
No edit summary
Line 1: Line 1:
{{Modding Info}}
{{Modding Info}}
{{Betamoddingcontent}}
Creating your own wishes requires 2.0.200.24 or greater.
Creating your own wishes requires 2.0.200.24 or greater.


Line 52: Line 55:
The regular expression passed to the attribute is parsed using case insensitive matching.
The regular expression passed to the attribute is parsed using case insensitive matching.
[[Category:Modding]]
[[Category:Modding]]
[[Category:Beta Modding]]
{{Modding Navbox}}
{{Modding Navbox}}

Revision as of 01:35, 7 May 2020

This page is about modding. See the modding overview for an abstract on modding.
This page is about modding. See the modding overview for an abstract on modding.
This section contains modding information that is only applicable to the in-development beta branch of Caves of Qud on Steam.

Creating your own wishes requires 2.0.200.24 or greater.

To create a wish, you define a XRL.Wish.WishCommand attribute on a public method. This method should either be void or bool.

public class MyWishHandler
{
  // Handles "testwish:foo" or "testwish foo" as a wish command
  [XRL.Wish.WishCommand(Command = "testwish")]
  public static bool TestWishHandler(string rest)
  {
     Popup.Show("Matched: " + rest);
     // if we dont return true, other wishes will also parse this wish message
     return true;
  }

  // Handles "testwish" with nothing else! (no string param)
  [XRL.Wish.WishCommand(Command = "testwish")]
  public static void TestWishHandler()
  {
     Popup.Show("Matched it the short way");
     // if we return void, it assumes we handled it
  }

  // showing of non-static also!
  public int count = 0;

  // no command -- uses the method name by default!
  [XRL.Wish.WishCommand]
  public void inc()
  {
    Popup.Show(count++);
  }

  [XRL.Wish.WishCommand]
  public void dec()
  {
    Popup.Show(count--);
  }

  [XRL.Wish.WishCommand(Regex = @"other fancy match \d things"]
  public void Handle(System.Text.RegularExpression.Match match)
  {
    Popup.Show(match.Groups[0].ToString());
  }

}

The regular expression passed to the attribute is parsed using case insensitive matching.