Page 1 of 1

Mod syntax error, can't figure out why

Posted: Thu Dec 13, 2018 8:53 pm
by jupiter878
I've been trying to make a mod that can modify the rocket animation speed so that it's easier to get neat ratios between it and other science setups. The game continues to throw messages that I have made a syntax error near the '-', but I don't know how to fix it, or why I've messed up.

data.raw.rocket-silo['rocket-silo'].light_blinking_speed = 1/(120)

data.raw.rocket-silo['rocket-silo'].door_opening_speed = 1/(151)

These two are the only lines in the data.lua file that I've created. I have attached both the data.lua and info.json files. I would appreciate some help with this.

Re: Mod syntax error, can't figure out why

Posted: Thu Dec 13, 2018 9:02 pm
by DaveMcW
You correctly quoted the second dash but forgot the first.

data.raw['rocket-silo']['rocket-silo']

Re: Mod syntax error, can't figure out why

Posted: Thu Dec 13, 2018 10:34 pm
by jupiter878
It works now, thanks.
Say, is there more than one type of syntax that works for this? I made another mod with the form

data.raw.boiler['heat-exchanger'].target_temperature = 515
data.raw.generator['steam-turbine'].maximum_temperature = 515

and this worked just fine, so I'd like to know what's allowed and not allowed here.

Re: Mod syntax error, can't figure out why

Posted: Thu Dec 13, 2018 11:57 pm
by Nexela
- is a special character in lua, to use it as a key it needs to be quoted

a.one is the same as a['one']

but

a.two-three has a special character in the key string so it has to be quoted otherwise it tries to subtract a.two and the (possibly nil) variable three. a['two-three']