twine-code.d.ts 1.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  1. declare module "twine-sugarcube" {
  2. export interface SugarCubeSetupObject {
  3. Example: { new(): Example };
  4. /**
  5. * Provides functions to overwrite behavior of functions and variables
  6. */
  7. Overwrite: {
  8. /**
  9. * Registers code that will be run whenever a `setup.qsp_func()`- call occurs for the given `passageName`.
  10. *
  11. * If the function `func` returns anything but `undefined`, this value will be returned by `setup.qsp_func()` and default behavior (executing the code of the passage) is skipped.
  12. *
  13. * @type {(passageName:string, func:((args: any[])=>any))=>void}
  14. */
  15. funcRegister: (passageName:string, func:((args: any[])=>any))=>void,
  16. /**
  17. * Registers code that will be run whenever a `setup.qsp_gs()`- call occurs for the given `passageName`.
  18. *
  19. * If the function `exec` returns anything but `undefined`, the default behavior (executing the code of the passage) is skipped.
  20. *
  21. * @type {(passageName:string, func:((args: any[])=>any))=>void}
  22. */
  23. gsRegister: (passageName: string, exec:((args: any[])=>any))=>void,
  24. /**
  25. * Specify `get` to return a constant value when a certain value is requested. Alternatively, you can specify a function, that returns a value. If `undefined` is returned, standard behavior is executed.
  26. *
  27. * Likewise, you can specify `set` to execute code when a value is set. If `set` returns anything but `undefined` standard behavior (setting the var) is skipped.
  28. *
  29. */
  30. varRegister: (varname:string,
  31. get:number|string|((index?:number)=>any)|undefined,
  32. set:((index:number,val:number|string)=>any)|undefined,
  33. )=>void
  34. };
  35. }
  36. }
  37. export {};