The first mod

by Adil

This mod is example of how to mod

7 years ago
0.14
7

b bug in on_tick handler in the associated wiki article

6 years ago

The associated wiki article, https://wiki.factorio.com/User:Adil/Modding_tutorial, has a serious bug in its on_tick handler. It says "if not (e.tick%60)==0 then return end", with the intent to return whenever the tick value is not divisible by 60. But in Lua, 'not' has higher precedence than '==', so the condition as a whole is always false, causing the rest of the on_tick handler to execute on every tick rather than once every 60 ticks.

I think it is important to fix the article because people are likely to copy that line of code into their own mods. I did.

The mod that one can download here, from mods.factorio.com, does not have the bug (its on_tick behavior is quite different). But I'm reporting the problem here since I don't have wiki edit permission and couldn't find any better place to report it.

New response