gdcore-tools 2.0.0-gd-v5.4.219-autobuild → 2.0.0-gd-v5.5.221-autobuild
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/Runtime/Extensions/DialogueTree/bondage.js/dist/bondage.d.ts +39 -0
- package/dist/Runtime/Extensions/DialogueTree/dialoguetools.js +2 -2
- package/dist/Runtime/Extensions/DialogueTree/dialoguetools.js.map +2 -2
- package/dist/Runtime/Extensions/Physics2Behavior/JsExtension.js +23 -21
- package/dist/Runtime/Extensions/Physics2Behavior/physics2runtimebehavior.js.map +1 -1
- package/dist/Runtime/Extensions/Physics2Behavior/physics2tools.js +1 -1
- package/dist/Runtime/Extensions/Physics2Behavior/physics2tools.js.map +2 -2
- package/dist/Runtime/Extensions/Physics3DBehavior/JsExtension.js +2472 -0
- package/dist/Runtime/Extensions/Physics3DBehavior/Physics3DRuntimeBehavior.js +2 -0
- package/dist/Runtime/Extensions/Physics3DBehavior/Physics3DRuntimeBehavior.js.map +7 -0
- package/dist/Runtime/Extensions/Physics3DBehavior/Physics3DTools.js +2 -0
- package/dist/Runtime/Extensions/Physics3DBehavior/Physics3DTools.js.map +7 -0
- package/dist/Runtime/Extensions/Physics3DBehavior/PhysicsCharacter3DRuntimeBehavior.js +2 -0
- package/dist/Runtime/Extensions/Physics3DBehavior/PhysicsCharacter3DRuntimeBehavior.js.map +7 -0
- package/dist/Runtime/Extensions/Physics3DBehavior/jolt-physics.d.ts +5152 -0
- package/dist/Runtime/Extensions/Physics3DBehavior/jolt-physics.wasm.js +2 -0
- package/dist/Runtime/Extensions/Physics3DBehavior/jolt-physics.wasm.js.map +7 -0
- package/dist/Runtime/Extensions/Physics3DBehavior/jolt-physics.wasm.wasm +0 -0
- package/dist/Runtime/Extensions/PlatformBehavior/platformerobjectruntimebehavior.js.map +2 -2
- package/dist/Runtime/Extensions/TileMap/helper/TileMapHelper.js +1 -1
- package/dist/Runtime/Extensions/TileMap/helper/TileMapHelper.js.map +1 -1
- package/dist/Runtime/RuntimeInstanceContainer.js +1 -1
- package/dist/Runtime/RuntimeInstanceContainer.js.map +2 -2
- package/dist/Runtime/events-tools/soundtools.js +1 -1
- package/dist/Runtime/events-tools/soundtools.js.map +2 -2
- package/dist/Runtime/pixi-renderers/pixi-image-manager.js +1 -1
- package/dist/Runtime/pixi-renderers/pixi-image-manager.js.map +2 -2
- package/dist/Runtime/pixi-renderers/runtimegame-pixi-renderer.js +1 -1
- package/dist/Runtime/pixi-renderers/runtimegame-pixi-renderer.js.map +2 -2
- package/dist/lib/libGD.cjs +1 -1
- package/dist/lib/libGD.wasm +0 -0
- package/gd.d.ts +4 -2
- package/package.json +1 -1
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
declare namespace bondage {
|
|
2
|
+
export class Runner {
|
|
3
|
+
yarnNodes: any;
|
|
4
|
+
variables: any;
|
|
5
|
+
functions: any;
|
|
6
|
+
visited: any;
|
|
7
|
+
load(data: any[]): void;
|
|
8
|
+
setVariableStorage(storage: any): void;
|
|
9
|
+
registerFunction(name: string, func): void;
|
|
10
|
+
run(startNode: string): any;
|
|
11
|
+
evalNodes(nodes: any[], yarnNodeData: any): any;
|
|
12
|
+
handleSelections(selections: any[]): any;
|
|
13
|
+
evaluateAssignment(node: any): any;
|
|
14
|
+
evaluateConditional(node: any): any;
|
|
15
|
+
evaluateExpressionOrLiteral(node): any;
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
export class Result {}
|
|
19
|
+
|
|
20
|
+
export class TextResult extends Result {
|
|
21
|
+
text: string;
|
|
22
|
+
data: any;
|
|
23
|
+
lineNum: number;
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
export class CommandResult extends Result {
|
|
27
|
+
text: string;
|
|
28
|
+
data: any;
|
|
29
|
+
lineNum: number;
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
export class OptionsResult extends Result {
|
|
33
|
+
options: string[];
|
|
34
|
+
lineNum: number[];
|
|
35
|
+
selected: number;
|
|
36
|
+
|
|
37
|
+
select(index: number): void;
|
|
38
|
+
}
|
|
39
|
+
}
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
var gdjs;(function(
|
|
2
|
-
`)}),a}
|
|
1
|
+
var gdjs;(function(l){let F;(function(Le){const s=new l.Logger("Dialogue tree"),n=new bondage.Runner;let g,u=0,o="",m=!1,p=[],f=0,b=!1,v=[],r=null,i=!1,c=null,x="",C=0,L=0,d=[],y,h=[],S="";function j(e,t){try{const a=JSON.parse(e.getAsString());n.load(a),t&&t.length>0&&l.dialogueTree.startFrom(t)}catch(a){s.error("Error while loading from scene variable: ",a)}}Le.loadFromSceneVariable=j;function E(e,t,a){e.getGame().getJsonManager().loadJson(t,function(T,R){if(T)s.error("An error happened while loading JSON resource:",T);else{if(!R)return;const A=R;try{n.load(A)}catch(N){s.error("An error happened while loading parsing the dialogue tree data:",N)}a&&a.length>0&&l.dialogueTree.startFrom(a)}})}Le.loadFromJsonFile=E;function P(){i=!1,r=null,o="",u=0}Le.stopRunningDialogue=P;function J(){return i&&!r&&o&&u>=o.length&&(i=!1),i}Le.isRunning=J;function _(){if(!(m||!i)){if(r instanceof bondage.CommandResult&&c==="text"&&x===r.data.title&&C===r.lineNum&&l.dialogueTree.hasClippedScrollingCompleted()){l.dialogueTree.goToNextDialogueLine();return}o&&c==="text"&&u<o.length&&(u+=1)}}Le.scrollClippedText=_;function M(){m||!i||!o||c!=="text"||(u=o.length)}Le.completeClippedTextScrolling=M;function z(){return!i||c===""?!1:r&&o.length>0&&u>=o.length?(l.dialogueTree.getVariable("debug")&&s.warn("Scroll completed:",u,"/",o.length),!0):!1}Le.hasClippedScrollingCompleted=z;function H(){return i&&o.length?o.substring(0,u+1):""}Le.getClippedLineText=H;function G(){return i&&o.length?o:""}Le.getLineText=G;function U(){return p.length>1?p.length-1:0}Le.commandParametersCount=U;function k(e){if(e===-1&&p.length>0)return p[0];if(p.length>=e+1){const t=p[e+1];return t||""}return""}Le.getCommandParameter=k;function K(e){return!i||m||!g?!1:g.some(function(t,a){return u!==0&&u<t.time?!1:(t.cmd==="wait"&&(u===0||u!==o.length)&&(m=!0,setTimeout(function(){m=!1,g.splice(a,1),l.dialogueTree.getVariable("debug")&&s.info("CMD:",t)},parseInt(t.params[1],10))),t.cmd===e?(p=t.params,g.splice(a,1),l.dialogueTree.getVariable("debug")&&s.info("CMD:",t),!0):!1)})}Le.isCommandCalled=K;function V(e){return e>=d.length&&(e=d.length-1),e<0&&(e=0),e}function w(e){return e>=d.length&&(e=0),e<0&&(e=d.length-1),e}function Q(e){return!i||!d.length?[]:(e=V(e),d[e])}Le.getLineOption=Q;function W(e,t){if(!i||!d.length)return"";let a="";return d.forEach(function(T,R){R===f?a+=e:a+=e.replace(/.*/g," "),a+=T,t&&(a+=`
|
|
2
|
+
`)}),a}Le.getLineOptionsText=W;function X(e){return l.dialogueTree.getLineOptionsText(e,!1)}Le.getLineOptionsTextHorizontal=X;function Y(e){return l.dialogueTree.getLineOptionsText(e,!0)}Le.getLineOptionsTextVertical=Y;function Z(){return i&&d.length?L:0}Le.getLineOptionsCount=Z;function $(){if(!!i&&r instanceof bondage.OptionsResult&&!b&&f!==-1){g=[];try{r.select(f);try{r=y.next().value}catch(e){s.error("Error while confirming in the dialogue tree. Verify if there is a syntax error? Full error is: ",e);return}l.dialogueTree.goToNextDialogueLine()}catch(e){s.error("An error happened when trying to access the dialogue branch!",e)}}}Le.confirmSelectOption=$;function q(){!i||O()&&(f+=1,f=w(f),b=!0)}Le.selectNextOption=q;function I(){!i||O()&&(f-=1,f=w(f),b=!0)}Le.selectPreviousOption=I;function ee(e){!i||O()&&(f=V(e),b=!0)}Le.selectOption=ee;function te(){return i&&O()?f:0}Le.getSelectedOption=te;function re(){return b?(b=!1,f===-1&&(f=0),!0):!1}Le.hasSelectedOptionChanged=re;function ne(e){if(!i)return!1;if(g&&e==="command"){if(g.some(function(t){return u>t.time&&t.cmd==="wait"}))return!m;if(g.length>0&&p.length>0)return!0}return c===e}Le.isDialogueLineType=ne;function ie(e){return n&&n.yarnNodes&&Object.keys(n.yarnNodes).some(function(t){return t===e})}Le.hasDialogueBranch=ie;function ae(e){if(!!l.dialogueTree.hasDialogueBranch(e)){L=0,d=[],v=[];try{y=n.run(e)}catch(t){s.error("Error while setting up the dialogue tree. Verify if there is a syntax error? Full error is: ",t);return}o="",u=0,g=[],p=[],m=!1;try{r=y.next().value}catch(t){s.error("Error while starting the dialogue tree. Verify if there is a syntax error? Full error is: ",t);return}!r||((r instanceof bondage.TextResult||r instanceof bondage.CommandResult)&&(h=r.data.tags,x=r.data.title,S=r.data.body),C=r.lineNum,B()?c="text":O()?c="options":c="command",i=!0,l.dialogueTree.goToNextDialogueLine())}}Le.startFrom=ae;function B(){return r instanceof bondage.TextResult}function O(){return r instanceof bondage.OptionsResult}function D(){return r instanceof bondage.CommandResult}function oe(){if(!(m||!i))if(L=0,f=-1,b=!1,l.dialogueTree.getVariable("debug")&&s.info("Parsing:",r),!r)l.dialogueTree.stopRunningDialogue();else if(r instanceof bondage.TextResult){C===r.lineNum&&x===r.data.title?(u=o.length-1,o+=(o===""?"":" ")+r.text):(u=0,o=r.text),h=r.data.tags,x=r.data.title,S=r.data.body,C=r.lineNum,c="text";try{r=y.next().value}catch(e){s.error("Error while progressing the dialogue tree. Verify if there is a syntax error? Full error is: ",e);return}}else if(r instanceof bondage.OptionsResult)g=[],c="options",o="",u=0,L=r.options.length,d=r.options,b=!0;else if(D()){c="command";const e=r.text.split(" "),t=g.length&&g[g.length-1].cmd==="wait"?1:0;g.push({cmd:e[0],params:e,time:o.length+t});try{r=y.next().value}catch(a){s.error("Error while progressing the dialogue tree. Verify if there is a syntax error? Full error is: ",a);return}l.dialogueTree.goToNextDialogueLine()}else c="unknown"}Le.goToNextDialogueLine=oe;function le(){return i?x:""}Le.getBranchTitle=le;function ue(e){return i?x===e:!1}Le.branchTitleIs=ue;function se(){return i?h.join(","):""}Le.getBranchTags=se;function ge(e){return i&&h.length?(e>h.length-1&&(e=h.length-1),h[e]):""}Le.getBranchTag=ge;function fe(e){return v=[],i&&h.length?h.some(function(t){const a=t.match(/([^\(]+)\(([^\)]+)\)/i);return v=a?a[2].split(","):[],a?a[1]===e:t===e}):!1}Le.branchContainsTag=fe;function ce(e){if(i&&v.length>=e){const t=v[e];return t||""}return""}Le.getTagParameter=ce;function de(){return i?Object.keys(n.visited).join(","):""}Le.getVisitedBranchTitles=de;function pe(e){return e||(e=x),Object.keys(n.visited).includes(e)&&n.visited[e]}Le.branchTitleHasBeenVisited=pe;function he(){return i?S:""}Le.getBranchText=he;function me(e){return n.variables&&e in n.variables.data?n.variables.get(e):""}Le.getVariable=me;function be(e){if(n.variables&&e in n.variables.data){const t=n.variables.get(e);return typeof t!="number"?parseFloat(t)||0:isFinite(t)?t:0}return 0}Le.getVariableAsNumber=be;function xe(e){return n.variables&&e in n.variables.data?""+n.variables.get(e):""}Le.getVariableAsString=xe;function Te(e,t){return n.variables&&e in n.variables.data?n.variables.get(e)===t:!1}Le.compareVariable=Te;function ve(e,t){n.variables&&n.variables.set(e,t)}Le.setVariable=ve;function ye(e){const t={variables:n.variables.data,visited:n.visited};e.fromJSObject(t)}Le.saveState=ye;function Oe(e){const t=e.toJSObject();if(!t){s.error("Load state variable is empty:",e);return}try{n.visited=t.visited,n.variables.data={},Object.keys(t.variables).forEach(function(a){const T=t.variables[a];n.variables.set(a,T)})}catch(a){s.error("Failed to load state from variable:",e,a)}}Le.loadState=Oe;function Ce(){n.visited={},n.variables.data={}}Le.clearState=Ce})(F=l.dialogueTree||(l.dialogueTree={}))})(gdjs||(gdjs={}));
|
|
3
3
|
//# sourceMappingURL=dialoguetools.js.map
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../../../GDevelop/Extensions/DialogueTree/dialoguetools.ts"],
|
|
4
|
-
"sourcesContent": ["// @ts-nocheck - Weird usage of `this` in this file. Should be refactored.\n\nnamespace gdjs {\n const logger = new gdjs.Logger('Dialogue tree');\n\n gdjs.dialogueTree = {};\n gdjs.dialogueTree.runner = new bondage.Runner();\n\n /**\n * Load the Dialogue Tree data of the game. Initialize The Dialogue Tree, so as it can be used in the game.\n * @param sceneVar The variable to load the Dialogue tree data from. The data is a JSON string, created by Yarn.\n * @param startDialogueNode The Dialogue Branch to start the Dialogue Tree from. If left empty, the data will only be loaded, but can later be initialized via another action\n */\n gdjs.dialogueTree.loadFromSceneVariable = function (\n sceneVar: gdjs.Variable,\n startDialogueNode: string\n ) {\n this.runner = gdjs.dialogueTree.runner;\n try {\n this.yarnData = JSON.parse(sceneVar.getAsString());\n this.runner.load(this.yarnData);\n if (startDialogueNode && startDialogueNode.length > 0) {\n gdjs.dialogueTree.startFrom(startDialogueNode);\n }\n } catch (e) {\n logger.error('Error while loading from scene variable: ', e);\n }\n };\n\n /**\n * Load the Dialogue Tree data from a JSON resource.\n *\n * @param instanceContainer The scene where the dialogue is running.\n * @param jsonResourceName The JSON resource where to load the Dialogue Tree data from. The data is a JSON string usually created with [Yarn Dialogue Editor](https://github.com/InfiniteAmmoInc/Yarn).\n * @param startDialogueNode The Dialogue Branch to start the Dialogue Tree from. If left empty, the data will only be loaded, but can later be initialized via another action\n */\n gdjs.dialogueTree.loadFromJsonFile = function (\n instanceContainer: gdjs.RuntimeInstanceContainer,\n jsonResourceName: string,\n startDialogueNode: string\n ) {\n instanceContainer\n .getGame()\n .getJsonManager()\n .loadJson(jsonResourceName, function (error, content) {\n if (error) {\n logger.error('An error happened while loading JSON resource:', error);\n } else {\n if (!content) {\n return;\n }\n gdjs.dialogueTree.yarnData = content;\n try {\n gdjs.dialogueTree.runner.load(gdjs.dialogueTree.yarnData);\n } catch (error) {\n logger.error(\n 'An error happened while loading parsing the dialogue tree data:',\n error\n );\n }\n if (startDialogueNode && startDialogueNode.length > 0) {\n gdjs.dialogueTree.startFrom(startDialogueNode);\n }\n }\n });\n };\n\n /**\n * Stop the currently running dialogue\n */\n gdjs.dialogueTree.stopRunningDialogue = function () {\n if (this.dialogueIsRunning) {\n this.dialogueIsRunning = false;\n }\n if (this.dialogueData) {\n this.dialogueData = null;\n }\n this.dialogueText = '';\n this.clipTextEnd = 0;\n };\n\n /**\n * Check if the Dialogue Tree is currently parsing data.\n * For example, you can do things like disabling player movement while talking to a NPC.\n */\n gdjs.dialogueTree.isRunning = function () {\n if (\n this.dialogueIsRunning &&\n !this.dialogueData &&\n this.dialogueText &&\n this.clipTextEnd >= this.dialogueText.length\n ) {\n this.dialogueIsRunning = false;\n }\n return this.dialogueIsRunning;\n };\n\n /**\n * Scroll the clipped text. This can be combined with a timer and user input to control how fast the dialogue line text is scrolling.\n */\n gdjs.dialogueTree.scrollClippedText = function () {\n if (this.pauseScrolling || !this.dialogueIsRunning) {\n return;\n }\n\n // Autoscroll commands so the user doesn't have to press again.\n if (\n gdjs.dialogueTree._isLineTypeCommand() &&\n this.dialogueDataType === 'text' &&\n this.dialogueBranchTitle === this.dialogueData.data.title &&\n this.lineNum === this.dialogueData.lineNum &&\n gdjs.dialogueTree.hasClippedScrollingCompleted()\n ) {\n gdjs.dialogueTree.goToNextDialogueLine();\n return;\n }\n\n // Increment scrolling of clipped text\n if (\n this.dialogueText &&\n this.dialogueDataType === 'text' &&\n this.clipTextEnd < this.dialogueText.length\n ) {\n this.clipTextEnd += 1;\n }\n };\n\n /**\n * Scroll the clipped text to its end, so the entire text is printed. This can be useful in keeping the event sheet logic simpler, while supporting more variation.\n */\n gdjs.dialogueTree.completeClippedTextScrolling = function () {\n if (\n this.pauseScrolling ||\n !this.dialogueIsRunning ||\n !this.dialogueText ||\n this.dialogueDataType !== 'text'\n ) {\n return;\n }\n this.clipTextEnd = this.dialogueText.length;\n };\n\n /**\n * Check if text scrolling has completed.\n * Useful to prevent the user from skipping to next line before the current one has been printed fully.\n */\n gdjs.dialogueTree.hasClippedScrollingCompleted = function () {\n if (!this.dialogueIsRunning || this.dialogueDataType === '') {\n return false;\n }\n if (\n this.dialogueData &&\n this.dialogueText.length > 0 &&\n this.clipTextEnd >= this.dialogueText.length\n ) {\n if (gdjs.dialogueTree.getVariable('debug')) {\n logger.warn(\n 'Scroll completed:',\n this.clipTextEnd,\n '/',\n this.dialogueText.length\n );\n }\n return true;\n }\n return false;\n };\n\n /**\n * Get the current dialogue line with a scrolling effect (recommended).\n * Used with the scrollClippedText to achieve a classic scrolling text, as well as any <<wait>> effects to pause scrolling.\n */\n gdjs.dialogueTree.getClippedLineText = function () {\n return this.dialogueIsRunning && this.dialogueText.length\n ? this.dialogueText.substring(0, this.clipTextEnd + 1)\n : '';\n };\n\n /**\n * Get the current complete dialogue line without using any scrolling effects.\n * Note that using this instead getClippedLineText will skip any <<wait>> commands entirely.\n */\n gdjs.dialogueTree.getLineText = function () {\n return this.dialogueIsRunning && this.dialogueText.length\n ? this.dialogueText\n : '';\n };\n\n /**\n * Get the number of command parameters in a command with parameters that has been caught by a isCommandCalled condition\n */\n gdjs.dialogueTree.commandParametersCount = function () {\n if (this.commandParameters && this.commandParameters.length > 1) {\n return this.commandParameters.length - 1;\n }\n return 0;\n };\n\n /**\n * Get a command parameter in any command with parameters that has been caught by a isCommandCalled condition\n * @param paramIndex The index of the parameter to get.\n */\n gdjs.dialogueTree.getCommandParameter = function (paramIndex: float) {\n if (paramIndex === -1 && this.commandParameters.length > 0) {\n return this.commandParameters[0];\n }\n if (\n this.commandParameters &&\n this.commandParameters.length >= paramIndex + 1\n ) {\n const returnedParam = this.commandParameters[paramIndex + 1];\n return returnedParam ? returnedParam : '';\n }\n return '';\n };\n\n /**\n * Catch <<commands>> and <<commands with parameters>> from the current Dialogue Line.\n * You can trigger custom logic that relate to the story you are telling during the dialogue.\n *\n * @param command The command you want to check for being called. Write it without the `<<>>`.\n */\n gdjs.dialogueTree.isCommandCalled = function (command: string) {\n if (!this.dialogueIsRunning) {\n return false;\n }\n const commandCalls = gdjs.dialogueTree.commandCalls;\n const clipTextEnd = gdjs.dialogueTree.clipTextEnd;\n const dialogueText = gdjs.dialogueTree.dialogueText;\n if (this.pauseScrolling || !commandCalls) {\n return false;\n }\n return this.commandCalls.some(function (call, index) {\n if (clipTextEnd !== 0 && clipTextEnd < call.time) {\n return false;\n }\n if (\n call.cmd === 'wait' &&\n (clipTextEnd === 0 || clipTextEnd !== dialogueText.length)\n ) {\n gdjs.dialogueTree.pauseScrolling = true;\n setTimeout(function () {\n gdjs.dialogueTree.pauseScrolling = false;\n commandCalls.splice(index, 1);\n if (gdjs.dialogueTree.getVariable('debug')) {\n logger.info('CMD:', call);\n }\n }, parseInt(call.params[1], 10));\n }\n if (call.cmd === command) {\n gdjs.dialogueTree.commandParameters = call.params;\n commandCalls.splice(index, 1);\n if (gdjs.dialogueTree.getVariable('debug')) {\n logger.info('CMD:', call);\n }\n return true;\n }\n });\n };\n\n /**\n * Internal method to allow for capping option selection.\n */\n gdjs.dialogueTree._normalizedOptionIndex = function (optionIndex) {\n if (optionIndex >= this.options.length) {\n optionIndex = this.options.length - 1;\n }\n if (optionIndex < 0) {\n optionIndex = 0;\n }\n return optionIndex;\n };\n\n /**\n * Internal method to allow for cycling option selection.\n */\n gdjs.dialogueTree._cycledOptionIndex = function (optionIndex) {\n if (optionIndex >= this.options.length) {\n optionIndex = 0;\n }\n if (optionIndex < 0) {\n optionIndex = this.options.length - 1;\n }\n return optionIndex;\n };\n\n /**\n * Get the text of an option the player can select.\n * Used with getLineOptionsCount to render options for the player when a line of the Options type is parsed\n * @param optionIndex The index of the option you want to get\n */\n gdjs.dialogueTree.getLineOption = function (optionIndex: float) {\n if (!this.dialogueIsRunning || !this.options.length) {\n return [];\n }\n optionIndex = gdjs.dialogueTree._normalizedOptionIndex(optionIndex);\n return this.options[optionIndex];\n };\n\n /**\n * Get the text of the options the player can select, along with the selection cursor.\n * @param optionSelectionCursor The string used to draw the currently selected option's cursor\n * @param addNewLine when true each option is rendered on a new line.\n */\n gdjs.dialogueTree.getLineOptionsText = function (\n optionSelectionCursor: string,\n addNewLine: boolean\n ) {\n if (!this.dialogueIsRunning || !this.options.length) {\n return '';\n }\n let textResult = '';\n this.options.forEach(function (optionText, index) {\n if (index === gdjs.dialogueTree.selectedOption) {\n textResult += optionSelectionCursor;\n } else {\n textResult += optionSelectionCursor.replace(/.*/g, ' ');\n }\n textResult += optionText;\n if (addNewLine) {\n textResult += '\\n';\n }\n });\n return textResult;\n };\n gdjs.dialogueTree.getLineOptionsTextHorizontal = function (\n optionSelectionCursor\n ) {\n return this.getLineOptionsText(optionSelectionCursor, false);\n };\n gdjs.dialogueTree.getLineOptionsTextVertical = function (\n optionSelectionCursor\n ) {\n return this.getLineOptionsText(optionSelectionCursor, true);\n };\n\n /**\n * Get the number of options that are presented to the player, during the parsing of an Options type line.\n * @returns The number of options\n */\n gdjs.dialogueTree.getLineOptionsCount = function (): number {\n if (this.dialogueIsRunning && this.options.length) {\n return this.optionsCount;\n }\n return 0;\n };\n\n /**\n * Confirm the currently selected option, during the parsing of an Options type line.\n *\n * This will advance the dialogue tree to the dialogue branch was selected by the player.\n */\n gdjs.dialogueTree.confirmSelectOption = function () {\n if (!this.dialogueIsRunning) {\n return;\n }\n if (\n this.dialogueData.select &&\n !this.selectedOptionUpdated &&\n this.selectedOption !== -1\n ) {\n this.commandCalls = [];\n try {\n this.dialogueData.select(this.selectedOption);\n try {\n this.dialogueData = this.dialogue.next().value;\n } catch (error) {\n logger.error(\n 'Error while confirming in the dialogue tree. Verify if there is a syntax error? Full error is: ',\n error\n );\n return;\n }\n gdjs.dialogueTree.goToNextDialogueLine();\n } catch (error) {\n logger.error(\n `An error happened when trying to access the dialogue branch!`,\n error\n );\n }\n }\n };\n\n /**\n * Select next option during Options type line parsing. Hook this to your game input.\n */\n gdjs.dialogueTree.selectNextOption = function () {\n if (!this.dialogueIsRunning) {\n return;\n }\n if (this.dialogueData.select) {\n this.selectedOption += 1;\n this.selectedOption = gdjs.dialogueTree._cycledOptionIndex(\n this.selectedOption\n );\n this.selectedOptionUpdated = true;\n }\n };\n\n /**\n * Select previous option during Options type line parsing. Hook this to your game input.\n */\n gdjs.dialogueTree.selectPreviousOption = function () {\n if (!this.dialogueIsRunning) {\n return;\n }\n if (this.dialogueData.select) {\n this.selectedOption -= 1;\n this.selectedOption = gdjs.dialogueTree._cycledOptionIndex(\n this.selectedOption\n );\n this.selectedOptionUpdated = true;\n }\n };\n\n /**\n * Select option by index during Options type line parsing.\n * @param optionIndex The index of the option to select\n */\n gdjs.dialogueTree.selectOption = function (optionIndex: float) {\n if (!this.dialogueIsRunning) {\n return;\n }\n if (this.dialogueData.select) {\n this.selectedOption = gdjs.dialogueTree._normalizedOptionIndex(\n optionIndex\n );\n this.selectedOptionUpdated = true;\n }\n };\n\n /**\n * Get the currently selected option\n * @returns The index of the currently selected option\n */\n gdjs.dialogueTree.getSelectedOption = function (): number {\n if (!this.dialogueIsRunning) {\n return;\n }\n if (this.dialogueData.select) {\n return this.selectedOption;\n }\n return 0;\n };\n\n /**\n * Check when the player has changed option selection since the last call to this function.\n *\n * Can be used to re-render your displayed dialogue options when needed.\n *\n * @returns true if the selected option was updated since the last call to this function\n */\n gdjs.dialogueTree.hasSelectedOptionChanged = function (): boolean {\n if (this.selectedOptionUpdated) {\n this.selectedOptionUpdated = false;\n if (this.selectedOption === -1) {\n this.selectedOption = 0;\n }\n return true;\n }\n return false;\n };\n\n /**\n * Check the type of the Dialogue Line that is being displayed to the player at the moment.\n *\n * There are three types:\n * - text - regular dialogue text is being parsed at the moment\n * - options - the player has reached a branching choice moment where they must select one of multiple options\n * - command - a <<command>> was called in the background, that can be used to trigger game events, but will not be displayed in the dialogue box.\n *\n * @param type The type you want to check for ( one of the three above )\n */\n gdjs.dialogueTree.isDialogueLineType = function (type: string) {\n if (!this.dialogueIsRunning) {\n return false;\n }\n if (this.commandCalls && type === 'command') {\n if (\n this.commandCalls.some(function (call) {\n return (\n gdjs.dialogueTree.clipTextEnd > call.time && call.cmd === 'wait'\n );\n })\n ) {\n return !this.pauseScrolling;\n }\n if (this.commandCalls.length > 0 && this.commandParameters.length > 0) {\n return true;\n }\n }\n return this.dialogueDataType === type;\n };\n\n /**\n * Check if a branch exists. It is also used internally whenever you use the start from action.\n * @param branchName The Dialogue Branch name you want to check.\n */\n gdjs.dialogueTree.hasDialogueBranch = function (branchName: string) {\n return (\n this.runner &&\n this.runner.yarnNodes &&\n Object.keys(this.runner.yarnNodes).some(function (node) {\n return node === branchName;\n })\n );\n };\n\n /**\n * Start parsing dialogue from a specified Dialogue tree branch.\n * Can be used if you want to store multiple dialogues inside a single Dialogue tree data set.\n * @param startDialogueNode The Dialogue Branch name you want to start parsing from.\n */\n gdjs.dialogueTree.startFrom = function (startDialogueNode: string) {\n this.runner = gdjs.dialogueTree.runner;\n if (!this.hasDialogueBranch(startDialogueNode)) {\n return;\n }\n this.optionsCount = 0;\n this.options = [];\n this.tagParameters = [];\n try {\n this.dialogue = this.runner.run(startDialogueNode);\n } catch (error) {\n logger.error(\n 'Error while setting up the dialogue tree. Verify if there is a syntax error? Full error is: ',\n error\n );\n return;\n }\n this.dialogueText = '';\n this.clipTextEnd = 0;\n this.commandCalls = [];\n this.commandParameters = [];\n this.pauseScrolling = false;\n try {\n this.dialogueData = this.dialogue.next().value;\n } catch (error) {\n logger.error(\n 'Error while starting the dialogue tree. Verify if there is a syntax error? Full error is: ',\n error\n );\n return;\n }\n this.dialogueBranchTags = this.dialogueData.data.tags;\n this.dialogueBranchTitle = this.dialogueData.data.title;\n this.dialogueBranchBody = this.dialogueData.data.body;\n this.lineNum = this.dialogueData.lineNum;\n if (gdjs.dialogueTree._isLineTypeText()) {\n this.dialogueDataType = 'text';\n } else {\n if (gdjs.dialogueTree._isLineTypeOptions()) {\n this.dialogueDataType = 'options';\n } else {\n this.dialogueDataType = 'command';\n }\n }\n this.dialogueIsRunning = true;\n gdjs.dialogueTree.goToNextDialogueLine();\n };\n\n /**\n * Internal methods to check the type of a Dialogue Line\n */\n gdjs.dialogueTree._isLineTypeText = function () {\n return this.dialogueData instanceof bondage.TextResult;\n };\n gdjs.dialogueTree._isLineTypeOptions = function () {\n return this.dialogueData instanceof bondage.OptionsResult;\n };\n gdjs.dialogueTree._isLineTypeCommand = function () {\n return this.dialogueData instanceof bondage.CommandResult;\n };\n\n /**\n * This is the main lifecycle function.It runs once only when the user is advancing the dialogue to the next line.\n * Progress Dialogue to the next line. Hook it to your game input.\n * Note that this action can be influenced by any <<wait>> commands, but they work only if you have at least one isCommandCalled condition.\n */\n gdjs.dialogueTree.goToNextDialogueLine = function () {\n if (this.pauseScrolling || !this.dialogueIsRunning) {\n return;\n }\n this.optionsCount = 0;\n this.selectedOption = -1;\n this.selectedOptionUpdated = false;\n if (gdjs.dialogueTree.getVariable('debug')) {\n logger.info('Parsing:', this.dialogueData);\n }\n if (!this.dialogueData) {\n gdjs.dialogueTree.stopRunningDialogue();\n } else {\n if (gdjs.dialogueTree._isLineTypeText()) {\n if (\n this.lineNum === this.dialogueData.lineNum &&\n this.dialogueBranchTitle === this.dialogueData.data.title\n ) {\n this.clipTextEnd = this.dialogueText.length - 1;\n this.dialogueText +=\n (this.dialogueText === '' ? '' : ' ') + this.dialogueData.text;\n } else {\n this.clipTextEnd = 0;\n this.dialogueText = this.dialogueData.text;\n }\n this.dialogueBranchTags = this.dialogueData.data.tags;\n this.dialogueBranchTitle = this.dialogueData.data.title;\n this.dialogueBranchBody = this.dialogueData.data.body;\n this.lineNum = this.dialogueData.lineNum;\n this.dialogueDataType = 'text';\n try {\n this.dialogueData = this.dialogue.next().value;\n } catch (error) {\n logger.error(\n 'Error while progressing the dialogue tree. Verify if there is a syntax error? Full error is: ',\n error\n );\n return;\n }\n } else {\n if (gdjs.dialogueTree._isLineTypeOptions()) {\n this.commandCalls = [];\n this.dialogueDataType = 'options';\n this.dialogueText = '';\n this.clipTextEnd = 0;\n this.optionsCount = this.dialogueData.options.length;\n this.options = this.dialogueData.options;\n this.selectedOptionUpdated = true;\n } else {\n if (gdjs.dialogueTree._isLineTypeCommand()) {\n this.dialogueDataType = 'command';\n const command = this.dialogueData.text.split(' ');\n\n // If last command was to wait, increase time by one\n const offsetTime =\n this.commandCalls.length &&\n this.commandCalls[this.commandCalls.length - 1].cmd === 'wait'\n ? 1\n : 0;\n this.commandCalls.push({\n cmd: command[0],\n params: command,\n time: this.dialogueText.length + offsetTime,\n });\n try {\n this.dialogueData = this.dialogue.next().value;\n } catch (error) {\n logger.error(\n 'Error while progressing the dialogue tree. Verify if there is a syntax error? Full error is: ',\n error\n );\n return;\n }\n gdjs.dialogueTree.goToNextDialogueLine();\n } else {\n this.dialogueDataType = 'unknown';\n }\n }\n }\n }\n };\n\n /**\n * Get the current Dialogue Tree branch title.\n * @returns The current branch title.\n */\n gdjs.dialogueTree.getBranchTitle = function (): string {\n if (this.dialogueIsRunning) {\n return this.dialogueBranchTitle;\n }\n return '';\n };\n\n /**\n * Check if the currently parsed Dialogue branch title is a query.\n * @param title The Dialogue Branch name you want to check for.\n */\n gdjs.dialogueTree.branchTitleIs = function (title: string) {\n if (this.dialogueIsRunning) {\n return this.dialogueBranchTitle === title;\n }\n return false;\n };\n\n /**\n * Get all the branch tags from the current Dialogue branch as a string. Useful for debugging.\n * @returns The current branch tags, separated by a comma.\n */\n gdjs.dialogueTree.getBranchTags = function (): string {\n if (this.dialogueIsRunning) {\n return this.dialogueBranchTags.join(',');\n }\n return '';\n };\n\n /**\n * Get one of the current Dialogue branch tags via index.\n * @param index The index of the Dialogue Branch tag you want to get.\n * @returns The branch tag at the specified index, or an empty string if not found.\n */\n gdjs.dialogueTree.getBranchTag = function (index: float): string {\n if (this.dialogueIsRunning && this.dialogueBranchTags.length) {\n if (index > this.dialogueBranchTags.length - 1) {\n index = this.dialogueBranchTags.length - 1;\n }\n return this.dialogueBranchTags[index];\n }\n return '';\n };\n\n /**\n * Check if the current Dialogue branch contains a specific tag.\n * @param query The name of the Dialogue Branch tag you want to check.\n */\n gdjs.dialogueTree.branchContainsTag = function (query: string) {\n this.tagParameters = [];\n if (this.dialogueIsRunning && this.dialogueBranchTags.length) {\n return this.dialogueBranchTags.some(function (tag) {\n const splitTag = tag.match(/([^\\(]+)\\(([^\\)]+)\\)/i);\n gdjs.dialogueTree.tagParameters = splitTag\n ? splitTag[2].split(',')\n : [];\n return splitTag ? splitTag[1] === query : tag === query;\n });\n }\n return false;\n };\n\n /**\n * Get any tag(parameter,anotherParameter) from a tag captured by the branchContainsTag Condition\n * @param paramIndex The index of the tag parameter you want to get.\n * Leaving this empty will result in retrieving the first parameter.\n */\n gdjs.dialogueTree.getTagParameter = function (paramIndex: float) {\n if (this.dialogueIsRunning && this.tagParameters.length >= paramIndex) {\n const returnedParam = this.tagParameters[paramIndex];\n return returnedParam ? returnedParam : '';\n }\n return '';\n };\n\n /**\n * Get a list of all the titles of visited by the player Branches. Useful for debugging.\n */\n gdjs.dialogueTree.getVisitedBranchTitles = function () {\n if (this.dialogueIsRunning) {\n return Object.keys(this.runner.visited).join(',');\n }\n return '';\n };\n\n /**\n * Check if a player has visited a Dialogue Branch in the past.\n * @param title The title of the branch to check for.\n * Leaving this empty will check if the current branch title has been visited in the past.\n */\n gdjs.dialogueTree.branchTitleHasBeenVisited = function (title: string) {\n if (!title) {\n title = this.dialogueBranchTitle;\n }\n return (\n Object.keys(this.runner.visited).includes(title) &&\n this.runner.visited[title]\n );\n };\n\n /**\n * Get the entire unparsed text of the current Dialogue Branch\n */\n gdjs.dialogueTree.getBranchText = function () {\n if (this.dialogueIsRunning) {\n return this.dialogueBranchBody;\n }\n return '';\n };\n\n /**\n * Get the value of a variable stored in the dialogue state.\n * @param key The variable name\n */\n gdjs.dialogueTree.getVariable = function (\n key: string\n ): string | float | boolean {\n if (this.runner.variables && key in this.runner.variables.data) {\n return this.runner.variables.get(key);\n }\n return '';\n };\n\n /**\n * Get the value of a variable stored in the dialogue state.\n * @param key The variable name\n */\n gdjs.dialogueTree.getVariableAsNumber = function (key: string): float {\n if (this.runner.variables && key in this.runner.variables.data) {\n const value = this.runner.variables.get(key);\n if (typeof value !== 'number') {\n return parseFloat(value) || 0;\n }\n\n return isFinite(value) ? value : 0;\n }\n return 0;\n };\n\n /**\n * Get the value of a variable stored in the dialogue state.\n * @param key The variable name\n */\n gdjs.dialogueTree.getVariableAsString = function (key: string): string {\n if (this.runner.variables && key in this.runner.variables.data) {\n return '' + this.runner.variables.get(key);\n }\n return '';\n };\n\n /**\n * Check if a specific variable created by the Dialogue parses exists and is equal to a specific value.\n * @param key The name of the variable you want to check the value of\n * @param value The value you want to check against\n */\n gdjs.dialogueTree.compareVariable = function (\n key: string,\n value: string | boolean | number\n ) {\n if (this.runner.variables && key in this.runner.variables.data) {\n return this.runner.variables.get(key) === value;\n }\n return false;\n };\n\n /**\n * Set a specific variable created by the Dialogue parser to a specific value.\n * @param key The name of the variable you want to set the value of\n * @param value The value you want to set\n */\n gdjs.dialogueTree.setVariable = function (\n key: string,\n value: string | boolean | number\n ) {\n if (this.runner.variables) {\n this.runner.variables.set(key, value);\n }\n };\n\n /**\n * Store the current State of the Dialogue Parser in a specified variable.\n * Can be used to implement persistence in dialogue through your game's Load/Save function.\n * That way you can later load all the dialogue choices the player has made.\n * @param outputVariable The variable where to store the State\n */\n gdjs.dialogueTree.saveState = function (outputVariable: gdjs.Variable) {\n const dialogueState = {\n variables: gdjs.dialogueTree.runner.variables.data,\n visited: gdjs.dialogueTree.runner.visited,\n };\n outputVariable.fromJSObject(dialogueState);\n };\n\n /**\n * Load the current State of the Dialogue Parser from a specified variable.\n * Can be used to implement persistence in dialogue through your game's Load/Save function.\n * That way you can later load all the dialogue choices the player has made.\n * @param inputVariable The structured variable where to load the State from.\n */\n gdjs.dialogueTree.loadState = function (inputVariable: gdjs.Variable) {\n const loadedState = inputVariable.toJSObject();\n if (!loadedState) {\n logger.error('Load state variable is empty:', inputVariable);\n return;\n }\n try {\n gdjs.dialogueTree.runner.visited = loadedState.visited;\n gdjs.dialogueTree.runner.variables.data = {};\n Object.keys(loadedState.variables).forEach(function (key) {\n const value = loadedState.variables[key];\n gdjs.dialogueTree.runner.variables.set(key, value);\n });\n } catch (e) {\n logger.error('Failed to load state from variable:', inputVariable, e);\n }\n };\n\n /**\n * Clear the current State of the Dialogue Parser.\n */\n gdjs.dialogueTree.clearState = function () {\n gdjs.dialogueTree.runner.visited = {};\n gdjs.dialogueTree.runner.variables.data = {};\n };\n}\n"],
|
|
5
|
-
"mappings": "
|
|
4
|
+
"sourcesContent": ["namespace gdjs {\n export namespace dialogueTree {\n const logger = new gdjs.Logger('Dialogue tree');\n\n const runner = new bondage.Runner();\n let commandCalls: Array<any>;\n let clipTextEnd: integer = 0;\n let dialogueText = '';\n let pauseScrolling = false;\n let commandParameters: Array<string> = [];\n let selectedOption: integer = 0;\n let selectedOptionUpdated = false;\n let tagParameters: Array<string> = [];\n let dialogueData:\n | bondage.TextResult\n | bondage.CommandResult\n | bondage.OptionsResult\n | null = null;\n let dialogueIsRunning = false;\n let dialogueDataType: string | null = null;\n let dialogueBranchTitle = '';\n let lineNum: number | number[] = 0;\n let optionsCount = 0;\n let options: Array<string> = [];\n let dialogue: any;\n let dialogueBranchTags: Array<string> = [];\n let dialogueBranchBody = '';\n\n /**\n * Load the Dialogue Tree data of the game. Initialize The Dialogue Tree, so as it can be used in the game.\n * @param sceneVar The variable to load the Dialogue tree data from. The data is a JSON string, created by Yarn.\n * @param startDialogueNode The Dialogue Branch to start the Dialogue Tree from. If left empty, the data will only be loaded, but can later be initialized via another action\n */\n export function loadFromSceneVariable(\n sceneVar: gdjs.Variable,\n startDialogueNode: string\n ) {\n try {\n const yarnData = JSON.parse(sceneVar.getAsString());\n runner.load(yarnData);\n if (startDialogueNode && startDialogueNode.length > 0) {\n gdjs.dialogueTree.startFrom(startDialogueNode);\n }\n } catch (e) {\n logger.error('Error while loading from scene variable: ', e);\n }\n }\n\n /**\n * Load the Dialogue Tree data from a JSON resource.\n *\n * @param instanceContainer The scene where the dialogue is running.\n * @param jsonResourceName The JSON resource where to load the Dialogue Tree data from. The data is a JSON string usually created with [Yarn Dialogue Editor](https://github.com/InfiniteAmmoInc/Yarn).\n * @param startDialogueNode The Dialogue Branch to start the Dialogue Tree from. If left empty, the data will only be loaded, but can later be initialized via another action\n */\n export function loadFromJsonFile(\n instanceContainer: gdjs.RuntimeInstanceContainer,\n jsonResourceName: string,\n startDialogueNode: string\n ) {\n instanceContainer\n .getGame()\n .getJsonManager()\n .loadJson(jsonResourceName, function (error, content) {\n if (error) {\n logger.error(\n 'An error happened while loading JSON resource:',\n error\n );\n } else {\n if (!content) {\n return;\n }\n const yarnData = content as any[];\n try {\n runner.load(yarnData);\n } catch (error) {\n logger.error(\n 'An error happened while loading parsing the dialogue tree data:',\n error\n );\n }\n if (startDialogueNode && startDialogueNode.length > 0) {\n gdjs.dialogueTree.startFrom(startDialogueNode);\n }\n }\n });\n }\n\n /**\n * Stop the currently running dialogue\n */\n export function stopRunningDialogue() {\n dialogueIsRunning = false;\n dialogueData = null;\n dialogueText = '';\n clipTextEnd = 0;\n }\n\n /**\n * Check if the Dialogue Tree is currently parsing data.\n * For example, you can do things like disabling player movement while talking to a NPC.\n */\n export function isRunning() {\n if (\n dialogueIsRunning &&\n !dialogueData &&\n dialogueText &&\n clipTextEnd >= dialogueText.length\n ) {\n dialogueIsRunning = false;\n }\n return dialogueIsRunning;\n }\n\n /**\n * Scroll the clipped text. This can be combined with a timer and user input to control how fast the dialogue line text is scrolling.\n */\n export function scrollClippedText() {\n if (pauseScrolling || !dialogueIsRunning) {\n return;\n }\n\n // Autoscroll commands so the user doesn't have to press again.\n if (\n dialogueData instanceof bondage.CommandResult &&\n dialogueDataType === 'text' &&\n dialogueBranchTitle === dialogueData.data.title &&\n lineNum === dialogueData.lineNum &&\n gdjs.dialogueTree.hasClippedScrollingCompleted()\n ) {\n gdjs.dialogueTree.goToNextDialogueLine();\n return;\n }\n\n // Increment scrolling of clipped text\n if (\n dialogueText &&\n dialogueDataType === 'text' &&\n clipTextEnd < dialogueText.length\n ) {\n clipTextEnd += 1;\n }\n }\n\n /**\n * Scroll the clipped text to its end, so the entire text is printed. This can be useful in keeping the event sheet logic simpler, while supporting more variation.\n */\n export function completeClippedTextScrolling() {\n if (\n pauseScrolling ||\n !dialogueIsRunning ||\n !dialogueText ||\n dialogueDataType !== 'text'\n ) {\n return;\n }\n clipTextEnd = dialogueText.length;\n }\n\n /**\n * Check if text scrolling has completed.\n * Useful to prevent the user from skipping to next line before the current one has been printed fully.\n */\n export function hasClippedScrollingCompleted() {\n if (!dialogueIsRunning || dialogueDataType === '') {\n return false;\n }\n if (\n dialogueData &&\n dialogueText.length > 0 &&\n clipTextEnd >= dialogueText.length\n ) {\n if (gdjs.dialogueTree.getVariable('debug')) {\n logger.warn(\n 'Scroll completed:',\n clipTextEnd,\n '/',\n dialogueText.length\n );\n }\n return true;\n }\n return false;\n }\n\n /**\n * Get the current dialogue line with a scrolling effect (recommended).\n * Used with the scrollClippedText to achieve a classic scrolling text, as well as any <<wait>> effects to pause scrolling.\n */\n export function getClippedLineText() {\n return dialogueIsRunning && dialogueText.length\n ? dialogueText.substring(0, clipTextEnd + 1)\n : '';\n }\n\n /**\n * Get the current complete dialogue line without using any scrolling effects.\n * Note that using this instead getClippedLineText will skip any <<wait>> commands entirely.\n */\n export function getLineText() {\n return dialogueIsRunning && dialogueText.length ? dialogueText : '';\n }\n\n /**\n * Get the number of command parameters in a command with parameters that has been caught by a isCommandCalled condition\n */\n export function commandParametersCount() {\n if (commandParameters.length > 1) {\n return commandParameters.length - 1;\n }\n return 0;\n }\n\n /**\n * Get a command parameter in any command with parameters that has been caught by a isCommandCalled condition\n * @param paramIndex The index of the parameter to get.\n */\n export function getCommandParameter(paramIndex: float) {\n if (paramIndex === -1 && commandParameters.length > 0) {\n return commandParameters[0];\n }\n if (commandParameters.length >= paramIndex + 1) {\n const returnedParam = commandParameters[paramIndex + 1];\n return returnedParam ? returnedParam : '';\n }\n return '';\n }\n\n /**\n * Catch <<commands>> and <<commands with parameters>> from the current Dialogue Line.\n * You can trigger custom logic that relate to the story you are telling during the dialogue.\n *\n * @param command The command you want to check for being called. Write it without the `<<>>`.\n */\n export function isCommandCalled(command: string) {\n if (!dialogueIsRunning) {\n return false;\n }\n if (pauseScrolling || !commandCalls) {\n return false;\n }\n return commandCalls.some(function (call, index) {\n if (clipTextEnd !== 0 && clipTextEnd < call.time) {\n return false;\n }\n if (\n call.cmd === 'wait' &&\n (clipTextEnd === 0 || clipTextEnd !== dialogueText.length)\n ) {\n pauseScrolling = true;\n setTimeout(function () {\n pauseScrolling = false;\n commandCalls.splice(index, 1);\n if (gdjs.dialogueTree.getVariable('debug')) {\n logger.info('CMD:', call);\n }\n }, parseInt(call.params[1], 10));\n }\n if (call.cmd === command) {\n commandParameters = call.params;\n commandCalls.splice(index, 1);\n if (gdjs.dialogueTree.getVariable('debug')) {\n logger.info('CMD:', call);\n }\n return true;\n }\n return false;\n });\n }\n\n /**\n * Internal method to allow for capping option selection.\n */\n function _normalizedOptionIndex(optionIndex: integer) {\n if (optionIndex >= options.length) {\n optionIndex = options.length - 1;\n }\n if (optionIndex < 0) {\n optionIndex = 0;\n }\n return optionIndex;\n }\n\n /**\n * Internal method to allow for cycling option selection.\n */\n function _cycledOptionIndex(optionIndex: integer) {\n if (optionIndex >= options.length) {\n optionIndex = 0;\n }\n if (optionIndex < 0) {\n optionIndex = options.length - 1;\n }\n return optionIndex;\n }\n\n /**\n * Get the text of an option the player can select.\n * Used with getLineOptionsCount to render options for the player when a line of the Options type is parsed\n * @param optionIndex The index of the option you want to get\n */\n export function getLineOption(optionIndex: float) {\n if (!dialogueIsRunning || !options.length) {\n return [];\n }\n optionIndex = _normalizedOptionIndex(optionIndex);\n return options[optionIndex];\n }\n\n /**\n * Get the text of the options the player can select, along with the selection cursor.\n * @param optionSelectionCursor The string used to draw the currently selected option's cursor\n * @param addNewLine when true each option is rendered on a new line.\n */\n export function getLineOptionsText(\n optionSelectionCursor: string,\n addNewLine: boolean\n ) {\n if (!dialogueIsRunning || !options.length) {\n return '';\n }\n let textResult = '';\n options.forEach(function (optionText, index) {\n if (index === selectedOption) {\n textResult += optionSelectionCursor;\n } else {\n textResult += optionSelectionCursor.replace(/.*/g, ' ');\n }\n textResult += optionText;\n if (addNewLine) {\n textResult += '\\n';\n }\n });\n return textResult;\n }\n export function getLineOptionsTextHorizontal(optionSelectionCursor) {\n return gdjs.dialogueTree.getLineOptionsText(optionSelectionCursor, false);\n }\n export function getLineOptionsTextVertical(optionSelectionCursor) {\n return gdjs.dialogueTree.getLineOptionsText(optionSelectionCursor, true);\n }\n\n /**\n * Get the number of options that are presented to the player, during the parsing of an Options type line.\n * @returns The number of options\n */\n export function getLineOptionsCount(): number {\n if (dialogueIsRunning && options.length) {\n return optionsCount;\n }\n return 0;\n }\n\n /**\n * Confirm the currently selected option, during the parsing of an Options type line.\n *\n * This will advance the dialogue tree to the dialogue branch was selected by the player.\n */\n export function confirmSelectOption() {\n if (!dialogueIsRunning) {\n return;\n }\n if (\n dialogueData instanceof bondage.OptionsResult &&\n !selectedOptionUpdated &&\n selectedOption !== -1\n ) {\n commandCalls = [];\n try {\n dialogueData.select(selectedOption);\n try {\n dialogueData = dialogue.next().value;\n } catch (error) {\n logger.error(\n 'Error while confirming in the dialogue tree. Verify if there is a syntax error? Full error is: ',\n error\n );\n return;\n }\n gdjs.dialogueTree.goToNextDialogueLine();\n } catch (error) {\n logger.error(\n `An error happened when trying to access the dialogue branch!`,\n error\n );\n }\n }\n }\n\n /**\n * Select next option during Options type line parsing. Hook this to your game input.\n */\n export function selectNextOption() {\n if (!dialogueIsRunning) {\n return;\n }\n if (_isLineTypeOptions()) {\n selectedOption += 1;\n selectedOption = _cycledOptionIndex(selectedOption);\n selectedOptionUpdated = true;\n }\n }\n\n /**\n * Select previous option during Options type line parsing. Hook this to your game input.\n */\n export function selectPreviousOption() {\n if (!dialogueIsRunning) {\n return;\n }\n if (_isLineTypeOptions()) {\n selectedOption -= 1;\n selectedOption = _cycledOptionIndex(selectedOption);\n selectedOptionUpdated = true;\n }\n }\n\n /**\n * Select option by index during Options type line parsing.\n * @param optionIndex The index of the option to select\n */\n export function selectOption(optionIndex: float) {\n if (!dialogueIsRunning) {\n return;\n }\n if (_isLineTypeOptions()) {\n selectedOption = _normalizedOptionIndex(optionIndex);\n selectedOptionUpdated = true;\n }\n }\n\n /**\n * Get the currently selected option\n * @returns The index of the currently selected option\n */\n export function getSelectedOption(): number {\n if (!dialogueIsRunning) {\n return 0;\n }\n if (_isLineTypeOptions()) {\n return selectedOption;\n }\n return 0;\n }\n\n /**\n * Check when the player has changed option selection since the last call to this function.\n *\n * Can be used to re-render your displayed dialogue options when needed.\n *\n * @returns true if the selected option was updated since the last call to this function\n */\n export function hasSelectedOptionChanged(): boolean {\n if (selectedOptionUpdated) {\n selectedOptionUpdated = false;\n if (selectedOption === -1) {\n selectedOption = 0;\n }\n return true;\n }\n return false;\n }\n\n /**\n * Check the type of the Dialogue Line that is being displayed to the player at the moment.\n *\n * There are three types:\n * - text - regular dialogue text is being parsed at the moment\n * - options - the player has reached a branching choice moment where they must select one of multiple options\n * - command - a <<command>> was called in the background, that can be used to trigger game events, but will not be displayed in the dialogue box.\n *\n * @param type The type you want to check for ( one of the three above )\n */\n export function isDialogueLineType(type: string) {\n if (!dialogueIsRunning) {\n return false;\n }\n if (commandCalls && type === 'command') {\n if (\n commandCalls.some(function (call) {\n return clipTextEnd > call.time && call.cmd === 'wait';\n })\n ) {\n return !pauseScrolling;\n }\n if (commandCalls.length > 0 && commandParameters.length > 0) {\n return true;\n }\n }\n return dialogueDataType === type;\n }\n\n /**\n * Check if a branch exists. It is also used internally whenever you use the start from action.\n * @param branchName The Dialogue Branch name you want to check.\n */\n export function hasDialogueBranch(branchName: string) {\n return (\n runner &&\n runner.yarnNodes &&\n Object.keys(runner.yarnNodes).some(function (node) {\n return node === branchName;\n })\n );\n }\n\n /**\n * Start parsing dialogue from a specified Dialogue tree branch.\n * Can be used if you want to store multiple dialogues inside a single Dialogue tree data set.\n * @param startDialogueNode The Dialogue Branch name you want to start parsing from.\n */\n export function startFrom(startDialogueNode: string) {\n if (!gdjs.dialogueTree.hasDialogueBranch(startDialogueNode)) {\n return;\n }\n optionsCount = 0;\n options = [];\n tagParameters = [];\n try {\n dialogue = runner.run(startDialogueNode);\n } catch (error) {\n logger.error(\n 'Error while setting up the dialogue tree. Verify if there is a syntax error? Full error is: ',\n error\n );\n return;\n }\n dialogueText = '';\n clipTextEnd = 0;\n commandCalls = [];\n commandParameters = [];\n pauseScrolling = false;\n try {\n dialogueData = dialogue.next().value;\n } catch (error) {\n logger.error(\n 'Error while starting the dialogue tree. Verify if there is a syntax error? Full error is: ',\n error\n );\n return;\n }\n if (!dialogueData) {\n return;\n }\n if (\n dialogueData instanceof bondage.TextResult ||\n dialogueData instanceof bondage.CommandResult\n ) {\n dialogueBranchTags = dialogueData.data.tags;\n dialogueBranchTitle = dialogueData.data.title;\n dialogueBranchBody = dialogueData.data.body;\n }\n lineNum = dialogueData.lineNum;\n if (_isLineTypeText()) {\n dialogueDataType = 'text';\n } else {\n if (_isLineTypeOptions()) {\n dialogueDataType = 'options';\n } else {\n dialogueDataType = 'command';\n }\n }\n dialogueIsRunning = true;\n gdjs.dialogueTree.goToNextDialogueLine();\n }\n\n /**\n * Internal methods to check the type of a Dialogue Line\n */\n function _isLineTypeText() {\n return dialogueData instanceof bondage.TextResult;\n }\n function _isLineTypeOptions() {\n return dialogueData instanceof bondage.OptionsResult;\n }\n function _isLineTypeCommand() {\n return dialogueData instanceof bondage.CommandResult;\n }\n\n /**\n * This is the main lifecycle function.It runs once only when the user is advancing the dialogue to the next line.\n * Progress Dialogue to the next line. Hook it to your game input.\n * Note that this action can be influenced by any <<wait>> commands, but they work only if you have at least one isCommandCalled condition.\n */\n export function goToNextDialogueLine() {\n if (pauseScrolling || !dialogueIsRunning) {\n return;\n }\n optionsCount = 0;\n selectedOption = -1;\n selectedOptionUpdated = false;\n if (gdjs.dialogueTree.getVariable('debug')) {\n logger.info('Parsing:', dialogueData);\n }\n if (!dialogueData) {\n gdjs.dialogueTree.stopRunningDialogue();\n } else {\n if (dialogueData instanceof bondage.TextResult) {\n if (\n lineNum === dialogueData.lineNum &&\n dialogueBranchTitle === dialogueData.data.title\n ) {\n clipTextEnd = dialogueText.length - 1;\n dialogueText +=\n (dialogueText === '' ? '' : ' ') + dialogueData.text;\n } else {\n clipTextEnd = 0;\n dialogueText = dialogueData.text;\n }\n dialogueBranchTags = dialogueData.data.tags;\n dialogueBranchTitle = dialogueData.data.title;\n dialogueBranchBody = dialogueData.data.body;\n lineNum = dialogueData.lineNum;\n dialogueDataType = 'text';\n try {\n dialogueData = dialogue.next().value;\n } catch (error) {\n logger.error(\n 'Error while progressing the dialogue tree. Verify if there is a syntax error? Full error is: ',\n error\n );\n return;\n }\n } else {\n if (dialogueData instanceof bondage.OptionsResult) {\n commandCalls = [];\n dialogueDataType = 'options';\n dialogueText = '';\n clipTextEnd = 0;\n optionsCount = dialogueData.options.length;\n options = dialogueData.options;\n selectedOptionUpdated = true;\n } else {\n if (_isLineTypeCommand()) {\n dialogueDataType = 'command';\n const command = dialogueData.text.split(' ');\n\n // If last command was to wait, increase time by one\n const offsetTime =\n commandCalls.length &&\n commandCalls[commandCalls.length - 1].cmd === 'wait'\n ? 1\n : 0;\n commandCalls.push({\n cmd: command[0],\n params: command,\n time: dialogueText.length + offsetTime,\n });\n try {\n dialogueData = dialogue.next().value;\n } catch (error) {\n logger.error(\n 'Error while progressing the dialogue tree. Verify if there is a syntax error? Full error is: ',\n error\n );\n return;\n }\n gdjs.dialogueTree.goToNextDialogueLine();\n } else {\n dialogueDataType = 'unknown';\n }\n }\n }\n }\n }\n\n /**\n * Get the current Dialogue Tree branch title.\n * @returns The current branch title.\n */\n export function getBranchTitle(): string {\n if (dialogueIsRunning) {\n return dialogueBranchTitle;\n }\n return '';\n }\n\n /**\n * Check if the currently parsed Dialogue branch title is a query.\n * @param title The Dialogue Branch name you want to check for.\n */\n export function branchTitleIs(title: string) {\n if (dialogueIsRunning) {\n return dialogueBranchTitle === title;\n }\n return false;\n }\n\n /**\n * Get all the branch tags from the current Dialogue branch as a string. Useful for debugging.\n * @returns The current branch tags, separated by a comma.\n */\n export function getBranchTags(): string {\n if (dialogueIsRunning) {\n return dialogueBranchTags.join(',');\n }\n return '';\n }\n\n /**\n * Get one of the current Dialogue branch tags via index.\n * @param index The index of the Dialogue Branch tag you want to get.\n * @returns The branch tag at the specified index, or an empty string if not found.\n */\n export function getBranchTag(index: float): string {\n if (dialogueIsRunning && dialogueBranchTags.length) {\n if (index > dialogueBranchTags.length - 1) {\n index = dialogueBranchTags.length - 1;\n }\n return dialogueBranchTags[index];\n }\n return '';\n }\n\n /**\n * Check if the current Dialogue branch contains a specific tag.\n * @param query The name of the Dialogue Branch tag you want to check.\n */\n export function branchContainsTag(query: string) {\n tagParameters = [];\n if (dialogueIsRunning && dialogueBranchTags.length) {\n return dialogueBranchTags.some(function (tag) {\n const splitTag = tag.match(/([^\\(]+)\\(([^\\)]+)\\)/i);\n tagParameters = splitTag ? splitTag[2].split(',') : [];\n return splitTag ? splitTag[1] === query : tag === query;\n });\n }\n return false;\n }\n\n /**\n * Get any tag(parameter,anotherParameter) from a tag captured by the branchContainsTag Condition\n * @param paramIndex The index of the tag parameter you want to get.\n * Leaving this empty will result in retrieving the first parameter.\n */\n export function getTagParameter(paramIndex: float) {\n if (dialogueIsRunning && tagParameters.length >= paramIndex) {\n const returnedParam = tagParameters[paramIndex];\n return returnedParam ? returnedParam : '';\n }\n return '';\n }\n\n /**\n * Get a list of all the titles of visited by the player Branches. Useful for debugging.\n */\n export function getVisitedBranchTitles() {\n if (dialogueIsRunning) {\n return Object.keys(runner.visited).join(',');\n }\n return '';\n }\n\n /**\n * Check if a player has visited a Dialogue Branch in the past.\n * @param title The title of the branch to check for.\n * Leaving this empty will check if the current branch title has been visited in the past.\n */\n export function branchTitleHasBeenVisited(title: string) {\n if (!title) {\n title = dialogueBranchTitle;\n }\n return (\n Object.keys(runner.visited).includes(title) && runner.visited[title]\n );\n }\n\n /**\n * Get the entire unparsed text of the current Dialogue Branch\n */\n export function getBranchText() {\n if (dialogueIsRunning) {\n return dialogueBranchBody;\n }\n return '';\n }\n\n /**\n * Get the value of a variable stored in the dialogue state.\n * @param key The variable name\n */\n export function getVariable(key: string): string | float | boolean {\n if (runner.variables && key in runner.variables.data) {\n return runner.variables.get(key);\n }\n return '';\n }\n\n /**\n * Get the value of a variable stored in the dialogue state.\n * @param key The variable name\n */\n export function getVariableAsNumber(key: string): float {\n if (runner.variables && key in runner.variables.data) {\n const value = runner.variables.get(key);\n if (typeof value !== 'number') {\n return parseFloat(value) || 0;\n }\n\n return isFinite(value) ? value : 0;\n }\n return 0;\n }\n\n /**\n * Get the value of a variable stored in the dialogue state.\n * @param key The variable name\n */\n export function getVariableAsString(key: string): string {\n if (runner.variables && key in runner.variables.data) {\n return '' + runner.variables.get(key);\n }\n return '';\n }\n\n /**\n * Check if a specific variable created by the Dialogue parses exists and is equal to a specific value.\n * @param key The name of the variable you want to check the value of\n * @param value The value you want to check against\n */\n export function compareVariable(\n key: string,\n value: string | boolean | number\n ) {\n if (runner.variables && key in runner.variables.data) {\n return runner.variables.get(key) === value;\n }\n return false;\n }\n\n /**\n * Set a specific variable created by the Dialogue parser to a specific value.\n * @param key The name of the variable you want to set the value of\n * @param value The value you want to set\n */\n export function setVariable(key: string, value: string | boolean | number) {\n if (runner.variables) {\n runner.variables.set(key, value);\n }\n }\n\n /**\n * Store the current State of the Dialogue Parser in a specified variable.\n * Can be used to implement persistence in dialogue through your game's Load/Save function.\n * That way you can later load all the dialogue choices the player has made.\n * @param outputVariable The variable where to store the State\n */\n export function saveState(outputVariable: gdjs.Variable) {\n const dialogueState = {\n variables: runner.variables.data,\n visited: runner.visited,\n };\n outputVariable.fromJSObject(dialogueState);\n }\n\n /**\n * Load the current State of the Dialogue Parser from a specified variable.\n * Can be used to implement persistence in dialogue through your game's Load/Save function.\n * That way you can later load all the dialogue choices the player has made.\n * @param inputVariable The structured variable where to load the State from.\n */\n export function loadState(inputVariable: gdjs.Variable) {\n const loadedState = inputVariable.toJSObject();\n if (!loadedState) {\n logger.error('Load state variable is empty:', inputVariable);\n return;\n }\n try {\n runner.visited = loadedState.visited;\n runner.variables.data = {};\n Object.keys(loadedState.variables).forEach(function (key) {\n const value = loadedState.variables[key];\n runner.variables.set(key, value);\n });\n } catch (e) {\n logger.error('Failed to load state from variable:', inputVariable, e);\n }\n }\n\n /**\n * Clear the current State of the Dialogue Parser.\n */\n export function clearState() {\n runner.visited = {};\n runner.variables.data = {};\n }\n }\n}\n"],
|
|
5
|
+
"mappings": "AAAA,GAAU,MAAV,UAAU,EAAV,CACS,GAAU,GAAV,UAAU,GAAV,CACL,KAAM,GAAS,GAAI,GAAK,OAAO,iBAEzB,EAAS,GAAI,SAAQ,OAC3B,GAAI,GACA,EAAuB,EACvB,EAAe,GACf,EAAiB,GACjB,EAAmC,GACnC,EAA0B,EAC1B,EAAwB,GACxB,EAA+B,GAC/B,EAIO,KACP,EAAoB,GACpB,EAAkC,KAClC,EAAsB,GACtB,EAA6B,EAC7B,EAAe,EACf,EAAyB,GACzB,EACA,EAAoC,GACpC,EAAqB,GAOlB,WACL,EACA,EACA,CACA,GAAI,CACF,KAAM,GAAW,KAAK,MAAM,EAAS,eACrC,EAAO,KAAK,GACR,GAAqB,EAAkB,OAAS,GAClD,EAAK,aAAa,UAAU,SAEvB,EAAP,CACA,EAAO,MAAM,4CAA6C,IAXvD,GAAS,wBAsBT,WACL,EACA,EACA,EACA,CACA,EACG,UACA,iBACA,SAAS,EAAkB,SAAU,EAAO,EAAS,CACpD,GAAI,EACF,EAAO,MACL,iDACA,OAEG,CACL,GAAI,CAAC,EACH,OAEF,KAAM,GAAW,EACjB,GAAI,CACF,EAAO,KAAK,SACL,EAAP,CACA,EAAO,MACL,kEACA,GAGJ,AAAI,GAAqB,EAAkB,OAAS,GAClD,EAAK,aAAa,UAAU,MA5B/B,GAAS,mBAqCT,YAA+B,CACpC,EAAoB,GACpB,EAAe,KACf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,CACpD,KAAM,GAAQ,EAAO,UAAU,IAAI,GACnC,MAAI,OAAO,IAAU,SACZ,WAAW,IAAU,EAGvB,SAAS,GAAS,EAAQ,EAEnC,MAAO,GATF,GAAS,uBAgBT,YAA6B,EAAqB,CACvD,MAAI,GAAO,WAAa,IAAO,GAAO,UAAU,KACvC,GAAK,EAAO,UAAU,IAAI,GAE5B,GAJF,GAAS,uBAYT,YACL,EACA,EACA,CACA,MAAI,GAAO,WAAa,IAAO,GAAO,UAAU,KACvC,EAAO,UAAU,IAAI,KAAS,EAEhC,GAPF,GAAS,mBAeT,YAAqB,EAAa,EAAkC,CACzE,AAAI,EAAO,WACT,EAAO,UAAU,IAAI,EAAK,GAFvB,GAAS,eAYT,YAAmB,EAA+B,CACvD,KAAM,GAAgB,CACpB,UAAW,EAAO,UAAU,KAC5B,QAAS,EAAO,SAElB,EAAe,aAAa,GALvB,GAAS,aAcT,YAAmB,EAA8B,CACtD,KAAM,GAAc,EAAc,aAClC,GAAI,CAAC,EAAa,CAChB,EAAO,MAAM,gCAAiC,GAC9C,OAEF,GAAI,CACF,EAAO,QAAU,EAAY,QAC7B,EAAO,UAAU,KAAO,GACxB,OAAO,KAAK,EAAY,WAAW,QAAQ,SAAU,EAAK,CACxD,KAAM,GAAQ,EAAY,UAAU,GACpC,EAAO,UAAU,IAAI,EAAK,WAErB,EAAP,CACA,EAAO,MAAM,sCAAuC,EAAe,IAdhE,GAAS,aAqBT,aAAsB,CAC3B,EAAO,QAAU,GACjB,EAAO,UAAU,KAAO,GAFnB,GAAS,gBAl3BD,yCADT",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
|
@@ -340,7 +340,8 @@ module.exports = {
|
|
|
340
340
|
_(
|
|
341
341
|
'The friction applied when touching other objects. The higher the value, the more friction.'
|
|
342
342
|
)
|
|
343
|
-
)
|
|
343
|
+
)
|
|
344
|
+
.setGroup(_('Movement'));
|
|
344
345
|
behaviorProperties
|
|
345
346
|
.getOrCreate('restitution')
|
|
346
347
|
.setValue(
|
|
@@ -352,7 +353,8 @@ module.exports = {
|
|
|
352
353
|
_(
|
|
353
354
|
'The "bounciness" of the object. The higher the value, the more other objects will bounce against it.'
|
|
354
355
|
)
|
|
355
|
-
)
|
|
356
|
+
)
|
|
357
|
+
.setGroup(_('Movement'));
|
|
356
358
|
behaviorProperties
|
|
357
359
|
.getOrCreate('linearDamping')
|
|
358
360
|
.setValue(
|
|
@@ -695,7 +697,7 @@ module.exports = {
|
|
|
695
697
|
.addCondition(
|
|
696
698
|
'IsDynamic',
|
|
697
699
|
_('Is dynamic'),
|
|
698
|
-
_('
|
|
700
|
+
_('Check if an object is dynamic.'),
|
|
699
701
|
_('_PARAM0_ is dynamic'),
|
|
700
702
|
_('Dynamics'),
|
|
701
703
|
'res/physics32.png',
|
|
@@ -727,7 +729,7 @@ module.exports = {
|
|
|
727
729
|
.addCondition(
|
|
728
730
|
'IsStatic',
|
|
729
731
|
_('Is static'),
|
|
730
|
-
_('
|
|
732
|
+
_('Check if an object is static.'),
|
|
731
733
|
_('_PARAM0_ is static'),
|
|
732
734
|
_('Dynamics'),
|
|
733
735
|
'res/physics32.png',
|
|
@@ -759,7 +761,7 @@ module.exports = {
|
|
|
759
761
|
.addCondition(
|
|
760
762
|
'IsKinematic',
|
|
761
763
|
_('Is kinematic'),
|
|
762
|
-
_('
|
|
764
|
+
_('Check if an object is kinematic.'),
|
|
763
765
|
_('_PARAM0_ is kinematic'),
|
|
764
766
|
_('Dynamics'),
|
|
765
767
|
'res/physics32.png',
|
|
@@ -790,9 +792,9 @@ module.exports = {
|
|
|
790
792
|
aut
|
|
791
793
|
.addCondition(
|
|
792
794
|
'IsBullet',
|
|
793
|
-
_('Is
|
|
794
|
-
_('
|
|
795
|
-
_('_PARAM0_ is bullet'),
|
|
795
|
+
_('Is treated as a bullet'),
|
|
796
|
+
_('Check if the object is being treated as a bullet.'),
|
|
797
|
+
_('_PARAM0_ is treated as a bullet'),
|
|
796
798
|
_('Dynamics'),
|
|
797
799
|
'res/physics32.png',
|
|
798
800
|
'res/physics32.png'
|
|
@@ -825,7 +827,7 @@ module.exports = {
|
|
|
825
827
|
.addCondition(
|
|
826
828
|
'HasFixedRotation',
|
|
827
829
|
_('Has fixed rotation'),
|
|
828
|
-
_('
|
|
830
|
+
_('Check if an object has fixed rotation.'),
|
|
829
831
|
_('_PARAM0_ has fixed rotation'),
|
|
830
832
|
_('Dynamics'),
|
|
831
833
|
'res/physics32.png',
|
|
@@ -859,7 +861,7 @@ module.exports = {
|
|
|
859
861
|
.addCondition(
|
|
860
862
|
'IsSleepingAllowed',
|
|
861
863
|
_('Is sleeping allowed'),
|
|
862
|
-
_('
|
|
864
|
+
_('Check if an object can sleep.'),
|
|
863
865
|
_('_PARAM0_ can sleep'),
|
|
864
866
|
_('Dynamics'),
|
|
865
867
|
'res/physics32.png',
|
|
@@ -898,7 +900,7 @@ module.exports = {
|
|
|
898
900
|
.addCondition(
|
|
899
901
|
'IsSleeping',
|
|
900
902
|
_('Is sleeping'),
|
|
901
|
-
_('
|
|
903
|
+
_('Check if an object is sleeping.'),
|
|
902
904
|
_('_PARAM0_ is sleeping'),
|
|
903
905
|
_('Dynamics'),
|
|
904
906
|
'res/physics32.png',
|
|
@@ -1267,7 +1269,7 @@ module.exports = {
|
|
|
1267
1269
|
.addCondition(
|
|
1268
1270
|
'LayerEnabled',
|
|
1269
1271
|
_('Layer enabled'),
|
|
1270
|
-
_('
|
|
1272
|
+
_('Check if an object has a specific layer enabled.'),
|
|
1271
1273
|
_('_PARAM0_ has layer _PARAM2_ enabled'),
|
|
1272
1274
|
_('Filtering'),
|
|
1273
1275
|
'res/physics32.png',
|
|
@@ -1303,7 +1305,7 @@ module.exports = {
|
|
|
1303
1305
|
.addCondition(
|
|
1304
1306
|
'MaskEnabled',
|
|
1305
1307
|
_('Mask enabled'),
|
|
1306
|
-
_('
|
|
1308
|
+
_('Check if an object has a specific mask enabled.'),
|
|
1307
1309
|
_('_PARAM0_ has mask _PARAM2_ enabled'),
|
|
1308
1310
|
_('Filtering'),
|
|
1309
1311
|
'res/physics32.png',
|
|
@@ -1897,7 +1899,7 @@ module.exports = {
|
|
|
1897
1899
|
.addCondition(
|
|
1898
1900
|
'JointFirstObject',
|
|
1899
1901
|
_('Joint first object'),
|
|
1900
|
-
_('
|
|
1902
|
+
_('Check if an object is the first object on a joint.'),
|
|
1901
1903
|
_('_PARAM0_ is the first object for joint _PARAM2_'),
|
|
1902
1904
|
_('Joints'),
|
|
1903
1905
|
'res/physics32.png',
|
|
@@ -1913,7 +1915,7 @@ module.exports = {
|
|
|
1913
1915
|
.addCondition(
|
|
1914
1916
|
'JointSecondObject',
|
|
1915
1917
|
_('Joint second object'),
|
|
1916
|
-
_('
|
|
1918
|
+
_('Check if an object is the second object on a joint.'),
|
|
1917
1919
|
_('_PARAM0_ is the second object for joint _PARAM2_'),
|
|
1918
1920
|
_('Joints'),
|
|
1919
1921
|
'res/physics32.png',
|
|
@@ -2382,7 +2384,7 @@ module.exports = {
|
|
|
2382
2384
|
.addCondition(
|
|
2383
2385
|
'RevoluteJointLimitsEnabled',
|
|
2384
2386
|
_('Revolute joint limits enabled'),
|
|
2385
|
-
_('
|
|
2387
|
+
_('Check if a revolute joint limits are enabled.'),
|
|
2386
2388
|
_('Limits for revolute joint _PARAM2_ are enabled'),
|
|
2387
2389
|
_('Joints/Revolute'),
|
|
2388
2390
|
'JsPlatform/Extensions/revolute_joint24.png',
|
|
@@ -2461,7 +2463,7 @@ module.exports = {
|
|
|
2461
2463
|
.addCondition(
|
|
2462
2464
|
'RevoluteJointMotorEnabled',
|
|
2463
2465
|
_('Revolute joint motor enabled'),
|
|
2464
|
-
_('
|
|
2466
|
+
_('Check if a revolute joint motor is enabled.'),
|
|
2465
2467
|
_('Motor of revolute joint _PARAM2_ is enabled'),
|
|
2466
2468
|
_('Joints/Revolute'),
|
|
2467
2469
|
'JsPlatform/Extensions/revolute_joint24.png',
|
|
@@ -2700,7 +2702,7 @@ module.exports = {
|
|
|
2700
2702
|
.addCondition(
|
|
2701
2703
|
'PrismaticJointLimitsEnabled',
|
|
2702
2704
|
_('Prismatic joint limits enabled'),
|
|
2703
|
-
_('
|
|
2705
|
+
_('Check if a prismatic joint limits are enabled.'),
|
|
2704
2706
|
_('Limits for prismatic joint _PARAM2_ are enabled'),
|
|
2705
2707
|
_('Joints/Prismatic'),
|
|
2706
2708
|
'JsPlatform/Extensions/prismatic_joint24.png',
|
|
@@ -2779,7 +2781,7 @@ module.exports = {
|
|
|
2779
2781
|
.addCondition(
|
|
2780
2782
|
'PrismaticJointMotorEnabled',
|
|
2781
2783
|
_('Prismatic joint motor enabled'),
|
|
2782
|
-
_('
|
|
2784
|
+
_('Check if a prismatic joint motor is enabled.'),
|
|
2783
2785
|
_('Motor for prismatic joint _PARAM2_ is enabled'),
|
|
2784
2786
|
_('Joints/Prismatic'),
|
|
2785
2787
|
'JsPlatform/Extensions/prismatic_joint24.png',
|
|
@@ -3459,7 +3461,7 @@ module.exports = {
|
|
|
3459
3461
|
.addCondition(
|
|
3460
3462
|
'WheelJointMotorEnabled',
|
|
3461
3463
|
_('Wheel joint motor enabled'),
|
|
3462
|
-
_('
|
|
3464
|
+
_('Check if a wheel joint motor is enabled.'),
|
|
3463
3465
|
_('Motor for wheel joint _PARAM2_ is enabled'),
|
|
3464
3466
|
_('Joints/Wheel'),
|
|
3465
3467
|
'JsPlatform/Extensions/wheel_joint24.png',
|
|
@@ -4203,7 +4205,7 @@ module.exports = {
|
|
|
4203
4205
|
.getCodeExtraInformation()
|
|
4204
4206
|
.addIncludeFile('Extensions/Physics2Behavior/physics2tools.js')
|
|
4205
4207
|
.addIncludeFile('Extensions/Physics2Behavior/physics2runtimebehavior.js')
|
|
4206
|
-
.setFunctionName('gdjs.physics2.
|
|
4208
|
+
.setFunctionName('gdjs.physics2.areObjectsColliding');
|
|
4207
4209
|
|
|
4208
4210
|
extension
|
|
4209
4211
|
.addCondition(
|