I'm trying to learn about creating plugins right now. I came across something that confused me a bit.
I have a function that changes multiple selfswitches at once.
This works how I want it for now.
But if I try to set state as a string and not as a boolean, it only works with true (i.e. 'true' instead of true).
Why does it work on true but not on false ('false' instead of false)?
I have a function that changes multiple selfswitches at once.
PluginManager.registerCommand(pluginName, "SetSelfSwitch", args => {
var sswitch = JSON.parse(args.selfswitches).map(e => JSON.parse(e));
sswitch.forEach(e => {
if (e.state === 'true') {
e.state = true;
}
if (e.state === 'false') {
e.state = false;
}
SetSelfSwitch(e.mapid, e.eventid, e.letter, e.state);
});
});
var sswitch = JSON.parse(args.selfswitches).map(e => JSON.parse(e));
sswitch.forEach(e => {
if (e.state === 'true') {
e.state = true;
}
if (e.state === 'false') {
e.state = false;
}
SetSelfSwitch(e.mapid, e.eventid, e.letter, e.state);
});
});
This works how I want it for now.
But if I try to set state as a string and not as a boolean, it only works with true (i.e. 'true' instead of true).
Why does it work on true but not on false ('false' instead of false)?