/// This line appears on the mud and i want to capture the bolded parts.
/// Your base abilities are: Str:13 Int:14 Wil:18 Dex:15 Con:10.
/// So i use this as a perl regex expression.
Your base abilities are: Str:(\d+) Int:(\d+) Wil:(\d+) Dex:(\d+) Con:(\d+).
Str = matches[2]
Int = matches[3]
Wil = matches[4]
Dex = matches[5]
Con = matches[6]
echo (Str .. ' ' .. Int .. ' ' .. Wil .. ' ' .. Dex .. ' ' .. Con)
/// And i get this result on my screen: 13 14 18 15 10
/// So far so good.
/// Now i want to have this function check if three of the stats are above x number, so i write it this way:
function checkstats()
if Str >= 15 and Dex >= 17 and con >= 13
then
/// What command do i use to play of a sound file here?
return true
else
send ('restat')
return false
end
end
/// And i try to run it:
checkstats()
/// It doesn't work and i get this in the debugger:::
/// LUA: ERROR running script STATS (Trigger34) ERROR:[string "function Trigger34()..."]:10: attempt to
/// compare number with string
/// Teach me master, do i have to declare the variables as integer or something?? Am i using wrong type of wildcards?!
Wildcards/function
Re: Wildcards/function
Hi, Zenith. Dead easy to fix this. Simply replace all your lines, following this method:
Hope that helps.
Lastly, the function you need here is playSoundFile(). You can find more details on it from the wiki page: http://wiki.mudlet.org/w/Manual:Lua_Fun ... ySoundFile
Hope that helps.
Re: Wildcards/function
// It now looks like this.
Str = tonumber(matches[2])
Int = tonumber(matches[3])
Wil = tonumber(matches[4])
Dex = tonumber(matches[5])
Con = tonumber(matches[6])
echo ("\n" .. Str .. ' ' .. Int .. ' ' .. Wil .. ' ' .. Dex .. ' ' .. Con)
function checkstats()
if Str >= 15 and Dex >= 17 and con >= 13
then
echo ("You got it!")
return true
else
send ('restat')
send ('k sapling')
return false
end
end
checkstats()
/// New Error: LUA: ERROR running script STATS (Trigger34) ERROR:[string "function Trigger34()..."]:10: attempt to compare number with nil
Str = tonumber(matches[2])
Int = tonumber(matches[3])
Wil = tonumber(matches[4])
Dex = tonumber(matches[5])
Con = tonumber(matches[6])
echo ("\n" .. Str .. ' ' .. Int .. ' ' .. Wil .. ' ' .. Dex .. ' ' .. Con)
function checkstats()
if Str >= 15 and Dex >= 17 and con >= 13
then
echo ("You got it!")
return true
else
send ('restat')
send ('k sapling')
return false
end
end
checkstats()
/// New Error: LUA: ERROR running script STATS (Trigger34) ERROR:[string "function Trigger34()..."]:10: attempt to compare number with nil
Re: Wildcards/function
case error. Variables are case sensitive, Con != con.
Re: Wildcards/function
Aha thanks! I always miss those!