Page 1 of 1
GUI - Unknown Position Error
Posted: Thu May 09, 2013 10:47 pm
by metzyn
I've been struggling with the GUI modding code. Everytime I use the position field when adding a new element I receive the below error upon opening a game.
Unknown position: ontherightofthegoal
What am I doing wrong? According to the wiki this is the only supported position at the moment.
Re: GUI - Unknown Position Error
Posted: Fri May 10, 2013 1:19 pm
by kovarex
Oups, I'm sorry I didn't update this part of wiki.
From 0.4 version, it works differently, there is always gui.top, gui.left, gui.center.
These are flows and you can add to it/ remove from it, the position is not needed.
https://forums.factorio.com/wiki/index.php/Lua/Gui
https://forums.factorio.com/wiki/inde ... lement#add
Re: GUI - Unknown Position Error
Posted: Fri May 10, 2013 8:05 pm
by metzyn
Thanks! The wiki is extremely limited and vague so it forces a lot of trial and error to get things working.
Also, I cannot seem to get my frame looking decent. How can I format the text to be centered in the frame?
Code: Select all
game.oninit(function()
game.player.gui.top.add{type="frame", name="coordioFrame", caption="Coordinates", direction="vertical"}
game.player.gui.top.coordioFrame.add{type="label", name="coordinates"}
end)
game.onevent(defines.events, function(event)
if event.name == defines.events.ontick then
x = math.floor(game.player.character.position.x)
y = math.floor(game.player.character.position.y)
game.player.gui.top.coordioFrame.coordinates.caption = x .. ", " .. y
end
end)
Re: GUI - Unknown Position Error
Posted: Fri May 10, 2013 8:23 pm
by metzyn
And how do I make the frame longer???
My text gets cut off.
Re: GUI - Unknown Position Error
Posted: Fri May 10, 2013 9:10 pm
by metzyn
Also... unsure if this is a bug...
When I create a new game the size of the frame is super skinny and doesn't allow all the text to be displayed. When I save and close the frame reformats to the correct size. And then... if I change the code of the mod, such as what the caption of the actual frame is that is not updated in the saved game when I load it.
Re: GUI - Unknown Position Error
Posted: Fri May 10, 2013 9:21 pm
by kovarex
This seems like buggy behavior, I will take a look at it.