Page 1 of 1

why Booleans?

Posted: Mon Feb 24, 2014 8:25 pm
by Dysoch
since the 0.9 update i cant get this to work:

inside the onplayermineditem

Code: Select all

if sds.mineitems[event.itemstack.name] then
sds points to scripts/dynamic-system inside my own mod.

i but keeps calling it as a boolean. why did it work in 0.8.x but not in 0.9.x?
i cant seem to fix it, and considering this is a large part of my mod, i hate to disable it :P (so my release depends on this :))

edit: pls dont tell me that this caused it:
Stricter rules for lua scripts (no require outside mod path, no dofile function)
1: its not outside mod
2: i guess it has something to do with dofile, any work around? (i would like all my functions in another file as i want to make it clean (eg. not everything inside control.lua)

Re: why Booleans?

Posted: Tue Feb 25, 2014 4:14 pm
by ficolas
Are you trying to check if that variable exists or not?
Then you cant use that. That checks for it to be true.
What you need to do is:

Code: Select all

if blabla~=nil then

Re: why Booleans?

Posted: Wed Feb 26, 2014 12:04 am
by rk84
Require returns boolean when there is no other return value. (True = file found. No file = error.)
my guess:
module() is deprecated in Lua 5.2. It still exist and is usable, but require() which is replaced with factorio's own require ignores it. So you have to type a line were you return your table.

Re: why Booleans?

Posted: Wed Feb 26, 2014 6:11 am
by AlexPhoenix
rk84 wrote:which is replaced with factorio's own require ignores it. So you have to type a line were you return your table.
dont see any diference between standart lua requare and factorio requare.

Re: why Booleans?

Posted: Wed Feb 26, 2014 1:29 pm
by rk84
After some actuall testing. I think, easy fix could be to give the desired name of table inside module.

Code: Select all

module("ds")
This is because the module() itself stores the table globally. The current require just does not return reference to it.
Also you don't need package.seeall, if you are not using global variables inside module ('game' for example).