I can’t come up with an explanation for this error:
function init(self)
msg.post(".","acquire_input_focus")
local caretPos = gui.get_position(gui.get_node("Caret")) -- I get the node's position
print(caretPos)
end
function update(self, dt)
caret() -- triggers caretActive, turning it on and off
if caretActive == 1 then
gui.set_text(gui.get_node("Caret"),"|")
gui.set_position(gui.get_node("Caret"),caretPos[1]+10*chatLen) -- This is the problem child. It's found nil when I try to set it's X (X, Y, Z) to 10 times the chat length.
elseif caretPos ~= nil then
gui.set_text(gui.get_node("Caret"),"")
gui.set_position(gui.get_node("Caret"),caretPos)
print("set caret position")
end
end
My error is that the system seems to be finding caretPos to be nil when I clearly set it in the Init function. I realize using it as a list when it’s a vector is probably not going to return correctly, and I’d need to figure out how to get it’s X position another way, but I was experimenting to see if that would somehow would fix the problem–the system finding it nil.