Register to post in forums, or Log in to your existing account
 

Play RetroMUD
Post new topic  Reply to topic     Home » Forums » zMUD General Discussion
tyh
Beginner


Joined: 01 Feb 2004
Posts: 24
Location: United Kingdom

PostPosted: Sun Feb 01, 2004 2:35 am   

Pausing and program flow
 
Could someone please explain to me how the commands in the zmud language control the flow of the program. Also examples of useful structures utilizing such would be helpful.
Reply with quote
LightBulb
MASTER


Joined: 28 Nov 2000
Posts: 4817
Location: USA

PostPosted: Mon Feb 02, 2004 6:05 am   
 
Every zMUD command has its own helpfile which can be found from the zMUD help menu. If you select the Contents button after opening the helpfiles, you'll be given a nice table of contents. At the bottom of it, you'll find the main heading References. After expanding that, you'll find a subheading Command List (alphabetical). This will allow you to access every command's help and ensure you don't miss any.

The help for each command explains what that command does, which would be how it affects program flow, and gives useful examples. Any attempt to duplicate that here would far exceed the reasonable length of a message on this forum.

If you have specific questions, I and many others will be glad to answer or help you find your own answer. However, nobody is likely to feel like explaining the workings of the entire program.
Reply with quote
tyh
Beginner


Joined: 01 Feb 2004
Posts: 24
Location: United Kingdom

PostPosted: Fri Feb 06, 2004 12:28 pm   
 
Sorry didnt make myself clear. It was more a question of how to use commands in practical ituations. E.g I have a set of spell cast aliases that force the spell to cast,looping using the one off alarm command to fire the cast and a flag variable watching for success. What i want to do is force cast a number of spells in one alias, i.e force cast poison and weaken . However waiting inside one alias doesnt seem to stop the procedure that called that alias, it continuing execution and firing off other commands which causes the purpose of my commands to be missed.
Reply with quote
LightBulb
MASTER


Joined: 28 Nov 2000
Posts: 4817
Location: USA

PostPosted: Fri Feb 06, 2004 6:42 pm   
 
You still haven't made yourself clear.

The surest way to get an answer is to provide specific details, such as the actual scripts of the aliases, alarms, and triggers, the actual commands which need to be sent, and a sample of the actual text which will be received.

In posting scripts, please DON'T use the [code] and [/code] forum tags. They disable the forum's wordwrap feature, and that frequently results in posts which are several screens wide and almost impossible to read.
Reply with quote
tyh
Beginner


Joined: 01 Feb 2004
Posts: 24
Location: United Kingdom

PostPosted: Fri Feb 06, 2004 10:33 pm   
 
ok. This is what i do at the moment.
I have an alias force cast shortened name fc thusly:

cc %1 %2 %3
delay @SpDel
#while (@isSpellFail) {
#ALARM +10 {cc %1 %2 %3}
delay @SpDel
}
cc is the normal spellcasting alias which takes 3 params , spell name and 2 other params, and casts the spell.
code is :

setvar casting on
setvar spellfail off
cast %1 %2 %3

setvar is a generic variable routine which turns off and on flag variables

Delay is this :
#var delval 0
#var deltop %1
#while (@delval <> @deltop) {#ADD delval 1}
which locks up all other threads whilst the while loop executes.

SpDel is a variable set by the specific spell alias called to control the length of this delay. isSpellFail is a variable which tests another variable , spellfail, which is set to zero in the casting alias and set to 1 in the spell fail trigger.

Now it seems to me if there was commands which would remove the need for the delay routine then trhat might be a bit more elegant. Whilst this code works , it sometimes messes up and of course nothing can be done other than the casting of these spells.

What I'm looking for is maybe other ways of approaching the problem or simple commands which freeze all program execution or commands which allow execution to continue whilst the specific procedure or loop the command is in is frozen.
Reply with quote
LightBulb
MASTER


Joined: 28 Nov 2000
Posts: 4817
Location: USA

PostPosted: Sat Feb 07, 2004 4:50 am   
 
As I understand it, you want an alias which will allow you to supply several spells and the alias will
1. Cast the first spell
2. If the spell fails, recast it
3. If it didn't fail, cast the next spell
4. Repeat steps 2 and 3 as needed until all spells have been cast

It seems to me that the easiest way to do this would be to convert the alias parameter string to a list, then go through the list. You can still use an alarm to control the recasting interval. I don't recommend the #WHILE loops since the time required to complete one will vary, depending on how busy the computer is, and they will use most of the computer's processing time, which will pretty much freeze the computer. I'm assuming you have a trigger which sets @SpellFail to 1 whenever a spell failure message occurs.

#AL fc1 {
#VA casting 1
#VA SpellFail 0
#VA fc2 %replace( %-1, " ", "|")
cast %item( @fc2, 1)
#ALA fc3 *10 {
#IF (@SpellFail = 0) {#DELN fc2 1}
#IF (%numitems( @fc2) > 0) {
#VA casting 1
#VA SpellFail 0
cast %item( @fc2, 1)
} {#UNTR fc3}
}}

To use, paste the entire script to the command line (it's all one alias).
Then type the alias name, fc1, followed by any number of one-word spells:
fc1 poison weaken blind

This doesn't allow targets, I've assumed it will be used in combat with autotargeting. It also doesn't allow multi-word spells, so faerie fire is out. Sorry, it's the best I could come up with at this time.
Reply with quote
tyh
Beginner


Joined: 01 Feb 2004
Posts: 24
Location: United Kingdom

PostPosted: Sat Feb 07, 2004 1:44 pm   
 
works great thanks Smile
Reply with quote
tyh
Beginner


Joined: 01 Feb 2004
Posts: 24
Location: United Kingdom

PostPosted: Sat Feb 07, 2004 5:14 pm   
 
How would you do a similar thing for speedwalking paths you create on the fly so as the mud doesnt get spammed.

eg I have some routines that move me too any point on the map from any other, but frequently it either spams the server till i get disconnected or simply breaks all together (ulp). Heres the code :
;;firstly it captures current world co-ords in currX and currY ;;from trigger fired from looking at the sextant
look sex
#va targX %1
#va targY %2
#va distX 0
#Math distX %abs( @targX-@currX)
#va distY 0
#Math distY %abs( @targY-@currY)
;;it now has the offset in x y directions from current
;;to target (%1 %2) in distx disty
;;it now builds the text direction to target from these two vars
#va chrB ""
#if (@currX>@targX) {
@chrB = W
} {
#if (@currX<@targX) {
@chrB = E
}
}
#va chrA ""
#if (@currY>@targY) {
@chrA = N
} {
#if (@currY<@targY) {
@chrA = S
}
}
#va dir %remove( " ", %concat( @chrA, @chrB))
;; dir now contains the text direction
#va ddis 0
#va remaindis 0
#va remain ""
;; it then goes diagonaly across the 'square' formed by
;;the smaller of the two distances and then tags on the
;;difference between the two distances in the direction of
;;the longer one
#if (@distX>@distY) {
@ddis = @distY
#math remaindis %abs( @distX-@distY)
@remain = @chrB
} {
@ddis = @distX
#math remaindis %abs( @distY-@distX)
@remain = @chrA
}
;;now the bit id like help with. Again i use the
;;delay procedure to try to slow things down. Longmove is
;;a procedure that spams the first parameter the second
;;param number of times
delay 50
#if (@distX=0) {
#if (@distY=0) {
#noop
} {
LongMove @dir @distY
}
} {
#if (distY=0) {
LongMove @dir @distX
} {
LongMove @dir @ddis
LongMove @remain @remaindis
}
}
Reply with quote
tyh
Beginner


Joined: 01 Feb 2004
Posts: 24
Location: United Kingdom

PostPosted: Sat Feb 07, 2004 5:24 pm   
 
Thinking on... its longmove that possibly needs the mods . Heres the code:

#VAR A %2
#WHILE (@A <> 0) {
%1
#ADD A -1
}
Reply with quote
Display posts from previous:   
Post new topic   Reply to topic     Home » Forums » zMUD General Discussion All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum

© 2009 Zugg Software. Hosted by Wolfpaw.net