Sorry for the poor title, i don't really know how to formulate my question.
The code below is a small part of a thing i'm doing to automate the generation of buttons paired with a click event for a game.
I'm tring to pass the modal.load()
function (which takes an associative array as argument) as a string to the "Look"
button. Well the function passing works (it is not in the code provided), BUT
As you can see, each properties of actions[0].script
returns undefined
, as if this
is not passed..
Tell me if you need anything else to understand the code.
actions = [{
name: "Look",
modal_color: 'salmon',
modal_img: '',
modal_title: 'This is a title',
modal_text: 'This is text',
script: `modal.load({'img': '${this.modal_img}', 'color': '${this.modal_color}', 'title': '${this.modal_color}', 'txt': '${this.modal_text}'});`,
},
{
name: "Walk",
script: "console.info('Other type of script')"
}
]
console.log(actions[0].script)
EDIT : template strings for clarity