Ok, so I'm trying to create a script to do basic math for me, Unfortunately I'm a complete coding noob
If anyone could give me some idea if it's possible and how to do It I'd appreciate it.
As an example. I used to have a set of triggers for the Achaea Bopolopia cows that looked like this:
#TRIGGER {If (%1) cows jumped into Runaway River and (%2) } {#math answer %1-%2;say @answer}
How would these kinds of things be done in Mudlet?
Help with Basic math
Re: Help with Basic math
The \d+ matches numbers, which goes into 'matches[2]' and 'matches[3]' similar to %1 and %2. You don't need to do #math, because Lua understands how to do math if you just do "variable = a + b"
Then you send what you want to say.
Re: Help with Basic math
Trigger matches are stored as strings. The code posted before needs to be modified slightly to work.
Re: Help with Basic math
I'm virtually inept at coding and I can't type numbers fast enough in-game to answer the questions within 2 seconds but the trigger help, above, also doesn't work for me. What am I missing?
^If (\d+) cows jumped into Runaway River and (\d+)
answer = tonumber(matches[2])-tonumber(matches[3])
send("say " .. answer)
^If (\d+) beavers and (\d+) beavers got together with (\d+)
answer = tonumber(matches[2])+tonumber(matches[3])+tonumber(matches[4])
send("say " .. answer)
And so on. I've tried the trigger phrases as substrings, as perl regex, and as exact matches but nothing happens when the phrase is triggered.
^If (\d+) cows jumped into Runaway River and (\d+)
answer = tonumber(matches[2])-tonumber(matches[3])
send("say " .. answer)
^If (\d+) beavers and (\d+) beavers got together with (\d+)
answer = tonumber(matches[2])+tonumber(matches[3])+tonumber(matches[4])
send("say " .. answer)
And so on. I've tried the trigger phrases as substrings, as perl regex, and as exact matches but nothing happens when the phrase is triggered.