twine-code.d.ts 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899
  1. declare module "twine-sugarcube" {
  2. export interface SugarCubeSetupObject {
  3. Example: { new(): Example };
  4. //#region Player Character
  5. attributes: string[];
  6. proficiencies: {[proficiencyId:string]: ProficiencyDefinition};
  7. skills: {[skillId:string]: SkillDefinition};
  8. PlayerCharacter: { new(): PlayerCharacter };
  9. Skill: { new(): Skill };
  10. Skills: {
  11. new(): Skills;
  12. createProxy: ((skills:Skills)=>{[skillId:string]:Skill});
  13. };
  14. //#endregion
  15. /**
  16. * Provides functions to overwrite behavior of functions and variables
  17. */
  18. Overwrite: {
  19. /**
  20. * Registers code that will be run whenever a `setup.qsp_func()`- call occurs for the given `passageName`.
  21. *
  22. * 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.
  23. *
  24. * @type {(passageName:string, func:((args: any[])=>any))=>void}
  25. */
  26. funcRegister: (passageName:string, func:((args: any[])=>any))=>void,
  27. /**
  28. * Registers code that will be run whenever a `setup.qsp_gs()`- call occurs for the given `passageName`.
  29. *
  30. * If the function `exec` returns anything but `undefined`, the default behavior (executing the code of the passage) is skipped.
  31. *
  32. * @type {(passageName:string, func:((args: any[])=>any))=>void}
  33. */
  34. gsRegister: (passageName: string, exec:((args: any[])=>any))=>void,
  35. /**
  36. * 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.
  37. *
  38. * 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.
  39. *
  40. */
  41. varRegister: (varname:string,
  42. get:number|string|((index?:number|string)=>any)|undefined,
  43. set:((index:number|string,val:number|string)=>any)|undefined,
  44. )=>void
  45. varRegisterByPrefix: (varname:string,
  46. get:number|string|((varname:string,index?:number|string)=>any)|undefined,
  47. set:((varname:string,index:number|string,val:number|string)=>any)|undefined,
  48. )=>void
  49. };
  50. NPCs: {new(): NPCs};
  51. NPCAccessor: {new(): NPCAccessor};
  52. npcsInit: (npcIds: string[]) => void;
  53. npcInit: (npcId: string) => void;
  54. npcStatic: {[npcID:string]: NPCStaticObject};
  55. qsp_dyneval: (code:string, ...args : (string|number)[]) => string|number;
  56. qsp_func: (passage:string,...arguments:(string|number)[]) => string|number;
  57. }
  58. export interface SugarCubeStoryVariables{
  59. PC: PlayerCharacter;
  60. /**
  61. * The dynamic storage for NPC-data.
  62. *
  63. * @type {{[npcID:string]: {[field:string]:any}}}
  64. */
  65. npcDynamic: {[npcID:string]: {[field:string]:any}};
  66. npcs: NPCs;
  67. }
  68. }
  69. declare global {
  70. interface Window { QSP: {[key:(string|number)]: any}; }
  71. }
  72. export interface NPCStaticObject{
  73. _defaults: string[];
  74. [field: string]: string | number | string[];
  75. }
  76. export interface ProficiencyDefinition{
  77. calc: (attributs:{[skillId:string]:Skill}, skills: {[skillId:string]:Skill}) => number;
  78. }
  79. export interface SkillDefinition{
  80. attributes: string[];
  81. }
  82. export {};