CRASHFIX: the debug utility wasn't converting tables in strings, making the game crash if a table was present
This commit is contained in:
parent
bf8dde51cd
commit
80c092a132
2
DOCS.md
2
DOCS.md
@ -68,7 +68,7 @@ If you don't want to rely on the hotbar, or you want both the editor and the com
|
||||
|
||||
##### 1.2.2.3 Arenas properties
|
||||
Properties are explained down below, but essentially they allow you to create additional attributes specifically suited for what you have in mind (e.g. a score to reach to win the game).
|
||||
`arena_lib.change_arena_properties(sender, mod, arena_name, property, new_value)` changes the specified arena property with `new_value`. Keep in mind you can't change a property type (a number must remain a number, a string a string etc), and strings need quotes surrounding them - so `false` is a boolean, but `"false"` is a string.
|
||||
`arena_lib.change_arena_properties(sender, mod, arena_name, property, new_value)` changes the specified arena property with `new_value`. Keep in mind you can't change a property type (a number must remain a number, a string a string etc), and strings need quotes surrounding them - so `false` is a boolean, but `"false"` is a string. Also, this works for *arena* properties only. Not for temporary, players, nor team ones.
|
||||
|
||||
##### 1.2.2.4 Spawners
|
||||
`arena_lib.set_spawner(sender, mod, arena_name, <teamID_or_name>, <param>, <ID>)` creates a spawner where the sender is standing, so be sure to stand where you want the spawn point to be.
|
||||
|
@ -3,7 +3,7 @@ local FS = minetest.formspec_escape
|
||||
|
||||
local function get_rename_formspec() end
|
||||
local function get_properties_formspec() end
|
||||
local function property_to_string() end
|
||||
local function value_to_string() end
|
||||
|
||||
local settings_tools = {
|
||||
"arena_lib:settings_rename",
|
||||
@ -81,7 +81,7 @@ function get_properties_formspec(p_name, mod, arena, sel_idx)
|
||||
|
||||
-- ottengo una stringa con tutte le proprietà
|
||||
for property, v in pairs(mod_ref.properties) do
|
||||
properties = properties .. property .. " = " .. FS(property_to_string(arena[property])) .. ","
|
||||
properties = properties .. property .. " = " .. FS(value_to_string(arena[property])) .. ","
|
||||
properties_by_idx[i] = property
|
||||
i = i + 1
|
||||
end
|
||||
@ -95,7 +95,7 @@ function get_properties_formspec(p_name, mod, arena, sel_idx)
|
||||
|
||||
-- e assegno il valore
|
||||
sel_property_attr[p_name] = {id = sel_idx, name = sel_property}
|
||||
sel_property_value = FS(property_to_string(arena[sel_property]))
|
||||
sel_property_value = FS(value_to_string(arena[sel_property]))
|
||||
|
||||
properties = properties:sub(1,-2)
|
||||
|
||||
@ -129,7 +129,7 @@ end
|
||||
|
||||
|
||||
|
||||
function property_to_string(property)
|
||||
function value_to_string(property)
|
||||
|
||||
if type(property) == "string" then
|
||||
return "\"" .. property .. "\""
|
||||
|
@ -3,6 +3,8 @@
|
||||
---
|
||||
local S = minetest.get_translator("arena_lib")
|
||||
|
||||
local function value_to_string() end
|
||||
|
||||
|
||||
function arena_lib.print_arenas(sender, mod)
|
||||
|
||||
@ -116,14 +118,16 @@ function arena_lib.print_arena_info(sender, mod, arena_name)
|
||||
--calcolo proprietà
|
||||
local properties = ""
|
||||
for property, _ in pairs(mod_ref.properties) do
|
||||
properties = properties .. property .. " = " .. arena[property] .. "; "
|
||||
local value = value_to_string(arena[property])
|
||||
properties = properties .. property .. " = " .. value .. "; "
|
||||
end
|
||||
|
||||
--calcolo proprietà temporanee
|
||||
local temp_properties = ""
|
||||
if arena.in_game == true then
|
||||
for temp_property, _ in pairs(mod_ref.temp_properties) do
|
||||
temp_properties = temp_properties .. temp_property .. " = " .. arena[temp_property] .. "; "
|
||||
local value = value_to_string(arena[temp_property])
|
||||
temp_properties = temp_properties .. temp_property .. " = " .. value .. "; "
|
||||
end
|
||||
else
|
||||
for temp_property, _ in pairs(mod_ref.temp_properties) do
|
||||
@ -139,7 +143,8 @@ function arena_lib.print_arena_info(sender, mod, arena_name)
|
||||
for i = 1, #arena.teams do
|
||||
team_properties = team_properties .. arena.teams[i].name .. ": "
|
||||
for team_property, _ in pairs(mod_ref.team_properties) do
|
||||
team_properties = team_properties .. " " .. team_property .. " = " .. arena.teams[i][team_property] .. ";"
|
||||
local value = value_to_string(arena.teams[i][team_property])
|
||||
team_properties = team_properties .. " " .. team_property .. " = " .. value .. ";"
|
||||
end
|
||||
team_properties = team_properties .. "|"
|
||||
end
|
||||
@ -205,3 +210,19 @@ function arena_lib.print_arena_stats(sender, mod, arena_name)
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
----------------------------------------------
|
||||
---------------FUNZIONI LOCALI----------------
|
||||
----------------------------------------------
|
||||
|
||||
function value_to_string(value)
|
||||
if type(value) == "table" then
|
||||
return tostring(dump(value)):gsub("\n", "")
|
||||
else
|
||||
return tostring(value)
|
||||
end
|
||||
end
|
||||
|
Loading…
x
Reference in New Issue
Block a user