4
1

twine-code.d.ts 4.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109
  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. //#region External Code
  58. externalCodeURLs: {[key:string]:{code:string[],style:string[]}};
  59. externalCodePromises: {[key:string]:Promise<any>};
  60. externalCodePromise: (promiseId:string)=>Promise<any>;
  61. //#endregion
  62. getPassageLinks: (passageId:string) => {[passageId:string]:{type:string;line:number}[]};
  63. getPassageLinksToPassage: (passageId:string) => string[];
  64. }
  65. export interface SugarCubeStoryVariables{
  66. PC: PlayerCharacter;
  67. /**
  68. * The dynamic storage for NPC-data.
  69. *
  70. * @type {{[npcID:string]: {[field:string]:any}}}
  71. */
  72. npcDynamic: {[npcID:string]: {[field:string]:any}};
  73. npcs: NPCs;
  74. }
  75. }
  76. declare global {
  77. interface Window { QSP: {[key:(string|number)]: any}; }
  78. }
  79. export interface NPCStaticObject{
  80. _defaults: string[];
  81. [field: string]: string | number | string[];
  82. }
  83. export interface ProficiencyDefinition{
  84. calc: (attributs:{[skillId:string]:Skill}, skills: {[skillId:string]:Skill}) => number;
  85. }
  86. export interface SkillDefinition{
  87. attributes: string[];
  88. }
  89. export {};