weac.parse.map: add nil check via assertion

This commit is contained in:
Starbeamrainbowlabs 2024-10-07 19:07:49 +01:00
parent 717a651bd8
commit 7b43e4b201
No known key found for this signature in database
GPG Key ID: 1BE5172E637709C2

@ -4,6 +4,8 @@ local wea_c = worldeditadditions_core
--- ---
-- @module worldeditadditions_core.parse -- @module worldeditadditions_core.parse
--- 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 doawesome true" 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, doawesome = true }. -- the following table: { count = 25000, speed = 0.8, rate_erosion = 0.006, doawesome = true }.
@ -25,6 +27,9 @@ local function parse_map(params_text, keywords)
-- Look for bools -- Look for bools
if part_converted == "true" then part_converted = true end if part_converted == "true" then part_converted = true end
if part_converted == "false" then part_converted = false end if part_converted == "false" then part_converted = false end
if last_key == nil then
return false, "Error: nil check assertion in worldeditadditions_core.parse.map:state/mode/VALUE failed."
end
result[last_key] = part_converted result[last_key] = part_converted
mode = "KEY" mode = "KEY"
else else