I'm about a week into using Mudlet and loving it so far. I'm in the process of trying to move my scripts and bots from CMud over so that's driving much of my learning.
One thing I'm trying to figure out is what are my options for porting CMud code like this contrived example:
Code: Select all
get all sack
#WAIT 2000
drop all.sword
#WAIT 2000
#ECHO "done"
One thing I have started doing is breaking these code blocks up into multiple functions and chaining them together with tempTrigger() to accomplish something similar to the original code without nesting quoted tempTimer() blocks:
Code: Select all
TEST = TEST or {}
function TEST.test()
fg("cyan")
echo("\nTEST.test()\n")
TEST.test1()
end
function TEST.test1()
echo("TEST.test1()\n")
tempTimer(2, [[TEST.test2()]])
end
function TEST.test2()
echo("TEST.test2()\n")
tempTimer(2, [[TEST.test3()]])
end
function TEST.test3()
echo("TEST.test3()\n")
end
My question to the more experienced Mudlet users: are there some common patterns for tackling this sort of code that will make it easier to read, develop, and maintain?