Hi Nick and all,
I only have limited experience with Lua and want to know if the following situation is possible:
If a condition is met (or not met), then assign a boolean value to a variable.
My code as following (purpose is to check if players and mobs are in the set list then assign "fighting" is true/false to determine next action):
I tried several times but in vain (the code can be executed while pplroom & mobroom are always false) and didn't find any related topic in the forum, thus I'd like to seek for your advice.
Thanks in advance.
P.S. I have some other questions regarding matching values in Lua table which are related to the code I posted here - will ask questions later.
I only have limited experience with Lua and want to know if the following situation is possible:
If a condition is met (or not met), then assign a boolean value to a variable.
My code as following (purpose is to check if players and mobs are in the set list then assign "fighting" is true/false to determine next action):
function check_player()
local match = nil
-- pplroom = false
for k, v in pairs (players) do
if string.match (Char_Name, k:lower ()) then
match = k -- remember match
Note ("Warning, player " .. match .. " here.")
pplroom = true
else
pplroom = false
end -- if
end -- for
end -- function
function check_mob()
local match = nil
for k, v in pairs (mobs) do
if string.match (Char_Name, k:lower ()) then
match = k -- remember match
Execute ("say " .. "Mob " .. match .. " here.")
mobroom = true
else
mobroom = false
end -- if
end -- for
end -- function
I tried several times but in vain (the code can be executed while pplroom & mobroom are always false) and didn't find any related topic in the forum, thus I'd like to seek for your advice.
Thanks in advance.
P.S. I have some other questions regarding matching values in Lua table which are related to the code I posted here - will ask questions later.