Large architecture refactor of the scripting system. Previous implementation required Lua scripts to return "action tables" which were interpreted by a large and not very flexible at all if-else ladder in C++. While fine for the initial implementation, it's not scalable, and it makes it impossible for players to write their own meaningful tools.
15 lines
358 B
Lua
15 lines
358 B
Lua
-- /bin/ls - Lists files in a directory.
|
|
local dir = bettola.get_current_dir(context)
|
|
local output = ""
|
|
|
|
-- Iterate over the 'children' map exposed via C++.
|
|
for name, node in pairs(dir.children) do
|
|
output = output .. name
|
|
if node.type == 1 then -- 1 is DIR_NODE enum from C++.
|
|
output = output .. "/"
|
|
end
|
|
output = output .. " "
|
|
end
|
|
|
|
return output
|