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
DarkBeo
Newbie


Joined: 17 Mar 2003
Posts: 4
Location: Brazil

PostPosted: Wed Mar 26, 2003 3:31 pm   

Problems with #if
 
#Trigger {^Reward of (&qps) quest points added.$} {} Campaign
#Trigger {^Reward of (&tps) trivia point added.$} {} Campaign
#Trigger {^Reward of (&trains) training session added.$} {} Campaign
#Trigger {^Reward of (&pracs) pracing session added.$} {} Campaign
#Trigger {^Reward of (&golds) gold coins added.$} {} Campaign

#Trigger {CONGRATULATIONS! You have completed your campaign.} {Say #if (@qps > 0) {@qps Qps,},;#if (@tps > 0) {@tps Tp,};#if (@trains > 0) {@trains trains,};#if (@pracs > 0) {@pracs pracs,}; #if (@gold > 0) {@gold Coin} added.} Campaign

how I can send for the "Say" all #if in an only line?
Example:
say Reward of 30 Qps, 1 trivia, 2 trains, 3 pracs, 2453 gold coin added.
or (if @tps and @pracs = 0)
say Reward of 30 Qps, 2 trains, 2453 gold coin added.

DarkBeo
Reply with quote
Kjata
GURU


Joined: 10 Oct 2000
Posts: 4379
Location: USA

PostPosted: Wed Mar 26, 2003 4:13 pm   
 
This can be done with %concat:
#TRIGGER {CONGRATULATIONS! You have completed your campaign.} {#VAR message "";#IF (@qps > 0) {#VAR message {%concat(@message, @qps, " Qps, ")}};#IF (@tps > 0) {#VAR message {%concat(@message, @tps, " Tp, ")}};#IF (@trains > 0) {#VAR message {%concat(@message, @trains, " trains, ")}};#IF (@pracs > 0) {#VAR message {%concat(@message, @pracs, " pracs, ")}};#IF (@gold > 0) {#VAR message {%concat(@message, @gold, " Coin, ")}};#VAR message {%delete(@message, %len(@message) - 1, 2)};#VAR message {%concat(@message, " added.")};say @message} Campaign

Kjata
Reply with quote
Draxtier
Newbie


Joined: 13 Mar 2003
Posts: 9
Location: Canada

PostPosted: Thu Mar 27, 2003 6:32 pm   
 
quote:

This can be done with %concat:
#TRIGGER {CONGRATULATIONS! You have completed your campaign.} {#VAR message "";#IF (@qps > 0) {#VAR message {%concat(@message, @qps, " Qps, ")}};#IF (@tps > 0) {#VAR message {%concat(@message, @tps, " Tp, ")}};#IF (@trains > 0) {#VAR message {%concat(@message, @trains, " trains, ")}};#IF (@pracs > 0) {#VAR message {%concat(@message, @pracs, " pracs, ")}};#IF (@gold > 0) {#VAR message {%concat(@message, @gold, " Coin, ")}};#VAR message {%delete(@message, %len(@message) - 1, 2)};#VAR message {%concat(@message, " added.")};say @message} Campaign



Is there a reason you couldn't or shouldn't do all of this with %if() functions?

#TRIGGER {CONGRATULATIONS! You have completed your campaign.} {Say %if(@qps > 0,@qps Qps", ")%if(@tps > 0, @tps Tp", ")%if(@trains > 0, @trains trains", ")%if(@pracs > 0, @pracs pracs", ")%if(@gold > 0, @gold Coin", ")added.}

blah
Reply with quote
Kjata
GURU


Joined: 10 Oct 2000
Posts: 4379
Location: USA

PostPosted: Thu Mar 27, 2003 9:57 pm   
 
Yes, it can be done like that. It's just personal preference: I don't like putting functions outside of commands.

Kjata
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