twine-code.d.ts 5.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143
  1. declare module "twine-sugarcube" {
  2. export interface SugarCubeSetupObject {
  3. Example: { new(): Example };
  4. Filter: { new(): Filter };
  5. //#region Player Character
  6. attributes: string[];
  7. proficiencies: {[proficiencyId:string]: ProficiencyDefinition};
  8. skills: {[skillId:string]: SkillDefinition};
  9. PlayerCharacter: { new(): PlayerCharacter };
  10. Skill: { new(): Skill };
  11. Skills: {
  12. new(): Skills;
  13. createProxy: ((skills:Skills)=>{[skillId:string]:Skill});
  14. };
  15. //#endregion
  16. //#region Static Wardrobe
  17. OutfitItem: {new(itemId?:string): OutfitItem};
  18. OwnedOutfitItem: {new(itemId?:string): OwnedOutfitItem};
  19. outfitShop: {[shopId: string]: {
  20. outfitItems?: {
  21. image?: (key:string)=>string;
  22. }
  23. }};
  24. Wardrobe: {new(): Wardrobe};
  25. wardrobeStatic: {[wardrobeItemId:string]: {[propertyKey:string]:(string|number|string[])}};
  26. //#endregion
  27. //#region Wardrobe Overwrites
  28. wardrobeItemVars: {[type:string]:string[]};
  29. //#endregion
  30. //#region Wardrobe Display
  31. wardrobeDisplay_setup:()=>void;
  32. wardrobeDisplay_setFilter:(filter:FilterData)=>void;
  33. wardrobeDisplay_showItemDetails:(itemId:string)=>void;
  34. wardrobeDisplay_updateAvailable:()=>void;
  35. wardrobeDisplay_updateWorn:()=>void;
  36. //#endregion
  37. /**
  38. * Provides functions to overwrite behavior of functions and variables
  39. */
  40. Overwrite: {
  41. /**
  42. * Registers code that will be run whenever a `setup.qsp_func()`- call occurs for the given `passageName`.
  43. *
  44. * 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.
  45. *
  46. * @type {(passageName:string, func:((args: any[])=>any))=>void}
  47. */
  48. funcRegister: (passageName:string, func:((args: any[])=>any))=>void,
  49. /**
  50. * Registers code that will be run whenever a `setup.qsp_gs()`- call occurs for the given `passageName`.
  51. *
  52. * If the function `exec` returns anything but `undefined`, the default behavior (executing the code of the passage) is skipped.
  53. *
  54. * @type {(passageName:string, func:((args: any[])=>any))=>void}
  55. */
  56. gsRegister: (passageName: string, exec:((args: any[])=>any))=>void,
  57. /**
  58. * 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.
  59. *
  60. * 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.
  61. *
  62. */
  63. varRegister: (varname:string,
  64. get:number|string|((index?:number|string)=>any)|undefined,
  65. set:((index:number|string,val:number|string)=>any)|undefined,
  66. )=>void
  67. varRegisterByPrefix: (varname:string,
  68. get:number|string|((varname:string,index?:number|string)=>any)|undefined,
  69. set:((varname:string,index:number|string,val:number|string)=>any)|undefined,
  70. )=>void
  71. };
  72. NPCs: {new(): NPCs};
  73. NPCAccessor: {new(): NPCAccessor};
  74. npcsInit: (npcIds: string[]) => void;
  75. npcInit: (npcId: string) => void;
  76. npcStatic: {[npcID:string]: NPCStaticObject};
  77. qsp_dyneval: (code:string, ...args : (string|number)[]) => string|number;
  78. qsp_func: (passage:string,...arguments:(string|number)[]) => string|number;
  79. //#region External Code
  80. externalCodeURLs: {[key:string]:{code:string[],style:string[]}};
  81. externalCodePromises: {[key:string]:Promise<any>};
  82. externalCodePromise: (promiseId:string)=>Promise<any>;
  83. //#endregion
  84. getPassageLinks: (passageId:string) => {[passageId:string]:{type:string;line:number}[]};
  85. getPassageLinksToPassage: (passageId:string) => string[];
  86. }
  87. export interface SugarCubeStoryVariables{
  88. PC: PlayerCharacter;
  89. /**
  90. * The dynamic storage for NPC-data.
  91. *
  92. * @type {{[npcID:string]: {[field:string]:any}}}
  93. */
  94. npcDynamic: {[npcID:string]: {[field:string]:any}};
  95. npcs: NPCs;
  96. wardrobe: Wardrobe;
  97. }
  98. export interface SugarCubeTemporaryVariables{
  99. filter: Filter;
  100. }
  101. }
  102. declare global {
  103. interface Window { QSP: {[key:(string|number)]: any}; }
  104. }
  105. export interface NPCStaticObject{
  106. _defaults: string[];
  107. [field: string]: string | number | string[];
  108. }
  109. export interface ProficiencyDefinition{
  110. calc: (attributs:{[skillId:string]:Skill}, skills: {[skillId:string]:Skill}) => number;
  111. }
  112. export interface SkillDefinition{
  113. attributes: string[];
  114. }
  115. export {};