why Booleans?

Place to get help with not working mods / modding interface.
Post Reply
User avatar
Dysoch
Filter Inserter
Filter Inserter
Posts: 445
Joined: Fri Oct 18, 2013 2:27 pm
Contact:

why Booleans?

Post 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)
Creator of:
- DyTech
- DyWorld
- DyWorld-Dynamics
- DyWorld-Dynamics 2
Active since Factorio 0.6

ficolas
Smart Inserter
Smart Inserter
Posts: 1068
Joined: Sun Feb 24, 2013 10:24 am
Contact:

Re: why Booleans?

Post 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

User avatar
rk84
Filter Inserter
Filter Inserter
Posts: 556
Joined: Wed Feb 13, 2013 9:15 am
Contact:

Re: why Booleans?

Post 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.
Test mode
Searching Flashlight
[WIP]Fluid handling expansion
[WIP]PvP gamescript
[WIP]Rocket Express
Autofill: The torch has been pass to Nexela

User avatar
AlexPhoenix
Fast Inserter
Fast Inserter
Posts: 149
Joined: Tue Feb 18, 2014 7:48 am
Contact:

Re: why Booleans?

Post 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.

User avatar
rk84
Filter Inserter
Filter Inserter
Posts: 556
Joined: Wed Feb 13, 2013 9:15 am
Contact:

Re: why Booleans?

Post 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).
Test mode
Searching Flashlight
[WIP]Fluid handling expansion
[WIP]PvP gamescript
[WIP]Rocket Express
Autofill: The torch has been pass to Nexela

Post Reply

Return to “Modding help”