Modular, sane programming - how?

Posted by Fearless on Sun 28 May 2017 09:23 PM — 2 posts, 13,032 views.

#0
I need advice. I can't figure out the strategy to get modular, sane programming into MUSHclient. Much of what I want to do involves waiting for text or time to pass before continuing the logic. Chasing triggers around in circles is a logical nightmare.

I've seen the 'require "wait"' thing. Using it in an alias works as described but then calling that alias while inside some other script makes it lose the "waiting" feature.

My script section for my testwait alias is this, and it works:
require "wait"
wait.make (function ()
Send ("test1")
wait.time (4)
Send ("test2")
end)

My script section for my testmodular alias is this:
Note("running alias w/ wait...")
Execute("testwait")
Note("alias w/ wait done...")

The testmodular alias displays both notes before testwait sends anything. Clearly, I can't use something like testwait as a modular procedure to help me build a complex program until I fix something, but what?
USA Global Moderator #1
Your "wait.make (function ()...end)" needs to encompass everything that you want to have happen in order with delays in between, including those two outer notes.

Think of it sort of like creating a second lane in the instruction processing highway instead of having only one. Everything on the outside is in one lane, everything on the inside is in the other lane. The inner lane gets to stop moving and relax as much as it wants. The outer lane has to go go go and doesn't get to stop moving.

Quote:
modular, sane programming

I think you might benefit from looking up techniques for implementing state machines.