mirror of
https://github.com/minetest-mods/mesecons.git
synced 2024-12-26 15:37:27 +01:00
Fix a bug in long conditions
This commit is contained in:
parent
0ee661d25d
commit
f701dad739
@ -190,16 +190,14 @@ function yc_command_if_parsecondition(cond, L)
|
||||
cond = string.gsub(cond, "!0", "1")
|
||||
cond = string.gsub(cond, "!1", "0")
|
||||
|
||||
print(cond)
|
||||
local i = 2
|
||||
local l = string.len(cond)
|
||||
while i<=l do
|
||||
local s = cond:sub(i,i)
|
||||
local b = tonumber(cond:sub(i-1, i-1))
|
||||
local a = tonumber(cond:sub(i+1, i+1))
|
||||
if a == "" then print ("ERROR") break end
|
||||
if cond:sub(i+1, i+1) == nil then break end
|
||||
if s == "=" then
|
||||
print(b.."="..a.."?")
|
||||
if a == b then buf = "1" end
|
||||
if a ~= b then buf = "0" end
|
||||
cond = string.gsub(cond, b..s..a, buf)
|
||||
@ -208,7 +206,6 @@ function yc_command_if_parsecondition(cond, L)
|
||||
end
|
||||
i = i + 1
|
||||
end
|
||||
print(cond)
|
||||
|
||||
local i = 2
|
||||
local l = string.len(cond)
|
||||
@ -216,7 +213,7 @@ function yc_command_if_parsecondition(cond, L)
|
||||
local s = cond:sub(i,i)
|
||||
local b = tonumber(cond:sub(i-1, i-1))
|
||||
local a = tonumber(cond:sub(i+1, i+1))
|
||||
if a == "" then break end
|
||||
if cond:sub(i+1, i+1) == nil then break end
|
||||
if s == "&" then
|
||||
local buf = ((a==1) and (b==1))
|
||||
if buf == true then buf = "1" end
|
||||
@ -243,7 +240,6 @@ function yc_command_if_parsecondition(cond, L)
|
||||
end
|
||||
i = i + 1
|
||||
end
|
||||
print(cond)
|
||||
return cond
|
||||
end
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user