376 posts
Location
[string "FindMe"]:23143: bad argument #1 to 'returnPos' (vector expected, got nil)
Posted 17 June 2016 - 09:55 PM
I need to rotate things around the center of a window made with the window api, and it would be much easier if I was able to set (0,0) to the center of the window, making it a cartesian system instead of a top left system then using the equation for rotation. However, I have absolutely no idea how to set (0,0) to a different coordinate(the center of window).
212 posts
Location
Somewhere in this dimension... I think.
Posted 17 June 2016 - 10:02 PM
You can replace term.getCursorPos but good luck with that, you'd have to keep an old copy and do math on an uneven plane
376 posts
Location
[string "FindMe"]:23143: bad argument #1 to 'returnPos' (vector expected, got nil)
Posted 17 June 2016 - 10:14 PM
Got it!
If anyone is curious, I turned it into a cartesian coordinate system using this
local map = window.create(term.native(),0,0,29,20)
local oldCursorPos = map.setCursorPos
local oldGetCP = map.getCursorPos
local maxX, maxY = map.getSize()
map.getCursorPos = function() local x,y = oldGetCP() return x-(math.ceil(maxX/2)),-(y-(math.ceil(maxY/2))) end
map.setCursorPos = function(x,y) oldCursorPos(x+(math.ceil(maxX/2)),-(y-(math.ceil(maxY/2)))) end
Edited on 17 June 2016 - 08:15 PM