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

Play RetroMUD
Post new topic  Reply to topic     Home » Forums » CMUD General Discussion
Orang
Apprentice


Joined: 22 Jul 2004
Posts: 118
Location: USA

PostPosted: Mon Aug 04, 2008 9:13 pm   

EDIT: Script help
 
I am trying to use this script:

#class MoneyMaker
#var cashonhand_plat {}
#var cashonhand_gold {}
#var cashonhand_silver {}
#alias cashonhand {#prompt cashonhand_plat "What would you like your cash-on-hand for platinum to be?";#prompt cashonhand_gold "What would you like your cash-on-hand for gold to be?";#prompt cashonhand_silver "What would you like your cash-on-hand for silver to be?"}
#alias moneymaker {#T+ olympus;tel olympus}
#trigger "olympus" {(*)} {#if (%w = A Large Hall ~[up, s, ne, nw, se, sw~]) {pry helmet;pry brooch;pry thunderbolt;pry laurels;pry trident;pry skull;get all;tel harlin;#T- olympus;#T+ harlin} {tel olympus}} case|disable
#trigger "harlin" {(*)} {#if (%w = Harlin~'s General Store ~[out~]) {sell helmet to harlin;sell brooch to harlin;sell thunderbolt to harlin;sell laurels to harlin;sell trident to harlin;sell skull to harlin;#T- harlin;#T+ bank} {tel harlin}} case|disable
#trigger "bank" {(*)} {#if (%w = Bank Lobby ~[n, out, office~]) {deposit all;balance;#if (cashonhand_plat > 0) {withdraw @cashonhand_plat} {#echo No platinum on-hand.};#if (cashonhand_gold > 0) {withdraw @cashonhand_gold} {#echo No gold on-hand.};#if (cashonhand_silver > 0) {withdraw @cashonhand_silver} {#echo No silver on-hand.};balance;#T- bank} {tel bank}} case|disable
#echo {Thank you for installing my banking script. One moment, please...}
#alarm {+2} {cashonhand}
#class 0

But when I try to put it into CMUD, I get an "illegal character in expression: ," message.
Any help would really be appreciated. Thank you.
Reply with quote
charneus
Wizard


Joined: 19 Jun 2005
Posts: 1876
Location: California

PostPosted: Mon Aug 04, 2008 11:23 pm   
 
First of all, all your phrases need to be encased in quotation marks.

For instance, #if (%w="Bank Lobby [n, out, office]) and not #if (%w= Bank Lobby ~[n, out, office~]) (and no, since it's in quotation marks, you don't need to quote the brackets).

Second, change the #if (%w to #if (%1 since %w is NOT a valid parameter within an #IF statement.

That should set you straight. I haven't tested it myself, but fix those first and come back if you have more problems.

Charneus
Reply with quote
Orang
Apprentice


Joined: 22 Jul 2004
Posts: 118
Location: USA

PostPosted: Tue Aug 05, 2008 2:53 am   
 
The trigger is still not wanting to catch: here's what I changed:


#delclass MoneyMaker
#class MoneyMaker
#var cashonhand_plat {}
#var cashonhand_gold {}
#var cashonhand_silver {}
#alias cashonhand {#prompt cashonhand_plat "What would you like your cash-on-hand for platinum to be?";#prompt cashonhand_gold "What would you like your cash-on-hand for gold to be?";#prompt cashonhand_silver "What would you like your cash-on-hand for silver to be?"}
#alias moneymaker {tel olympus}
#trigger "olympus" {(*)} {#if (%1 = "A Large Hall ~[up~, s~, ne~, nw~, se~, sw~]") {pry helmet;pry brooch;pry thunderbolt;pry laurels;pry trident;pry skull;get all;tel harlin;#t- "olympus"} {#t- "olympus";tel olympus}} {} {case|disable}
#trigger "harlin" {(*)} {#if (%1 = "Harlin~'s General Store ~[out~]") {sell helmet to harlin;sell brooch to harlin;sell thunderbolt to harlin;sell laurels to harlin;sell trident to harlin;sell skull to harlin;#t- harlin;#t+ "bank"} {#t- "harlin";tel harlin}} {} {case|disable}
#trigger "bank" {(*)} {#if (%1 = "Bank Lobby ~[n, out, office~]") {deposit all;balance;#if (cashonhand_plat > 0) {withdraw @cashonhand_plat} {#echo No platinum on-hand.};#if (cashonhand_gold > 0) {withdraw @cashonhand_gold} {#echo No gold on-hand.};#if (cashonhand_silver > 0) {withdraw @cashonhand_silver} {#echo No silver on-hand.};balance;#t- "bank";#t- "olympus";#t- "harlin"} {#t- "olympus";#t- "harlin";#t- "bank";tel bank}} {} {case|disable}
#echo {Thank you for installing my banking script. One moment, please...}
#alarm {+2} {cashonhand}
#class 0
Reply with quote
charneus
Wizard


Joined: 19 Jun 2005
Posts: 1876
Location: California

PostPosted: Tue Aug 05, 2008 3:01 am   
 
You missed the point where I said you don't need to quote the brackets since you are quoting the whole string. Remove the tildes in the entire thing.

But... why are you doing it that way? It's really ridiculous. Instead of doing #if statements like that, you really should put the trigger as this:

#TRIGGER "Olympus" {A Large Hall ~[up, s, ne, nw, se, sw~]} {pry helmet;pry brooch;pry thunderbolt;pry laurels;pry trident;pry skull;get all;tel harlin;#T- "Olympus"}

*shrug* Just a thought.

Charneus
Reply with quote
Orang
Apprentice


Joined: 22 Jul 2004
Posts: 118
Location: USA

PostPosted: Tue Aug 05, 2008 3:06 am   
 
I do that because the teleport isn't always 100% accurate in getting you where you tell it to take you. Otherwise I would have done that :)
Reply with quote
Orang
Apprentice


Joined: 22 Jul 2004
Posts: 118
Location: USA

PostPosted: Tue Aug 05, 2008 3:14 am   
 
Hmm, the way the teleport on this mud works, maybe a multi-line trigger would be best.
How do you make one of those?
Reply with quote
charneus
Wizard


Joined: 19 Jun 2005
Posts: 1876
Location: California

PostPosted: Tue Aug 05, 2008 3:18 am   
 
#TRIGGER {First line here} {Whatever you want it to do (could be nothing, in fact)}
#COND {Second line here} {Whatever you want it to do (could be nothing again, though that defeats the purpose)}

There are different options you can use with #COND as well, such as match the pattern whenever it shows up, within a certain amount of lines, within a certain amount of time, and other things. Take a look at the #COND help file for more information.

Charneus
Reply with quote
Orang
Apprentice


Joined: 22 Jul 2004
Posts: 118
Location: USA

PostPosted: Tue Aug 05, 2008 3:36 am   
 
Ok, i got the first part of it working. Now I think I can get it all working.
Thank you so much.
Reply with quote
Orang
Apprentice


Joined: 22 Jul 2004
Posts: 118
Location: USA

PostPosted: Tue Aug 05, 2008 3:49 am   
 
This is what I came up with, and it works except for one thing: first time testing it out, works just fine. Try it one more time just to double check, stops working.

#delclass MoneyMaker
#class MoneyMaker
#var cashonhand_plat {}
#var cashonhand_gold {}
#var cashonhand_silver {}
#alias cashonhand {#prompt cashonhand_plat "What would you like your cash-on-hand for platinum to be?";#prompt cashonhand_gold "What would you like your cash-on-hand for gold to be?";#prompt cashonhand_silver "What would you like your cash-on-hand for silver to be?"}
#alias moneymaker {tel olympus;#t+ end_teleport}
#trigger "end_teleport" {^The blue light fades away, leaving you elsewhere.$} {} {} {case|disable}
#cond {^A Large Hall} {pry helmet;pry brooch;pry thunderbolt;pry laurels;pry trident;pry skull;get all;tel harlin} {}
#cond {^Harlin's General Store} {sell helmet to harlin;sell brooch to harlin;sell thunderbolt to harlin;sell laurels to harlin;sell trident to harlin;sell skull to harlin;tel bank} {}
#cond {^Bank Lobby} {deposit all;balance;#if (cashonhand_plat > 0) {withdraw @cashonhand_plat} {#echo No platinum on-hand.};#if (cashonhand_gold > 0) {withdraw @cashonhand_gold} {#echo No gold on-hand.};#if (cashonhand_silver > 0) {withdraw @cashonhand_silver} {#echo No silver on-hand.};balance;#t- "end_teleport"} {}
#echo {You have installed the money-making script. One moment, please...}
#alarm {+2} {cashonhand}
#class 0
Reply with quote
Rahab
Wizard


Joined: 22 Mar 2007
Posts: 2320

PostPosted: Tue Aug 05, 2008 4:46 pm   
 
My guess is that you expect a multistate trigger to act differently than it does. The initial trigger, in your case "The blue light fades...", is state 0. When it is in state 0, it will keep testing for the next state, "A Large Hall". When that matches, it will go to state 1, and test for the next state, "Harlin's General Store". And so on. It won't test for state 2 until it is in state 1.

From your earlier description, your teleport will put you into one of several rooms, and you need a trigger(s) to tell which one it is. A multistate trigger is not what you need for that. Your original triggers were testing for *, which means they matched everything, and then you tested whether that thing was what you wanted. As Charneus said, that's rather inefficient; triggers are designed precisely to do that testing right up front. So, instead of having (*) as your trigger, put in the actual text you want to match.
Reply with quote
Display posts from previous:   
Post new topic   Reply to topic     Home » Forums » CMUD 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