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
meddlesome
Wanderer


Joined: 24 Aug 2012
Posts: 70

PostPosted: Mon Sep 10, 2012 3:55 pm   

[SOLVED] What gives with this #IF?
 
Code:
#if (@counter > 1) {#LOOP 1, @counter {EXAMINE %{i}.CORPSE}} {EXAMINE CORPSE}


counter declared integer

I get a...
Quote:
ERROR: Trigger "ou are awarded &{XP}" fired but did not compile


I just don't want EXAMINE 1.CORPSE going to the MUD. That's ugly code.


Last edited by meddlesome on Mon Sep 10, 2012 4:32 pm; edited 1 time in total
Reply with quote
Rahab
Wizard


Joined: 22 Mar 2007
Posts: 2320

PostPosted: Mon Sep 10, 2012 4:10 pm   
 
Is that the entire trigger? This code isn't using @XP, so I suspect it is not. I don't see anything
obiously wrong with that particular line, but I don't have Cmud on this machine to check whether
it compiles. What makes you think that line is the problem?

It might be best to give the entire trigger so we can see the entire thing. The best way to do
it is to click the XML tab at the bottom of the Package Editor and cut and paste all of the XML.
Reply with quote
meddlesome
Wanderer


Joined: 24 Aug 2012
Posts: 70

PostPosted: Mon Sep 10, 2012 4:15 pm   
 
@XP is used on a statusbar, but It wasn't the trigger line that was an issue. It worked fine when I just had that #LOOP. It started this when I added the #IF to get rid of the EXAMINE 1.CORPSE.
_________________
Intel Core 2 Quad Q9450 @2.66GHz
MDAC 2.8 SP1 ON WINDOWS XP SP3
Msjet40.dll ver 4.0.9511.0 + Security Bulletin MS08-028
CMUD v237
Order number: **7829
Reply with quote
meddlesome
Wanderer


Joined: 24 Aug 2012
Posts: 70

PostPosted: Mon Sep 10, 2012 4:17 pm   
 
It even shows this in the package editor under the compiled code tab...

Quote:
Error compiling script:
illegal character in expression:
Reply with quote
meddlesome
Wanderer


Joined: 24 Aug 2012
Posts: 70

PostPosted: Mon Sep 10, 2012 4:23 pm   
 
Figured it out. The #LOOP 1, @counter was the issue. Seems the variable got moved over a space. #LOOP 1,@counter works.
_________________
Intel Core 2 Quad Q9450 @2.66GHz
MDAC 2.8 SP1 ON WINDOWS XP SP3
Msjet40.dll ver 4.0.9511.0 + Security Bulletin MS08-028
CMUD v237
Order number: **7829
Reply with quote
Anaristos
Sorcerer


Joined: 17 Jul 2007
Posts: 821
Location: California

PostPosted: Thu Sep 13, 2012 12:43 am   
 
Since #LOOP 1,1 {...} does nothing, there is no need to check. If you are going to check at all, check to make sure @counter is not less than 1.
Code:

#IF (@counter) {#LOOP 1,@counter {....}
_________________
Sic itur ad astra.
Reply with quote
Daern
Sorcerer


Joined: 15 Apr 2011
Posts: 809

PostPosted: Thu Sep 13, 2012 2:39 am   
 
Huh? That makes no sense. First of all, #LOOP 1,1 {...} doesn't do nothing, it loops once with 1 as %i, and second, your code doesn't make sure @counter is not less than 1, it just checks that it's not zero. There's nothing wrong with his code (except the fixed syntax error, of course).
Reply with quote
Mumra
Wanderer


Joined: 12 Feb 2003
Posts: 93
Location: USA

PostPosted: Wed Sep 19, 2012 12:56 am   
 
Meddlesome, the #LOOP 1, @counter with a space should work. I use it that way constantly.
Code:
#if (@counter > 1) {#LOOP 1, @counter {EXAMINE %{i}.CORPSE}} {EXAMINE CORPSE}

Is what you have written, why do you have {} around the i? you don't need those at all. just %i.corpse should work, I have a similar set of scripts here myself.
_________________
Mumra the Everliving, Realms of Despair
216.251.47.10 Port 4000
Reply with quote
Daern
Sorcerer


Joined: 15 Apr 2011
Posts: 809

PostPosted: Wed Sep 19, 2012 2:12 am   
 
#LOOP cannot have a space between the range values. Just a simple "#LOOP 1, 10 {}" is enough to prove that - enter it on your command line and you'll see you get an error. The {} is required to have the dot act as a literal rather than the member of operator. %i.CORPSE would look for the CORPSE key in the %i database variable and return the value, which would obviously always be null since %i will always just be a number. Personally, I would write it like this:
Code:
#if (@counter > 1) {#LOOP 1,@counter {#SEND %concat( "EXAMINE ", %i, ".CORPSE")}} {#SEND "EXAMINE CORPSE"}

That's a more reliable way of using the dot literally, but there's nothing wrong with the brace trick to prevent the expansion, especially with simple scripts like this.
Reply with quote
Mumra
Wanderer


Joined: 12 Feb 2003
Posts: 93
Location: USA

PostPosted: Wed Sep 19, 2012 2:22 am   
 
Perhaps the %i isn't checking the database because I do not have one loaded? but I can run for example
#loop 1,5 {examine %i.corpse}

and get
examine 1.corpse
examine 2.corpse
examine 3.corpse
examine 4.corpse
examine 5.corpse

I guess it is good to know for the future.. as I'm debating using the DB.
_________________
Mumra the Everliving, Realms of Despair
216.251.47.10 Port 4000
Reply with quote
Daern
Sorcerer


Joined: 15 Apr 2011
Posts: 809

PostPosted: Wed Sep 19, 2012 2:50 am   
 
I'm talking about normal key=value pair database variables, not the database module. The var.key syntax was added early in v3, if you're still using 2.37 you wouldn't have this issue.
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