2024-01-07 04:06:00 +00:00
|
|
|
print("Hello World")
|
2024-01-07 05:57:19 +00:00
|
|
|
|
2024-01-13 16:52:20 +00:00
|
|
|
--[[ function on_init()
|
2024-01-07 05:57:19 +00:00
|
|
|
print("Lua script was initialized!")
|
|
|
|
end
|
|
|
|
|
|
|
|
function on_first()
|
|
|
|
print("Lua's first function was called")
|
|
|
|
end
|
|
|
|
|
|
|
|
function on_pre_update()
|
|
|
|
print("Lua's pre-update function was called")
|
2024-01-13 16:52:20 +00:00
|
|
|
end ]]
|
2024-01-07 05:57:19 +00:00
|
|
|
|
2024-02-17 19:27:16 +00:00
|
|
|
---
|
|
|
|
---Recursively dumps a table as a string.
|
|
|
|
---
|
|
|
|
---@param obj table
|
|
|
|
---@return string
|
|
|
|
---@nodiscard
|
|
|
|
function dump_table(obj)
|
|
|
|
if type(obj) == 'table' then
|
|
|
|
local s = '{ '
|
|
|
|
for k,v in pairs(obj) do
|
|
|
|
if type(k) ~= 'number' then k = '"'..k..'"' end
|
|
|
|
s = s .. '['..k..'] = ' .. dump_table(v) .. ','
|
|
|
|
end
|
|
|
|
return s .. '} '
|
|
|
|
else
|
|
|
|
return tostring(obj)
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2024-01-07 05:57:19 +00:00
|
|
|
function on_update()
|
2024-01-13 16:52:20 +00:00
|
|
|
--print("Lua's update function was called")
|
|
|
|
|
2024-02-17 19:27:16 +00:00
|
|
|
--local v = Vec3:new(50, 10, 20)
|
|
|
|
--print("Vec3 = " .. tostring(v))
|
|
|
|
|
|
|
|
world:view(
|
|
|
|
---@param t Transform
|
|
|
|
function (t)
|
|
|
|
print("Found entity at a really cool place: " .. tostring(t))
|
|
|
|
t.translation:move_by(0, 0.001, 0)
|
2024-01-20 05:54:36 +00:00
|
|
|
|
2024-02-17 19:27:16 +00:00
|
|
|
return t
|
|
|
|
end,
|
|
|
|
Transform
|
|
|
|
)
|
2024-01-13 16:52:20 +00:00
|
|
|
|
2024-02-17 19:27:16 +00:00
|
|
|
-- local dt = world:resource(DeltaTime)
|
|
|
|
-- --print("DeltaTime was " .. tostring(dt) .. "s")
|
|
|
|
--
|
|
|
|
-- world:view(function (t)
|
|
|
|
-- --print("Found entity at a really cool place: " .. tostring(t))
|
|
|
|
-- t.translation = t.translation + (Vec3.new(0, 0.5, 0) * dt:get())
|
|
|
|
--
|
|
|
|
-- return t
|
|
|
|
-- end, Transform)
|
2024-01-07 05:57:19 +00:00
|
|
|
end
|
|
|
|
|
2024-01-13 16:52:20 +00:00
|
|
|
--[[ function on_post_update()
|
2024-01-07 05:57:19 +00:00
|
|
|
print("Lua's post-update function was called")
|
|
|
|
end
|
|
|
|
|
|
|
|
function on_last()
|
|
|
|
print("Lua's last function was called")
|
2024-01-13 16:52:20 +00:00
|
|
|
end ]]
|