0.12.11 help: attempt to index global 'game' (a nil value)
Posted: Sat Oct 17, 2015 6:38 am
Hello.
I keep searching but I just don't get this so far. I realize I need to read a LOT more and will do so for further mods I plan to create. It just appears this hasn't really been addressed in a place I can find
I realize that I can no longer call the game function, but I'm not sure how else to do this. I'm at the bottom of the learning curve currently it seems :p To be very frank; this is my first mod that I hacked together from two other mods. Bob's clock mod and some command line info from daniel34. Any help would be much appreciated! I know how to program in C++ among a few other languages but am VERY new to LUA and factorio modding. So far i don't fully understand the syntax, but I'll get there!
I'm getting the error: __coordinates__/control.lua:5: attempt to index global 'game' (a nil value)
for the following code:
I keep searching but I just don't get this so far. I realize I need to read a LOT more and will do so for further mods I plan to create. It just appears this hasn't really been addressed in a place I can find
I realize that I can no longer call the game function, but I'm not sure how else to do this. I'm at the bottom of the learning curve currently it seems :p To be very frank; this is my first mod that I hacked together from two other mods. Bob's clock mod and some command line info from daniel34. Any help would be much appreciated! I know how to program in C++ among a few other languages but am VERY new to LUA and factorio modding. So far i don't fully understand the syntax, but I'll get there!
I'm getting the error: __coordinates__/control.lua:5: attempt to index global 'game' (a nil value)
for the following code:
Code: Select all
require "defines"
if not coordinates then coordinates = {} end
game.on_event(defines.events.on_tick, function(event)
for i, player in ipairs(game.players) do
if player.gui.top.coordinatesGUI == nil then player.gui.top.add{type="button", name="coordinatesGUI"} end
player.gui.top.coordinatesGUI.caption=string.format("x=%f y=%f",game.player.character.position.x,game.player.character.position.y)
end
end)