|
mguasch01 Newbie
Joined: 27 Mar 2015 Posts: 2 Location: Austria
|
Posted: Fri Mar 27, 2015 11:39 pm
Learning to script. Basic questions |
Hello everyone,
So I'm trying to learn the basics of scripting. Let me first paint you a picture of where I play and what I want to do.
I play an LP MUD, and I want to go through a certain area gathering herbs.
The command to gather herbs is "search here for herbs". It takes a few seconds, then it finds one, and you'd have
to repeat it until there are no more herbs in the room. The command received would be "You find no herbs". I'd like
to search through this area for herbs, moving from room to room until no more herbs are found. I have the area
mapped, and my current sloppy solution is to set a #wa for the amount of miliseconds it takes me to find three herbs,
then move to the next room. The solution isn't optimal because sometimes you find one herb, sometimes three, and
sometimes none. So in the end I either miss a herb or just idle there until the waiting period is over before moving to
another room.
Is there a way to script this task to make it more efficient? What do I need to learn in order to write a working script?
I don't have much experience with CMUD besides basic triggering and aliases, but I understand programming a bit.
Can someone point me in the right direction?
Thanks in advance |
|
|
|
shalimar GURU
Joined: 04 Aug 2002 Posts: 4691 Location: Pensacola, FL, USA
|
Posted: Sat Mar 28, 2015 12:06 am |
The #PAUSE and #STEP commands are meant to do just that sort of thing when using speedwalks or paths.
Make use of '#EVENT onRoomEnter' and check it against %zonename or %roomname as to when you need to do it.
Using #HELP on most #COMMANDs and %functions will pull up the cmud help files.
Any other questions feel free to ask for clarification. |
|
_________________ Discord: Shalimarwildcat |
|
|
|
mguasch01 Newbie
Joined: 27 Mar 2015 Posts: 2 Location: Austria
|
Posted: Sat Mar 28, 2015 12:40 am |
Shalimar, thanks for your prompt reply.
I've looked into the help files on those commands and tried it out but it's not working for me. Let me see if I understood it correctly.
I'd have to slowwalk somewhere and pause in case of finding something, then renew the slow walk afterwards.
Apparently, the SLOW command awaits from some kind of confirmation?
I'm sorry if I'm totally clueless, but can you give me a "for dummies" version?
What I'd like to do is search in every room, and react to a string from the mud (You find no herbs) by moving forward in the path.
At the moment I'm doing this (short example)
nw;search here for herbs;#wa 5000;
n;search here for herbs;#wa 5000;
with strings like "You find a <herbname>!" triggered to react to "search here for herbs" again. |
|
|
|
shalimar GURU
Joined: 04 Aug 2002 Posts: 4691 Location: Pensacola, FL, USA
|
Posted: Sat Mar 28, 2015 9:11 am |
Alright for the help files you would do something like:
#HELP #TRIGGER
or
#HELP %numitems
If its not a valid command or function name it will say file not found, or something similar.
You said you already had the area mapped so i assumed you had some basic map triggers already.
If not you may need to set up #TRIGGERS that will #TAG roomdata.
the mapper will need to be reconfigured after there creation, if it hasn't been already.
I find the map works best in Safe mode when you want to pause things.
Here are some basic settings:
#EVENT onRoomEnter {#PAUSE;search here for herbs}
#TRIGGER {You find *!} {search here for herbs}
#TRIGGER {You find no herbs.} {#STEP}
Thats with no error testing as for when it wants it to be done mind you, this should have you attempting to search with every movement.
You could even queue up several movement commands and it would (should) know to stop in each room along the way.
Assuming you have a good map. |
|
_________________ Discord: Shalimarwildcat |
|
|
|
|
|