Skip to content

Commit

Permalink
Added support for more than one variable pr text field
Browse files Browse the repository at this point in the history
  • Loading branch information
McHauge committed Aug 20, 2021
1 parent d6446c0 commit a82ecec
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 20 deletions.
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -191,5 +191,5 @@ and if there is more than one parameter use "&" as a separator between them like

**V1.2.22**

- Added support for variables in all text fields inside Actions (but currently only support one variable pr field)
- Added support for variables in all text fields inside Feedbacks (but currently only support one variable pr field)
- Added support for variables in all text fields inside Actions
- Added support for variables in all text fields inside Feedbacks
13 changes: 4 additions & 9 deletions src/actions.js
Original file line number Diff line number Diff line change
Expand Up @@ -1411,15 +1411,10 @@ exports.executeAction = function (action) {
for (const property in action.options) {
// if an option includes a variable, get it's value and replace the name for the actual value
if (String(action.options[property]).includes('$(')) {
x = String(action.options[property].split('$(')[1]).split(')')[0]
var str = x.split(':') // Split instance and variable
var selctInstances = str[0]
var selctVariable = str[1]
var temp

// Gets the value of the selected value
this.system.emit('variable_get', selctInstances, selctVariable, (definitions) => (temp = definitions))
opt[property] = String(action.options[property]).split('$(')[0] + temp + String(action.options[property]).split('$(')[1].split(')')[1]
// Replaces all variables with their selected values
this.parseVariables(action.options[property], (temp) => {
opt[property] = temp
})
} else {
opt[property] = action.options[property]
}
Expand Down
15 changes: 6 additions & 9 deletions src/feedback.js
Original file line number Diff line number Diff line change
Expand Up @@ -780,19 +780,16 @@ exports.executeFeedback = function (feedback, bank) {

// If an option includes a variable, get it's value and replace the name for the actual value
for (const property in feedback.options) {
// if an option includes a variable, get it's value and replace the name for the actual value
if (String(feedback.options[property]).includes('$(')) {
x = String(feedback.options[property].split('$(')[1]).split(')')[0]
var str = x.split(':') // Split instance and variable
var selctInstances = str[0]
var selctVariable = str[1]
var temp

// Gets the value of the selected value
this.system.emit('variable_get', selctInstances, selctVariable, (definitions) => (temp = definitions))
opt[property] = String(feedback.options[property]).split('$(')[0] + temp + String(feedback.options[property]).split('$(')[1].split(')')[1]
// Replaces all variables with their selected values
this.parseVariables(feedback.options[property], (temp) => {
opt[property] = temp
})
} else {
opt[property] = feedback.options[property]
}
opt[property] = encodeURIComponent(opt[property])
}

const getInput = (value) => {
Expand Down

0 comments on commit a82ecec

Please sign in to comment.