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
Scirkhan
Apprentice


Joined: 14 Sep 2007
Posts: 167
Location: aztx

PostPosted: Sun Sep 16, 2007 9:08 am   

#'s, %'s and variables in %if?
 
Commands like %add in %if statements send %add to the game instead? it did for me.

My question, can you use @variables in the true and false statement of %if?
The syntax checker didn't have a problem with it (it does with #add), so i was curious if %if works with variables, predefined variables, and %commands.



Code:
#trigger {^@prompt}  {#if (%line = @prompt) {#gag;%if ("@prompt" = "@prompt",#sayp off,%add counter 1)}}

#var add %add
#trigger {^@prompt}  {#if (%line2 = @prompt) {#gag;%if ("@prompt" = "@prompt",@counter,@add counter 1)}}


@counter sends the value of counter
@add sends %add, i tried making it expand but expand is %expand
the @prompt's are fine.
I asked this question because i tried making a trigger to fire off my prompt which happens to have a space at the end of it
and it was a different trigger similiar to, {@prompt(*)$} i had a problem with the wildcard. *matches Any number of characters*
i tried with regex as i understood some of it and spent a bit learning about but i failed there.




------------------------------------------------------------------------------------------------------------------------------------------
How can i get something like sayp, showp that doesn't set off triggers?
#sayp will set off a trigger

I will likely post an actual script tomorrow, not a bunch of junk but those up there are likely to be in the same situation.



Thanks in advance.


Last edited by Scirkhan on Sun Sep 16, 2007 7:28 pm; edited 1 time in total
Reply with quote
Tech
GURU


Joined: 18 Oct 2000
Posts: 2733
Location: Atlanta, USA

PostPosted: Sun Sep 16, 2007 4:53 pm   
 
I read your post a few times and couldn't quite tell what you were asking. Can you rephrase it, or better yet post an example of some code that isn't working.
_________________
Asati di tempari!
Reply with quote
charneus
Wizard


Joined: 19 Jun 2005
Posts: 1876
Location: California

PostPosted: Sun Sep 16, 2007 11:26 pm   
 
First of all, there is no function %add. Second of all, #ADD must have a command. For instance,

#ADD variable 1

will add 1 to a variable.

Another thing - #IF is the command you want to use in this case.

Code:
#trigger {^@prompt}  {#if (%line = @prompt) {#gag;#if ("@prompt" = "@prompt") {#sayp off;#add counter 1}}
 
#trigger {^@prompt}  {#if (%line2 = @prompt) {#gag;#if ("@prompt" = "@prompt") {@counter;#add counter 1}}


I can't quite explain the difference between #commands and %functions, but I do know how to use them. :P Rule of thumb - #commands will follow a ; or {. %functions will come in the middle of a string... for instance:

#SHOW This is a %if(1=1,true,false) test.

or

#IF (1=1) {#SHOW This is a true test.} {#SHOW This is a false test.}

That's the way I put it - functions in the middle of a string, commands after a ; or { (or even at the beginning).

Charneus

EDIT: By the way, to set your #SAYP or #SHOW to not set off triggers, try this approach:

#T- {Trigger you don't want to set off};#SHOW blah blah blah;#T+ {Trigger you didn't want set off}


Last edited by charneus on Mon Sep 17, 2007 2:34 pm; edited 1 time in total
Reply with quote
Fang Xianfu
GURU


Joined: 26 Jan 2004
Posts: 5155
Location: United Kingdom

PostPosted: Mon Sep 17, 2007 9:44 am   
 
Charneus is right about the difference between commands and functions. Another way to think of it is that every line must begin with a command (a zScript command, or one to send to the MUD). Functions can't be at the beginning of lines.

You cannot have a space between the %if function and its opening bracket - it won't work.

And also, it seems a bit superfluous to do #trig {^@prompt} {#if (%line=@prompt) {}} because the lines this trigger matches will always equal @prompt.
_________________
Rorso's syntax colouriser.

- Happy bunny is happy! (1/25)
Reply with quote
Scirkhan
Apprentice


Joined: 14 Sep 2007
Posts: 167
Location: aztx

PostPosted: Tue Sep 18, 2007 10:44 am   
 
Okay, thanks
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