mirror of
https://github.com/sbrl/Minetest-WorldEditAdditions.git
synced 2024-09-12 08:08:30 +02:00
wea.parse.map: support bools
This commit is contained in:
parent
0498125ca7
commit
dc7ccf49f3
@ -1,7 +1,7 @@
|
|||||||
|
|
||||||
--- Parses a map of key-value pairs into a table.
|
--- Parses a map of key-value pairs into a table.
|
||||||
-- For example, "count 25000 speed 0.8 rate_erosion 0.006" would be parsed into
|
-- For example, "count 25000 speed 0.8 rate_erosion 0.006 doawesome true" would be parsed into
|
||||||
-- the following table: { count = 25000, speed = 0.8, rate_erosion = 0.006 }.
|
-- the following table: { count = 25000, speed = 0.8, rate_erosion = 0.006, doawesome = true }.
|
||||||
-- @param params_text string The string to parse.
|
-- @param params_text string The string to parse.
|
||||||
-- @returns table A table of key-value pairs parsed out from the given string.
|
-- @returns table A table of key-value pairs parsed out from the given string.
|
||||||
function worldeditadditions.parse.map(params_text)
|
function worldeditadditions.parse.map(params_text)
|
||||||
@ -14,6 +14,9 @@ function worldeditadditions.parse.map(params_text)
|
|||||||
-- Try converting to a number to see if it works
|
-- Try converting to a number to see if it works
|
||||||
local part_converted = tonumber(part)
|
local part_converted = tonumber(part)
|
||||||
if as_number == nil then part_converted = part end
|
if as_number == nil then part_converted = part end
|
||||||
|
-- Look for bools
|
||||||
|
if part_converted == "true" then part_converted = true end
|
||||||
|
if part_converted == "false" then part_converted = false end
|
||||||
result[last_key] = part
|
result[last_key] = part
|
||||||
else
|
else
|
||||||
last_key = part
|
last_key = part
|
||||||
|
Loading…
Reference in New Issue
Block a user