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
Private
Adept


Joined: 10 Jan 2002
Posts: 264
Location: USA

PostPosted: Sat Apr 09, 2005 1:42 pm   

#DELITEM and (a|1)|(b|2) stringlists
 
i have a variable containing (a|1)|(b|2)|(c|3) type of list. i.e mob|area

i have 2 variables with mob and area stored in em,

what i wanna do is #DELITEM @moblist {@mob|@area}

where mob=b and area=2 i.e. the (b|2) portion of the list

anyone know the correct syntax?


Last edited by Private on Tue Apr 12, 2005 7:04 am; edited 2 times in total
Reply with quote
Theragil
Apprentice


Joined: 13 Feb 2004
Posts: 157
Location: USA

PostPosted: Sat Apr 09, 2005 5:37 pm   
 
Hmm, why not use a database variable instead? Seems more straightforward.

I'm not sure if your listvar isn't really (a and then 1) and so on. In which case, #delitem {(@mob} ; #delitem {@area)} maybe?
Reply with quote
MattLofton
GURU


Joined: 23 Dec 2000
Posts: 4834
Location: USA

PostPosted: Sat Apr 09, 2005 9:30 pm   
 
Quote:

(a|1)|(b|2)|(c|3)


Theragil, these are called nested lists. They occur when you try to add more than one item at a time to a list via #ADDITEM or %additem(). ZMud puts parentheses around the entire list as a way to remember this.

Private, have you tried including the parentheses in your #DELITEM command? Also, I do believe you do NOT use the @ for the list variable you're wanting to delete things from.

#DELITEM moblist "(@mob|@area)"
_________________
EDIT: I didn't like my old signature
Reply with quote
Private
Adept


Joined: 10 Jan 2002
Posts: 264
Location: USA

PostPosted: Sat Apr 09, 2005 11:40 pm   
 
Solved it with:

Moblist = %delitem( @last_target|@current_zone, @MobList)

:)
Private

P.S.

#DELITEM moblist "(@last_target|@current_zone)"

didnt work either, but in this instance %delitem works better as i would only want it to remove 1 occurence of it (as in some can be dupes)

But i would like to learn how to use #DELITEM in such an instance for future reference :P
Reply with quote
megamog75
Enchanter


Joined: 20 Nov 2002
Posts: 627
Location: USA

PostPosted: Sat Apr 09, 2005 11:59 pm   
 
no syntax but you could write a script to take it out for you.
Something like this maybe :

#var test {(a|1)|(b|2)|(c|3)}
#alias rem {#loop 1,%numitems(@test) {#var test1 %item(@test,%repeatnum);#addi test2 %item(@test1,2);#show @test2}}
_________________
megamog75 Smile
I will do this.Nothing in my life matters except this.No moment in my life exists except this moment.I am born in this moment, and if I fail, I will die in this moment. Raistlin Majere
Reply with quote
Private
Adept


Joined: 10 Jan 2002
Posts: 264
Location: USA

PostPosted: Sun Apr 10, 2005 12:05 am   
 
tried

rem a|1

outputted:
1 a|1
1|2 a|1
1|2|3 a|1

then

#show @test gives:
(a|1)|(b|2)|(c|3)


then did rem (a|1)

outputted:

1|2|3 (a|1)
1|2|3 (a|1)
1|2|3 (a|1)

#show @test gives:
(a|1)|(b|2)|(c|3)

am i not understanding the useage of "rem" ?
Reply with quote
MattLofton
GURU


Joined: 23 Dec 2000
Posts: 4834
Location: USA

PostPosted: Sun Apr 10, 2005 5:41 am   
 
Did you know exactly where the one was that you wanted to take out? If so, you might find it easier to work with #DELNITEM rather than #DELITEM or %delitem().
_________________
EDIT: I didn't like my old signature
Reply with quote
Private
Adept


Joined: 10 Jan 2002
Posts: 264
Location: USA

PostPosted: Mon Apr 11, 2005 10:43 am   
 
naa, no clue, it is a list of mobs|areas that i kill in different orders, thus i dunno which item # it is.

I have ran into another problem now when selecting which to delete,

the mobname in:
(mobname1|room1)|(mobname2|room2)|(mobname3|room3)
stays constant, but these are MOBiles :P so if i kill mobname2 in a room other then room2, then i now need a way to delete (mobname2|room2) when room2b wont match room2
Reply with quote
Theragil
Apprentice


Joined: 13 Feb 2004
Posts: 157
Location: USA

PostPosted: Mon Apr 11, 2005 12:41 pm   
 
I've never used nested lists (obviously!), and I'm still wondering why not just use a database variable and be done with it. I can see a point to nested lists if the inner lists are actually lists (varying length, consistent meaning); but if they're just tuples, it's acting like a database variable without using the functions that handle them. That'd also solve that last problem, since you'd be indexing on the mobname, not the whole pair.
Reply with quote
Private
Adept


Joined: 10 Jan 2002
Posts: 264
Location: USA

PostPosted: Mon Apr 11, 2005 1:53 pm   
 
i like scripting things that friends can easily import, dont really care how hard it is to script, it's a pain trying to show someone how to set up a database when they can just import a text file :P
Reply with quote
Theragil
Apprentice


Joined: 13 Feb 2004
Posts: 157
Location: USA

PostPosted: Mon Apr 11, 2005 2:34 pm   
 
No, it's no more difficult at all. Just replace your #additem commands with #addkey, your #delitem commands with #delkey, and your %ismember() calls with %db(). Everything is a simple one-to-one mapping and the data is still stored in a variable, just a "Data record" variable instead of a "String list" variable.
Reply with quote
Private
Adept


Joined: 10 Jan 2002
Posts: 264
Location: USA

PostPosted: Mon Apr 11, 2005 3:00 pm   
 
so we aren't talking about needing a database set up with fields in it?
Reply with quote
Theragil
Apprentice


Joined: 13 Feb 2004
Posts: 157
Location: USA

PostPosted: Mon Apr 11, 2005 3:05 pm   
 
No, just a database variable.
Reply with quote
Theragil
Apprentice


Joined: 13 Feb 2004
Posts: 157
Location: USA

PostPosted: Mon Apr 11, 2005 3:10 pm   
 
Try this:
#var dbMobsKilled ""
#addkey dbMobsKilled frog12345 room2345
#addkey dbMobsKilled toad34567 room122
#if (%iskey(@dbMobsKilled,"frog12345")) {#echo Frog was killed in room %db(@dbMobsKilled,"frog12345")}

See what I mean?
Reply with quote
Private
Adept


Joined: 10 Jan 2002
Posts: 264
Location: USA

PostPosted: Mon Apr 11, 2005 3:28 pm   
 
ahh, thanks, ill give that a go :)

cool...
#if (%iskey(@dbMobsKilled,"frog12345")) {#echo Frog was killed, original room: %db(@dbMobsKilled,"frog12345");#delkey dbMobsKilled frog12345} {#SHOW Frog Not There}

1st time: Frog was killed, original room: room2345
2nd time: Frog Not There
Reply with quote
MattLofton
GURU


Joined: 23 Dec 2000
Posts: 4834
Location: USA

PostPosted: Tue Apr 12, 2005 12:06 am   
 
Just remember that unlike stringlists Zugg uses a special unprintable character to separate items. You won't be able to simply concatenate things to the end of the db variable or do any of the other stringlist functions (ie, additem).

Oh, and one last tip, if you work with the db variable in the Settings Editor do not ever EVER!!! click on the Stringlist button. Doing so will turn all those special unprintable characters to pipes and ZMud will forever display it as a stringlist, making all your meaningful interaction with it take place in code (easy enough, but it's sometimes easier/useful to do it via the editor.)
_________________
EDIT: I didn't like my old signature
Reply with quote
Private
Adept


Joined: 10 Jan 2002
Posts: 264
Location: USA

PostPosted: Tue Apr 12, 2005 7:02 am   
 
hrm... this is a tad finiky...

when triggerd from

#TRIGGER {Congratulations, that was one of your campaign mobs} {#show Deleting;#delkey MobList @last_target}

it show deleting... but doesnt

if i do a #SHOW Congratulations, that was one of your campaign mobs
after the 1st one, it then deletes.

or if i manually type "#delkey MobList @last_target" it deletes.

the trigger has deleted it once out of 12 tries, the rest i hadda repeat the #DELKEY command
Reply with quote
Theragil
Apprentice


Joined: 13 Feb 2004
Posts: 157
Location: USA

PostPosted: Tue Apr 12, 2005 4:59 pm   
 
I haven't had problems like that and I use them extensively, which makes me think there's something wrong there: perhaps the variable doesn't hold what you think it holds at the moment the trigger fires, or the database doesn't, or something. Some debug #show commands might be in order before you conclude this is some unavoidable zMUD bug.

I can't say I've ever converted a database variable into a stringlist, but if I had, I'd just write a one-liner to rebuild the one from the other. #forall and #addkey.
Reply with quote
Private
Adept


Joined: 10 Jan 2002
Posts: 264
Location: USA

PostPosted: Wed Apr 13, 2005 10:30 am   
 
Ok, i edited the "Congratulations, that was one of your CAMPAIGN mobs~!" trigger to read:

#CLASS auto_find 1
#show Moblist before: @moblist
#show Last Target: @last_target
#delkey MobList {@last_target}
#show Moblist after: @moblist
#CLASS auto_find 0

What follows is the mud and zmud #show output:

Your punch <>*<> FISSURES <>*<> General Saede! [152]
General Saede crumbles as he is battered to death!!
You receive 35+4 experience points.
Congratulations, that was one of your CAMPAIGN mobs!
General Saede spills his guts all over the floor.
You get Official papers from the battered corpse of General Saede.
You get 638 gold coins from the battered corpse of General Saede.

2030/2075Hp 1432/1635Ma 1971/1971Mv - T:0 $310070 ±-658 Tnl:919 Qt:24
Autospell ON

Moblist before: a heavily built goblin guardThe Goblin Fortressa Whitecloak patrolCity of Amadora young poetThe Three Pillars of DiatzYin Sister of YangJenny's Taverna member of the Draco Flying CavalryCastle Vlad-ShamirA ServantThe Great City of Knossosa Fortune TellerThe Tournament of Illoriaa red ballCity of Amadora larvaLower Planesthe Magma WyrmThe Killing FieldsThe Pale RiderThe Killing Fieldsa spirit of the deadRuins of Diamond ReachValkur's lab guardCastle Vlad-Shamir

Last target: General Saede

0.35 exp per second for 14 seconds.

Moblist after: a heavily built goblin guardThe Goblin Fortressa Whitecloak patrolCity of Amadora young poetThe Three Pillars of DiatzYin Sister of YangJenny's Taverna member of the Draco Flying CavalryCastle Vlad-ShamirA ServantThe Great City of Knossosa Fortune TellerThe Tournament of Illoriaa red ballCity of Amadora larvaLower Planesthe Magma WyrmThe Killing FieldsThe Pale RiderThe Killing Fieldsa spirit of the deadRuins of Diamond ReachValkur's lab guardCastle Vlad-Shamir

(Group) Private: 'I did 3435 damage 100% to that mob! (Others did 0 damage 0%). General Saede did 45 damage to the group 45 of it to me! CounterStrikes: 0 Oh, i missed 1 times.'

2030/2075Hp 1407/1635Ma 1971/1971Mv - T:0 $310070 ±-658 Tnl:919 Qt:24

General Saede is still there and the trigger obviosly fired cause we see the debug #SHOW's and @last_target is correct from the SHOW and my grouptell trigger, i then manually entered onto the command line:
#DELITEM moblist @last_target;#show Moblist now: @moblist

Moblist now: a heavily built goblin guardThe Goblin Fortressa Whitecloak patrolCity of Amadora young poetThe Three Pillars of DiatzYin Sister of YangJenny's Taverna member of the Draco Flying CavalryCastle Vlad-ShamirA ServantThe Great City of Knossosa Fortune TellerThe Tournament of Illoriaa red ballCity of Amadora larvaLower Planesthe Magma WyrmThe Killing FieldsThe Pale RiderThe Killing Fieldsa spirit of the deadRuins of Diamond ReachValkur's lab guardCastle Vlad-Shamir

General Saede is now gone. this happens consistantly, i always have to enter the command a second time to see results :P

I'm assuming the #SHOW @moblist looks funny because it is a database record and has those unprintable characters in it.
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