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
Aldur
Beginner


Joined: 16 Sep 2003
Posts: 16
Location: Sweden

PostPosted: Wed Nov 26, 2003 4:22 pm   

Help with some subs
 
When I use a script I've made I get a funny result.

The script looks like this:
Code:

#if (@wellsubs) {
  #var submob %concat( "%1")
  #if (%ismember( @submob, @wellmobs)) {
    #var subvuln {%proper( %db( %find( @submob, LDesc), "Vuln"))}
    #var subres {%proper( %db( %find( @submob, LDesc), "Invuln"))}
    #var subagg {%proper( %db( %find( @submob, LDesc), "Aggr"))}
    #var subspec {%proper( %db( %find( @submob, LDesc), "Spec"))}
    #var subslay {%proper( %db( %find( @submob, LDesc), "Race"))}
    #var subtemp {%ansi( yellow)Mob: %ansi( white)%proper( %db( %find( @submob, LDesc), "Name"))}
    #if (@subvuln) {#var subtemp %concat( @subtemp, " %ansi( green)- %ansi( yellow)Vuln:%ansi( white) ", @subvuln)}
    #if (@subres) {#var subtemp %concat( @subtemp, " %ansi( green)- %ansi(yellow)Resist:%ansi( white) ", @subres)}
    #if (@subagg) {#var subtemp %concat( @subtemp, " %ansi( green)- %ansi(yellow)Agressive:%ansi( white) ", @subagg)}
    #if (@subspec) {#var subtemp %concat( @subtemp, " %ansi( green)- %ansi(yellow)Special:%ansi( white) ", @subspec)}
    #if (@subslay) {#var subtemp %concat( @subtemp, " %ansi( green)- %ansi(yellow)Slay:%ansi( white) ", @subslay)}
    #sub @subtemp
    }
  }


The result looks like this:
Code:

Mob: Roper - Vuln: Unlife - Agressive: Yes - Special: Str-drain(1) {
  #var submob
  #if (64) {
    #var subvuln {Unlife}
    #var subres {}
    #var subagg {Yes}
    #var subspec {Str-drain}
    #var subslay {}
    #var subtemp {Mob: Roper}
    #if (Unlife) {#var subtemp Mob: Roper - Vuln: Unlife - Agressive: Yes - Special: Str-drain %ansi( green)- %ansi( yellow)Vuln:%ansi( white) Unlife}
    #if () {#var subtemp Mob: Roper - Vuln: Unlife - Agressive: Yes - Special: Str-drain %ansi( green)- %ansi(yellow)Resist:%ansi( white) }
    #if (Yes) {#var subtemp Mob: Roper - Vuln: Unlife - Agressive: Yes - Special: Str-drain %ansi( green)- %ansi(yellow)Agressive:%ansi( white) Yes}
    #if (Str-drain) {#var subtemp Mob: Roper - Vuln: Unlife - Agressive: Yes - Special: Str-drain %ansi( green)- %ansi(yellow)Special:%ansi( white) Str-drain}
    #if () {#var subtemp Mob: Roper - Vuln: Unlife - Agressive: Yes - Special: Str-drain %ansi( green)- %ansi(yellow)Slay:%ansi( white) }
    #sub Mob: Roper - Vuln: Unlife - Agressive: Yes - Special: Str-drain
}
  }

This is quite spammy, since all these lines fill up the mud window quite fast. I've been looking at it for half an hour now without seeing anything.

when it should look like:
Mob: Roper - Vuln: Unlife - Agressive: Yes - Special: Str-drain

The subtemp variable that it reports looks like
Variable: subtemp Mob: Roper - Vuln: Unlife - Agressive: Yes %ansi( green)- %ansi( yellow)Special:%ansi( white) Str-drain

the first part is colored, but the second half doesn't seem to get its color.
Reply with quote
Aldur
Beginner


Joined: 16 Sep 2003
Posts: 16
Location: Sweden

PostPosted: Wed Nov 26, 2003 10:47 pm   
 


Thats how it looks like.

Forgot to mention that the pattern is a simple (*)

Edit:

I Think I've isolated it to the #sub command, as it works perfectly with #show... except for the obvious fact that the old line isn't replaced then.
Reply with quote
MattLofton
GURU


Joined: 23 Dec 2000
Posts: 4834
Location: USA

PostPosted: Thu Nov 27, 2003 2:26 am   
 
It's true that #SUB is a slower, more intensive command than #SHOW, but this problem is basically because of your trigger pattern itself (it's moreso from the actual number of times it matches and how intensive the trigger code is, not how easy/difficult it is to figure out whether the pattern matches or not). You're using (*), which matches at least nine lines in the above image and possibly as many as 13 times. Each of these 13 matches causes your script to update 6 variables, execute 5 conditional checks, and post up the results of a 7th variable. Even with the fast process times for triggers, that's a lot of work in a very short amount of time.

I can easily reproduce this with an entirely different trigger, as that trigger dumps code 100% of the time in only one instance that I've ever found (a double prompt wherein I have to take apart and translate a 64-digit hex number).
Reply with quote
Aldur
Beginner


Joined: 16 Sep 2003
Posts: 16
Location: Sweden

PostPosted: Thu Nov 27, 2003 8:57 am   
 
I can appriciate that, but (*) is the only way I know to match it to all the mobs in the database (By comparing them to a stringlist i've made, but maybe Its just as good with #if(%find( "%1", LDesc)).

#if (%find( "%1", LDesc)) {
#su {Mob: %db( %find( "%1", LDesc), "Name")}
}

Even when I just use that, I get basically the same result, and I am all out of ideas.
Reply with quote
mr_kent
Enchanter


Joined: 10 Oct 2000
Posts: 698

PostPosted: Thu Nov 27, 2003 4:02 pm   
 
quote:
Originally posted by Aldur
[brI Think I've isolated it to the #sub command, as it works perfectly with #show... except for the obvious fact that the old line isn't replaced then.



So, capture everything to variables, #GAG the line, and #SHOW the information with whatever formatting you like?
Reply with quote
Aldur
Beginner


Joined: 16 Sep 2003
Posts: 16
Location: Sweden

PostPosted: Thu Nov 27, 2003 5:01 pm   
 
Then it looks very very ugly, cause the #show appears a few lines down.
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