Page 1 of 1
Variable Reading as 'nil'
Posted: Sun Oct 11, 2020 8:38 pm
by AlexNerd
I'm trying to have a variable that decrements by one when a player clicks on certain objects. However, the triggers weren't working so I put a print statement in the Lua code, and apparently it's being read as 'nil' even though I put an initial value in the Dialogue System. Any help would be appreciated!
- Capture.JPG (33.14 KiB) Viewed 473 times
- Capture.JPG (120.74 KiB) Viewed 473 times
Re: Variable Reading as 'nil'
Posted: Sun Oct 11, 2020 10:05 pm
by Tony Li
Re: Variable Reading as 'nil'
Posted: Mon Oct 12, 2020 4:29 pm
by AlexNerd
Thank you! I'm still new to Lua, sorry.
Re: Variable Reading as 'nil'
Posted: Mon Oct 12, 2020 4:38 pm
by Tony Li
No problem! Your original code was perfectly valid Lua. It's just that the Dialogue System stores all of its dialogue database variables in a Lua array named Variable[]. So to access a dialogue database variable, you need to specify the Variable[] array.
Re: Variable Reading as 'nil'
Posted: Mon Oct 12, 2020 4:41 pm
by AlexNerd
That makes sense. I'll have to remember that for the future.