I guess this error throws when the function in question is called for a second time.
The first call deletes the nodes but the table is untouched and still holds the values.
In the second run, the function throws the error because the nodes have been already deleted.
A short test (please correct me if there is dodgy code in it):
local boxes_array = {}
local input_counter = 0
local pos = 50
-- make some box nodes
local function make_boxes()
for i = 1, 4 do
local box = gui.new_box_node(vmath.vector3(pos, pos, 0), vmath.vector3(50, 50, 0))
gui.set_color(box, vmath.vector4(1,1,1,1))
pos = pos + 50
gui.set_position(box, vmath.vector3(pos, pos, 0))
table.insert(boxes_array, box)
end
-- reset pos so next clones are positioned like the previous ones
pos = 50
print("making boxes")
end
-- delete the box nodes
local function delete_boxes()
for i = 1, #boxes_array do
gui.delete_node(boxes_array[i])
end
print("deleting boxes")
end
function init(self)
msg.post(".", "acquire_input_focus")
make_boxes()
end
function on_input(self, action_id, action)
if action_id == hash("touch") then
if action.pressed then
input_counter = input_counter + 1
print("input number: "..input_counter)
print("lenght table: "..#boxes_array)
delete_boxes()
--make_boxes()
for i = 1, #boxes_array do
print(boxes_array[i])
end
print()
end
end
end
init makes the boxes:
call 1: boxes deleted, table still holds the values, call 2: error throws
Solution: remove the table values, eg. like this:
-- delete the box nodes
local function delete_boxes()
for i = 1, #boxes_array do
gui.delete_node(boxes_array[i])
boxes_array[i] = nil
end
print("deleting boxes")
end
output after call 2: