Script.on_event Error support

Place to ask discuss and request the modding support of Factorio. Don't request mods here.
Post Reply
User avatar
Ranakastrasz
Smart Inserter
Smart Inserter
Posts: 2130
Joined: Thu Jun 12, 2014 3:05 am
Contact:

Script.on_event Error support

Post by Ranakastrasz »

Code: Select all

script.on_event(defines.events.on_tick, ticker)
function ticker() -- run once per tickRate number of gameticks.
    if (game.tick % RanaMods.ModularArmor.config.tickRate) == 0 then
		tick()
        
	else
	end
    --[[if (game.tick %  60) == 0 then
        refresh_equipment()
    end]]--
end
This code doesn't call the function, but it doesn't display an error that the function doesn't exist either. You have to put the event registration after the function.
I request that if you do this, it should throw an error claiming the function can't be found, instead of silently doing nothing.

Wasted several days until I figured the problem out.

It works fine if it is registered in a function itself, presumably since the whole file was read before the function was called, but it doesn't work if its outside of a function. That is why I didn't realize the issue.
My Mods:
Modular Armor Revamp - V16
Large Chests - V16
Agent Orange - V16
Flare - V16
Easy Refineries - V16

Nexela
Smart Inserter
Smart Inserter
Posts: 1828
Joined: Wed May 25, 2016 11:09 am
Contact:

Re: Script.on_event Error support

Post by Nexela »

It is not silently doing anything though, you are passing nil to script.on_event effectively un-registering it

If you don't want want a nil value assign the variable before you use the variable


I recommend installing luacheck it would have given you a warning :)
Last edited by Nexela on Sun Sep 04, 2016 6:16 pm, edited 1 time in total.

User avatar
Ranakastrasz
Smart Inserter
Smart Inserter
Posts: 2130
Joined: Thu Jun 12, 2014 3:05 am
Contact:

Re: Script.on_event Error support

Post by Ranakastrasz »

Ah. That makes a bit more sense.
My Mods:
Modular Armor Revamp - V16
Large Chests - V16
Agent Orange - V16
Flare - V16
Easy Refineries - V16

Post Reply

Return to “Modding interface requests”