Feature Add-ins
Feature Add-ins expand almostLua functionality by adding libraries, functions or properties that may not arrive out of the box. Add-ins are snippets of almostLua code that go at the top of your script.
Table Add-in
By default, the almostLua table library only has three functions: find, insert and remove. However, this add-in expands it to clear, clone, concat, create, find, freeze, isfrozen, insert, maxn, move, remove:
local table = {
clear = function(tbl)
for i, _ in pairs(tbl) do
tbl[i] = nil
end
end,
clone = function(tbl)
local newTbl = {}
for i, v in pairs(tbl) do
newTbl[i] = v
end
return newTbl
end,
concat = function(tbl, sep, i, j)
local newString = ""
i = i or 1
j = j or #tbl
for x = i, j do
newString = newString .. tbl[x] .. (sep or "")
end
return newString
end,
create = function(count, value)
local newTbl = {}
for i = 1, count do
newTbl[i] = value
end
return newTbl
end,
freeze = function(tbl)
-- Do nothing
return tbl
end,
isfrozen = function(tbl)
-- Cannot freeze RetroStudio tables
return false
end,
maxn = function(tbl)
local max = 0
for i, _ in pairs(tbl) do
if i > max then
max = i
end
end
return max
end,
move = function(src, a, b, t, dst)
if dst == nil then
dst = src
end
for i = a, b do
dst[t + i] = src[i]
end
end,
}Shared Tables Add-in
This add-in adds the _G and shared tables, which allow you to share variables between scripts more efficiently. To use this add-in, you must be using almostLua 1.1 or higher.
Step 1: Import this model code into your RetroStudio game: 971466458 and place it in Lighting.
Step 2: At the top of the Lua script that needs shared tables, insert the following:
Terrain Add-in
The default Terrain class in almostLua is very limited. However, with this add-in, you can expand it to its full functionality set. Note that the add-in makes only bare effort to recreate terrain, there are no textures, shapes nor special materials like water.
Last updated