turtle: fix tlang integration
This commit is contained in:
parent
16fafaa193
commit
632eb7e286
@ -278,25 +278,32 @@ minetest.register_chatcommand("quarry", {
|
||||
|
||||
|
||||
turtle.states = {}
|
||||
turtle.states_available = false
|
||||
|
||||
function turtle.schedule(name, state)
|
||||
turtle.states[#turtle.states] = {name = name, state = state}
|
||||
turtle.states[#turtle.states + 1] = {name = name, state = state}
|
||||
turtle.states_available = true
|
||||
end
|
||||
|
||||
function turtle.run_states()
|
||||
local dead = {}
|
||||
for i, v in ipairs(turtle.states) do
|
||||
local ret = tlang.step(v.state)
|
||||
if ret ~= true then
|
||||
if type(ret) == "string" then
|
||||
minetest.display_chat_message("Turtle/tlang ERROR in " .. v.name .. ": " .. ret)
|
||||
end
|
||||
dead[#dead] = i
|
||||
end
|
||||
end
|
||||
function turtle.run_states(dtime)
|
||||
if turtle.states_available then
|
||||
local dead = {}
|
||||
|
||||
for i, v in ipairs(dead) do
|
||||
table.remove(turtle.states, v)
|
||||
for i, v in ipairs(turtle.states) do
|
||||
local ret = tlang.step(v.state)
|
||||
if ret ~= true then
|
||||
if type(ret) == "string" then
|
||||
minetest.display_chat_message("Turtle/tlang ERROR in " .. v.name .. ": " .. ret)
|
||||
end
|
||||
dead[#dead + 1] = i
|
||||
end
|
||||
end
|
||||
|
||||
for i, v in ipairs(dead) do
|
||||
table.remove(turtle.states, v)
|
||||
end
|
||||
|
||||
turtle.states_available = #turtle.states ~= 0
|
||||
end
|
||||
end
|
||||
|
||||
|
@ -292,7 +292,11 @@ end
|
||||
function builtins.print(state)
|
||||
local value = statepop(state)
|
||||
|
||||
print(value.value)
|
||||
if minetest then
|
||||
minetest.display_chat_message("Tlang: " .. tostring(value.value))
|
||||
else
|
||||
print(value.value)
|
||||
end
|
||||
end
|
||||
|
||||
function builtins.dup(state)
|
||||
|
Loading…
x
Reference in New Issue
Block a user