Page 1 of 1

game.player.cursorposition should be relative

Posted: Sun Sep 21, 2014 5:21 pm
by Adil
Currently this field stores absolute value that depends on the game window size, which seems impossible to determine.
It'd be more useful if we could obtain the cursor position in screen units (e.g. cursor.x/window_width). Maybe even with character being reference point.

Re: game.player.cursorposition should be relative

Posted: Sun Sep 21, 2014 5:44 pm
by jeroon
do these help?

screen2realposition
Translate screen coordinates (position relative to the left top edge of the window) to the map coordinates (what is the map position of the place under the cursor).
real2screenposition
Translate map coordinates to screen coordinates.

Re: game.player.cursorposition should be relative

Posted: Mon Sep 22, 2014 1:03 pm
by Rseding91
See also: https://forums.factorio.com/forum/vie ... f=7&t=5917

So, take care if you're going to use that method :) It might not exist forever.

Re: game.player.cursorposition should be relative

Posted: Tue Sep 23, 2014 4:57 pm
by Adil
jeroon wrote:do these help?
snip
Well, those definitely could be used to pile up a function that achieves the same goal, but I wouldn't want to use it on each tick if a simple table field lookup was possible.
Rseding91 wrote:See also: https://forums.factorio.com/forum/vie ... f=7&t=5917

So, take care if you're going to use that method :) It might not exist forever.
Aww. That's sad. Those were nice way of making custom controls in the mods.

Re: game.player.cursorposition should be relative

Posted: Wed Sep 24, 2014 1:22 pm
by Rseding91
Adil wrote:Aww. That's sad. Those were nice way of making custom controls in the mods.
After reading their response I don't think the methods are going anywhere but they definitely won't be compatible with MP/replays so you'll want to keep that in mind if you do use them.