for k,v in pairs(self.m_raw_list) do
if self.m_filtercriteria == nil or
self.m_filter_fct(v,self.m_filtercriteria) then
- table.insert(self.m_processed_list,v)
+ self.m_processed_list[#self.m_processed_list + 1] = v
end
end
--------------------------------------------------------------------------------
-- Localize functions to avoid table lookups (better performance).
-local table_insert = table.insert
local string_sub, string_find = string.sub, string.find
--------------------------------------------------------------------------------
-- the form _G["table: 0xFFFFFFF"]
keyStr = string.format("_G[%q]", tostring(k))
-- Dump key table
- table_insert(t, dump2(k, keyStr, dumped))
+ t[#t + 1] = dump2(k, keyStr, dumped)
end
else
keyStr = basic_dump(k)
end
local vname = string.format("%s[%s]", name, keyStr)
- table_insert(t, dump2(v, vname, dumped))
+ t[#t + 1] = dump2(v, vname, dumped)
end
return string.format("%s = {}\n%s", name, table.concat(t))
end
local t = {}
local dumped_indexes = {}
for i, v in ipairs(o) do
- table_insert(t, dump(v, indent, nested, level + 1))
+ t[#t + 1] = dump(v, indent, nested, level + 1)
dumped_indexes[i] = true
end
for k, v in pairs(o) do
k = "["..dump(k, indent, nested, level + 1).."]"
end
v = dump(v, indent, nested, level + 1)
- table_insert(t, k.." = "..v)
+ t[#t + 1] = k.." = "..v
end
end
nested[o] = nil
local s = string_sub(str, pos, np - 1)
if include_empty or (s ~= "") then
max_splits = max_splits - 1
- table_insert(items, s)
+ items[#items + 1] = s
end
pos = npe + 1
until (max_splits == 0) or (pos > (len + 1))
--------------------------------------------------------------------------------
function table.indexof(list, val)
- for i = 1, #list do
- if list[i] == val then
+ for i, v in ipairs(list) do
+ if v == val then
return i
end
end
local last_line = ""
while start ~= nil do
if string.len(last_line) + (stop-start) > charlimit then
- table_insert(retval, last_line)
+ retval[#retval + 1] = last_line
last_line = ""
end
last_line = last_line .. string_sub(text, current_idx, stop - 1)
if gotnewline then
- table_insert(retval, last_line)
+ retval[#retval + 1] = last_line
last_line = ""
gotnewline = false
end
--add last part of text
if string.len(last_line) + (string.len(text) - current_idx) > charlimit then
- table_insert(retval, last_line)
- table_insert(retval, string_sub(text, current_idx))
+ retval[#retval + 1] = last_line
+ retval[#retval + 1] = string_sub(text, current_idx)
else
last_line = last_line .. " " .. string_sub(text, current_idx)
- table_insert(retval, last_line)
+ retval[#retval + 1] = last_line
end
return retval
if iswall then
core.set_node(pos, {name = wield_name,
- param2 = dirs1[fdir+1]})
+ param2 = dirs1[fdir + 1]})
elseif isceiling then
if orient_flags.force_facedir then
core.set_node(pos, {name = wield_name,
param2 = 20})
else
core.set_node(pos, {name = wield_name,
- param2 = dirs2[fdir+1]})
+ param2 = dirs2[fdir + 1]})
end
else -- place right side up
if orient_flags.force_facedir then
local i = local_index
local_index = local_index + 1
var = "_["..i.."]"
- table.insert(local_defs, var.." = "..val)
+ local_defs[#local_defs + 1] = var.." = "..val
dumped[x] = var
return var
end
local np = nest_points[x]
for i, v in ipairs(x) do
if not np or not np[i] then
- table.insert(vals, dump_or_ref_val(v))
+ vals[#vals + 1] = dump_or_ref_val(v)
end
idx_dumped[i] = true
end
for k, v in pairs(x) do
if (not np or not np[k]) and
not idx_dumped[k] then
- table.insert(vals,
- "["..dump_or_ref_val(k).."] = "
- ..dump_or_ref_val(v))
+ vals[#vals + 1] = "["..dump_or_ref_val(k).."] = "
+ ..dump_or_ref_val(v)
end
end
return "{"..table.concat(vals, ", ").."}"
local function dump_nest_points()
for parent, vals in pairs(nest_points) do
for k, v in pairs(vals) do
- table.insert(local_defs, dump_or_ref_val(parent)
+ local_defs[#local_defs + 1] = dump_or_ref_val(parent)
.."["..dump_or_ref_val(k).."] = "
- ..dump_or_ref_val(v))
+ ..dump_or_ref_val(v)
end
end
end
if image == nil then image = "" end
if tooltip == nil then tooltip = "" end
- table.insert(self.buttons,{ name=name, caption=caption, image=image, tooltip=tooltip})
+ self.buttons[#self.buttons + 1] = {
+ name = name,
+ caption = caption,
+ image = image,
+ tooltip = tooltip
+ }
if self.orientation == "horizontal" then
if ( (self.btn_size * #self.buttons) + (self.btn_size * 0.05 *2)
> self.size.x ) then
tabdata = {},
}
- table.insert(self.tablist,newtab)
+ self.tablist[#self.tablist + 1] = newtab
if self.last_tab_index == #self.tablist then
self.current_tab = tab.name
local list = {}
for priv, bool in pairs(privs) do
if bool then
- table.insert(list, priv)
+ list[#list + 1] = priv
end
end
return table.concat(list, delim)
local cmds = {}
for cmd, def in pairs(core.chatcommands) do
if core.check_player_privs(name, def.privs) then
- table.insert(cmds, cmd)
+ cmds[#cmds + 1] = cmd
end
end
table.sort(cmds)
local cmds = {}
for cmd, def in pairs(core.chatcommands) do
if core.check_player_privs(name, def.privs) then
- table.insert(cmds, format_help_line(cmd, def))
+ cmds[#cmds + 1] = format_help_line(cmd, def)
end
end
table.sort(cmds)
elseif param == "privs" then
local privs = {}
for priv, def in pairs(core.registered_privileges) do
- table.insert(privs, priv .. ": " .. def.description)
+ privs[#privs + 1] = priv .. ": " .. def.description
end
table.sort(privs)
return true, "Available privileges:\n"..table.concat(privs, "\n")
function core.after(after, func, ...)
assert(tonumber(time) and type(func) == "function",
"Invalid core.after invocation")
- table.insert(jobs, {
+ jobs[#jobs + 1] = {
func = func,
expire = time + after,
arg = {...},
mod_origin = core.get_last_run_mod()
- })
+ }
end
function core.check_player_privs(player_or_name, ...)
-- We were provided with a table like { privA = true, privB = true }.
for priv, value in pairs(requested_privs[1]) do
if value and not player_privs[priv] then
- table.insert(missing_privileges, priv)
+ missing_privileges[#missing_privileges + 1] = priv
end
end
else
-- Only a list, we can process it directly.
for key, priv in pairs(requested_privs) do
if not player_privs[priv] then
- table.insert(missing_privileges, priv)
+ missing_privileges[#missing_privileges + 1] = priv
end
end
end
local temp_table = {}
for index, value in pairs(player_list) do
if value:is_player_connected() then
- table.insert(temp_table, value)
+ temp_table[#temp_table + 1] = value
end
end
return temp_table
function core.register_abm(spec)
-- Add to core.registered_abms
- core.registered_abms[#core.registered_abms+1] = spec
+ core.registered_abms[#core.registered_abms + 1] = spec
spec.mod_origin = core.get_current_modname() or "??"
end
local function make_registration()
local t = {}
local registerfunc = function(func)
- table.insert(t, func)
+ t[#t + 1] = func
core.callback_origins[func] = {
mod = core.get_current_modname() or "??",
name = debug.getinfo(1, "n").name or "??"
function core.register_on_player_hpchange(func, modifier)
if modifier then
- table.insert(core.registered_on_player_hpchanges.modifiers, func)
+ core.registered_on_player_hpchanges.modifiers[#core.registered_on_player_hpchanges.modifiers + 1] = func
else
- table.insert(core.registered_on_player_hpchanges.loggers, func)
+ core.registered_on_player_hpchanges.loggers[#core.registered_on_player_hpchanges.loggers + 1] = func
end
core.callback_origins[func] = {
mod = core.get_current_modname() or "??",
for i=1,#list,1 do
local fav = list[i]
if is_server_protocol_compat(fav.proto_min, fav.proto_max) then
- table.insert(res, fav)
+ res[#res + 1] = fav
end
end
for i=1,#list,1 do
local fav = list[i]
if not is_server_protocol_compat(fav.proto_min, fav.proto_max) then
- table.insert(res, fav)
+ res[#res + 1] = fav
end
end
return res
if name:sub(1, 1) ~= "." then
local prefix = path .. DIR_DELIM .. name .. DIR_DELIM
local toadd = {}
- table.insert(retval, toadd)
+ retval[#retval + 1] = toadd
local mod_conf = Settings(prefix .. "mod.conf"):to_table()
if mod_conf.name then
for i=1,#global_mods,1 do
global_mods[i].typ = "global_mod"
- table.insert(retval,global_mods[i])
+ retval[#retval + 1] = global_mods[i]
end
--read game mods
for i=1,#game_mods,1 do
game_mods[i].typ = "game_mod"
- table.insert(retval,game_mods[i])
+ retval[#retval + 1] = game_mods[i]
end
if data.worldpath == nil then
descriptionfile:close()
else
descriptionlines = {}
- table.insert(descriptionlines,fgettext("No mod description available"))
+ descriptionlines[#descriptionlines + 1] = fgettext("No mod description available")
end
retval = retval ..
local retval = {}
for _, item in ipairs(list) do
if item ~= "base" then
- table.insert(retval, item)
+ retval[#retval + 1] = item
end
end