Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Implement Dialogue tools Actor mechanics - closes 6461 #6469

Open
wants to merge 14 commits into
base: master
Choose a base branch
from
Open
296 changes: 296 additions & 0 deletions Extensions/DialogueTree/JsExtension.js
Original file line number Diff line number Diff line change
Expand Up @@ -264,6 +264,22 @@ module.exports = {
.getCodeExtraInformation()
.setFunctionName('gdjs.dialogueTree.setVariable');

extension
.addAction(
'DeleteVariable',
_('Delete dialogue state variable and its $nested.siblings'),
_(
'Delete dialogue state variable and its $nested.siblings. with $a, $c, $c.tom and $c.james, targetting "c" would result in only $a remaining'
),
_('Delete dialogue state variable and its $nested.siblings _PARAM0_'),
'',
'JsPlatform/Extensions/yarn32.png',
'JsPlatform/Extensions/yarn32.png'
)
.addParameter('string', _('State Variable Name'), '', false)
.getCodeExtraInformation()
.setFunctionName('gdjs.dialogueTree.deleteDialogueStateVariable');

extension
.addAction(
'SaveState',
Expand Down Expand Up @@ -311,6 +327,58 @@ module.exports = {
.getCodeExtraInformation()
.setFunctionName('gdjs.dialogueTree.clearState');

extension
.addAction(
'CreateNewActor',
_('Create a new actor'),
_(
'Create a new dialog actor, which can be used to trigger/set events said actor is active'
),
_(
'Create a new dialog actor with ID of _PARAM0_, name _PARAM1_ and color _PARAM2_'
),
'',
'JsPlatform/Extensions/yarn32.png',
'JsPlatform/Extensions/yarn32.png'
)
.addParameter('string', _('Actor ID'), '', false)
.addParameter('string', _('Actor name'), '', false)
.addParameter('color', _('Actor color'), '', false)
.getCodeExtraInformation()
.setFunctionName('gdjs.dialogueTree.createNewActor');

extension
.addAction(
'SetActorInfo',
_('Set actor variable'),
_(
'Set variable of dialog actor. Any is allowed to be set, apart of id'
),
_('Set dialog actor with ID of _PARAM0_ variable _PARAM1_ to _PARAM2_'),
'',
'JsPlatform/Extensions/yarn32.png',
'JsPlatform/Extensions/yarn32.png'
)
.addParameter('string', _('Actor ID'), '', false)
.addParameter('string', _('Actor variable'), '', false)
.addParameter('string', _('Variable string value'), '', false)
.getCodeExtraInformation()
.setFunctionName('gdjs.dialogueTree.setActorInfo');

extension
.addAction(
'DeleteActor',
_('Delete actor'),
_('Delete dialog actor'),
_('Delete a dialog actor with ID of _PARAM0_'),
'',
'JsPlatform/Extensions/yarn32.png',
'JsPlatform/Extensions/yarn32.png'
)
.addParameter('string', _('Actor ID'), '', false)
.getCodeExtraInformation()
.setFunctionName('gdjs.dialogueTree.deleteActor');

extension
.addStrExpression(
'LineText',
Expand Down Expand Up @@ -455,6 +523,20 @@ module.exports = {
.getCodeExtraInformation()
.setFunctionName('gdjs.dialogueTree.getCommandParameter');

extension
.addStrExpression(
'CommandParameterViaKey',
_('Get the parameter of a command call via a key'),
_(
'Get the parameter of a command call via a key. For example: asking <<command a=22 b=3>> for a parameter with key "a" will return 22'
),
'',
'JsPlatform/Extensions/yarn32.png'
)
.addParameter('string', _('parameter key'), '', true)
.getCodeExtraInformation()
.setFunctionName('gdjs.dialogueTree.getCommandParameterViaKey');

extension
.addExpression(
'CommandParametersCount',
Expand Down Expand Up @@ -482,6 +564,20 @@ module.exports = {
.getCodeExtraInformation()
.setFunctionName('gdjs.dialogueTree.getTagParameter');

extension
.addStrExpression(
'TagValueViaKey',
_('Get a Tag value found in the dialogue branch, using its key where the pattern is key:value'),
_(
'Get a Tag found in the dialogue branch, using a key. For example with tags: "bg:park", "time:lunch", asking for "bg" will return "park"'
),
'',
'JsPlatform/Extensions/yarn32.png'
)
.addParameter('string', _('tag key'), '', true)
.getCodeExtraInformation()
.setFunctionName('gdjs.dialogueTree.getTagValueViaKey');

extension
.addStrExpression(
'VisitedBranchTitles',
Expand Down Expand Up @@ -516,6 +612,102 @@ module.exports = {
.getCodeExtraInformation()
.setFunctionName('gdjs.dialogueTree.getVariable');

extension
.addExpression(
'VariableChildKeys',
_('Get variable number of child keys of a $nested.variable'),
_(
'Get variable number of child keys. For example with $root.actor.james.id and $root.actor.tom.id, $root.actor has 2 - tom and james'
),
'',
'JsPlatform/Extensions/yarn32.png'
)
.addParameter('string', _('Variable Name'), '', false)
.getCodeExtraInformation()
.setFunctionName('gdjs.dialogueTree.getKeysCount');

extension
.addStrExpression(
'GetChildKeyViaIndex',
_('Get a $nested.variable child key via index'),
_(
'Get a $nested.variable child key via index. For example with $c.tom.money, $c.tom.experience, targetting "c.tom" with index 1 will return "experience'
),
'',
'JsPlatform/Extensions/yarn32.png'
)
.addParameter('string', _('Nested Variable name'), '', false)
.addParameter('expression', _('index number'), '', false)
.getCodeExtraInformation()
.setFunctionName('gdjs.dialogueTree.getChildKeyViaIndex');

extension
.addStrExpression(
'ActiveActorId',
_('Get the Active Actor Id of the current dialogue line'),
_(
'Get the Active Actor Id of the current dialogue line. Empty string when no actor detected'
),
'',
'JsPlatform/Extensions/yarn32.png'
)
.getCodeExtraInformation()
.setFunctionName('gdjs.dialogueTree.getActiveLineActorId');

extension
.addExpression(
'ActiveActorParametersCount',
_(
'Get the number of parameters passed after an actor id on the active line'
),
_(
'Get the number of parameters passed after an actor id on the active line'
),
'',
'JsPlatform/Extensions/yarn32.png'
)
.getCodeExtraInformation()
.setFunctionName('gdjs.dialogueTree.getActiveLineActorParametersCount');

extension
.addStrExpression(
'ActiveLineActorParameter',
_('Get a parameter after an actor id on the active line via its index'),
_(
'Get a parameter after an actor id on the active line via its index. For example the line "tom happy: Its my birthday!" has one parameter "happy" which you can get via index 0'
),
'',
'JsPlatform/Extensions/yarn32.png'
)
.addParameter('expression', _('index number'), '', false)
.getCodeExtraInformation()
.setFunctionName('gdjs.dialogueTree.getActiveLineActorParameterViaIndex');

extension
.addExpression(
'ActorInfo',
_('Get Actor variable via actor ID'),
_('Get Actor variable via actor ID'),
'',
'JsPlatform/Extensions/yarn32.png'
)
.addParameter('string', _('Actor ID'), '', false)
.addParameter('string', _('Variable Name'), '', false)
.getCodeExtraInformation()
.setFunctionName('gdjs.dialogueTree.getActorInfo');

extension
.addExpression(
'ActiveActorInfo',
_('Get current active line Actor variable'),
_('Get current active line Actor variable'),
'',
'JsPlatform/Extensions/yarn32.png'
)
.addParameter('string', _('Variable Name'), '', false)
.getCodeExtraInformation()
.setFunctionName('gdjs.dialogueTree.getActiveActorInfo');

extension
.addCondition(
'IsCommandCalled',
Expand All @@ -532,6 +724,22 @@ module.exports = {
.getCodeExtraInformation()
.setFunctionName('gdjs.dialogueTree.isCommandCalled');

extension
.addCondition(
'IsCommandParameterPresent',
_('Command is called with a specific parameter'),
_(
'Check if a specific parameter is present in the Command that was called. If it is a <<command withParameter or anotherParameter=123>>, you can check if withParameter or anotherParameter exists.'
),
_('Command is called with parameter _PARAM0_'),
'',
'JsPlatform/Extensions/yarn32.png',
'JsPlatform/Extensions/yarn32.png'
)
.addParameter('string', _('Command Parameter'), '', false)
.getCodeExtraInformation()
.setFunctionName('gdjs.dialogueTree.commandHasParameter');

extension
.addCondition(
'IsDialogueLineType',
Expand Down Expand Up @@ -645,6 +853,18 @@ module.exports = {
.getCodeExtraInformation()
.setFunctionName('gdjs.dialogueTree.branchTitleHasBeenVisited');

extension
.addCondition(
'BranchNodeHasChanged',
_('Branch node has changed'),
_('Current branch node has changed'),
_('Current branch node has changed'),
'',
'JsPlatform/Extensions/yarn32.png',
'JsPlatform/Extensions/yarn32.png'
)
.setFunctionName('gdjs.dialogueTree.branchTitleHasChanged');

extension
.addCondition(
'CompareDialogueStateStringVariable',
Expand Down Expand Up @@ -711,6 +931,82 @@ module.exports = {
.getCodeExtraInformation()
.setFunctionName('gdjs.dialogueTree.hasClippedScrollingCompleted');

extension
.addCondition(
'HasActiveActorChanged',
_('Active Actor has changed'),
_(
'Check if the displayed dialogue text active actor has changed from the previous line.'
),
_('Active actor has changed'),
'',
'JsPlatform/Extensions/yarn32.png',
'JsPlatform/Extensions/yarn32.png'
)
.getCodeExtraInformation()
.setFunctionName('gdjs.dialogueTree.hasActiveActorChanged');

extension
.addCondition(
'LineHasActiveActor',
_('An Actor is currently present in the dialog line'),
_(
'An Actor is currently present in the dialog line'
),
_('Actor is present in current dialog line'),
'',
'JsPlatform/Extensions/yarn32.png',
'JsPlatform/Extensions/yarn32.png'
)
.getCodeExtraInformation()
.setFunctionName('gdjs.dialogueTree.lineHasActiveActor');


extension
.addCondition(
'ActiveActorLineHasParameter',
_('Active Actor line has parameter'),
_(
'Check if the displayed dialogue text active actor has a parameter. example "tom left: I am on the left!" the parameter "left" exists'
),
_('Active actor line has a parameter _PARAM0_'),
'',
'JsPlatform/Extensions/yarn32.png',
'JsPlatform/Extensions/yarn32.png'
)
.addParameter('string', _('Active Actor Line Parameter'), '', false)
.getCodeExtraInformation()
.setFunctionName('gdjs.dialogueTree.getActiveLineParameterExists');


extension
.addCondition(
'DoesActorExist',
_('Does actor with ID exist'),
_('Check if an actor with a specified id has been ecreated'),
_('Actor with ID _PARAM0_ exists'),
'',
'JsPlatform/Extensions/yarn32.png',
'JsPlatform/Extensions/yarn32.png'
)
.addParameter('string', _('Actor ID'), '', false)
.getCodeExtraInformation()
.setFunctionName('gdjs.dialogueTree.getActorExists');

extension
.addCondition(
'DoesVariableExist',
_('Does variable exist'),
_('Check if a dialogue state variable exists or has been set'),
_('Dialogue state variable _PARAM0_ exists'),
'',
'JsPlatform/Extensions/yarn32.png',
'JsPlatform/Extensions/yarn32.png'
)
.addParameter('string', _('Variable'), '', false)
.getCodeExtraInformation()
.setFunctionName('gdjs.dialogueTree.getVariableExists');

return extension;
},
runExtensionSanityTests: function (gd, extension) {
Expand Down
Loading