GUI - Unknown Position Error

Place to get help with not working mods / modding interface.
Post Reply
User avatar
metzyn
Long Handed Inserter
Long Handed Inserter
Posts: 96
Joined: Tue Mar 19, 2013 10:49 pm
Contact:

GUI - Unknown Position Error

Post 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.
Factorio Modder
Solar Expansion

kovarex
Factorio Staff
Factorio Staff
Posts: 8078
Joined: Wed Feb 06, 2013 12:00 am
Contact:

Re: GUI - Unknown Position Error

Post 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

User avatar
metzyn
Long Handed Inserter
Long Handed Inserter
Posts: 96
Joined: Tue Mar 19, 2013 10:49 pm
Contact:

Re: GUI - Unknown Position Error

Post 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)
Factorio Modder
Solar Expansion

User avatar
metzyn
Long Handed Inserter
Long Handed Inserter
Posts: 96
Joined: Tue Mar 19, 2013 10:49 pm
Contact:

Re: GUI - Unknown Position Error

Post by metzyn »

And how do I make the frame longer???

My text gets cut off.
Factorio Modder
Solar Expansion

User avatar
metzyn
Long Handed Inserter
Long Handed Inserter
Posts: 96
Joined: Tue Mar 19, 2013 10:49 pm
Contact:

Re: GUI - Unknown Position Error

Post 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.
Factorio Modder
Solar Expansion

kovarex
Factorio Staff
Factorio Staff
Posts: 8078
Joined: Wed Feb 06, 2013 12:00 am
Contact:

Re: GUI - Unknown Position Error

Post by kovarex »

This seems like buggy behavior, I will take a look at it.

Post Reply

Return to “Modding help”