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
megamog75
Enchanter


Joined: 20 Nov 2002
Posts: 627
Location: USA

PostPosted: Tue Jan 14, 2003 7:34 pm   

break up words captued in trigger?
 
Say you have a trigger exp:
#trigger {^~](*)} {#var @sentance %1}
How could I make the trigger break up each of the words in (*)? exp:
promt: [23] you get a lot of squat.
then breaks it up so that 'you' 'get' 'a' 'lot' 'of' 'squat' are all seperate #var
It would have to work when the promt changes to a longer sentance it would get it all or a shor1 word statment
or if not trigger is there another way?


megamog75
Reply with quote
megamog75
Enchanter


Joined: 20 Nov 2002
Posts: 627
Location: USA

PostPosted: Tue Jan 14, 2003 7:43 pm   
 
One more thing is there a way to strip off the '.' at the end of the sentance?

megamog75
Reply with quote
TonDiening
GURU


Joined: 26 Jul 2001
Posts: 1958
Location: Canada

PostPosted: Tue Jan 14, 2003 7:58 pm   
 
Make something like this:

#TRIGGER {^~](*)~'$} {#VARIABLE numwords %numwords( {%1});#VARIABLE sentance "";#LOOP @numwords {#VARIABLE sentance %additem( %word( {%1}, %i), @sentance)}}

All the words are now in a list called @sentance. Changing the trigger to include the trailing ~' makes sure it is stripped.

Ton Diening

Edit: or use the simpler idea by Talahaski
below! ^_^
Reply with quote
Talahaski
Enchanter


Joined: 10 Oct 2000
Posts: 656
Location: USA

PostPosted: Tue Jan 14, 2003 7:59 pm   
 
I'm sure there are a number of ways of doing this.

One command you may want to look at is the %replace. this can help you in removing the "."

I have not tested this, but if you want to split out words, you may want to try this.

Replace all spaces with "|"
This will change the variable into a string list where each word is a seperate entry.

You may also want to remove other punctuation.

So.

#var word_list %replace(%replace({%1},".","")," ","|")

try that and see how it works.

Talahaski
Processor PIII 1000
Memory 265MB
Video NVIDIA 64MB
Windows XP
Zmud Version 6.40
Zmapper Version 1.14
Reply with quote
megamog75
Enchanter


Joined: 20 Nov 2002
Posts: 627
Location: USA

PostPosted: Wed Jan 15, 2003 5:34 am   
 
OK this is what i got so far:
promt: [324 836] a bunch of stuff.
trig: #TRIGGER {^~[(*)](*)} {#VARIABLE numwords %numwords( {%2});#VARIABLE sentance "";#LOOP @numwords {#VARIABLE sentance %additem( %word( {%2}, %i), @sentance)};#var sentance %replace(@sentance,".","")}

what i get: a|bunch|of|stuff
What i need to do next is use this somehow to crate a way to pick anyone of the words.

I have tried #mxp and #sub exp:
#mxp %1~<send "%item("@sentance",1)" "@sentance">%2</send>

but am not getting any resaults,I have tried a buch of variations but nothing has done it, i have gottin reall close.
What i want to do is sub this prompt(numbers and words wildcards:
[23 546] a whole lot of stuff.
#sub or #mxp so i get:
23 546 a whole lot of stuffstripping the "." then when i click this hyper link I can choose to buy one of the key words.

Please help, I know someone reading this can help me.

megamog75
Reply with quote
Kjata
GURU


Joined: 10 Oct 2000
Posts: 4379
Location: USA

PostPosted: Thu Jan 16, 2003 12:53 am   
 
Try this:
#TRIGGER {~[(*)~] (*).} {#VAR words {%replace("%2", " ", "|")};#VAR commands "";#FORALL @words {#VAR commands {%additem(%concat("buy ", %i), @commands)}};#SUB {%concat("~[", %1, "~] <send ", %char(34), @commands, %char(34), " hint=", %char(34), "Right-click for options|", @words, %char(34), ">", %2, "</send>.")}}

Kjata
Reply with quote
megamog75
Enchanter


Joined: 20 Nov 2002
Posts: 627
Location: USA

PostPosted: Thu Jan 16, 2003 1:13 am   
 
Ok this works great I had to add Talahaski replace script where Kjata's was but now it works well for me, If I run into any problems I will post it here and in finished scrpits where I am placing this.

#CLASS {betterlist}
#ALIAS words {}
#ALIAS commands {}
#TRIGGER {~[(*)~] (*)} {#VAR words {%replace(%replace({%2},".","")," ","|")};#VAR commands "";#FORALL @words {#VAR commands {%additem(%concat("buy ", %i), @commands)}};#SUB {%concat("<send ", %char(34), @commands, %char(34), " hint=", %char(34), "Right-click for options|", @words, %char(34), ">[", %1, "] ", %2, "</send>")}}
#CLASS 0

Thanks for everyones help.

megamog75
Reply with quote
megamog75
Enchanter


Joined: 20 Nov 2002
Posts: 627
Location: USA

PostPosted: Thu Jan 16, 2003 2:45 am   
 
One last thing ,is there a way using the above script to keep the spacing the same in the: [324 2354]or[ 3 98798]
tried using %s but that only made things wors tried a couple of things actually but i got it so messed up i crased zmud and had to start over. Please help

megamog75
Reply with quote
Kjata
GURU


Joined: 10 Oct 2000
Posts: 4379
Location: USA

PostPosted: Thu Jan 16, 2003 2:56 am   
 
Try surrounding the %1 in the #SUB with double quotes.

Kjata
Reply with quote
megamog75
Enchanter


Joined: 20 Nov 2002
Posts: 627
Location: USA

PostPosted: Thu Jan 16, 2003 3:51 am   
 
OK the double qouts did not work they just got added to the line, but that is a small thing really, Here is a bigger problem:
[23 243] de'fault
de'fault was not on the list in the right hand click. And is there away to make it so each hyper line has its own list when you click on the right or is it always like that?


megamog75
Reply with quote
megamog75
Enchanter


Joined: 20 Nov 2002
Posts: 627
Location: USA

PostPosted: Thu Jan 16, 2003 5:37 am   
 
OK forget about the spacing I can live with it but htis problem has to be worked out,
when I type list i get :

[ 5 446] A black pearl.
[ 5 26769] An expensive-looking pocket watch.
[ 4 55] A fine silk doublet.
[ 4 4461] A woolen shawl.
[ 3 1115] A chef's apron.
[ 3 44] Black pants.
[ 1 111] A polished shield of heartwood.

If i right click on the bottom one i get it the right way but if i click on the one above it I get what i got for the first one i metioned then if i click on the third one from the bottem i get:
buy a
buy polished
buy shield
buy of
buy darkwood
buy apron

clicking on any of the ones above that will only return that and every last word in every sentance.

is there a way that so after every trigger it clears the @ver out?

Also this is what i am working with:
#TRIGGER {^~[(*)~] (*)} {#VAR words {%replace(%replace({%2},".","")," ","|")};#VAR commands "";#FORALL @words {#VAR commands {%additem(%concat("buy ", %i), @commands)}};#SUB {%concat("<send ", %char(34), @commands, %char(34), " hint=", %char(34), "Right-click for options|", @words, %char(34), ">[ %1 ] ", %2, "</send>")}}

I added a "^" to the trigger to help ancor it

megamog75
Reply with quote
megamog75
Enchanter


Joined: 20 Nov 2002
Posts: 627
Location: USA

PostPosted: Thu Jan 16, 2003 7:47 am   
 
In the end none of that seemed to work but I did make this little thing and it seems to do the job I even tried it out in the mud before i posted it here!

#VAR commands {}
#VAR words {A|ceremonial|blade.}
#TRIGGER {^~[(*)] (*)} {#gag
#VAR words {%replace("%2", " ", "|")}
#mxp (%1) <send "buy %item(@words,1)|buy %item(@words,2)|buy %item(@words,3)|buy %item(@words,4)|buy %item(@words,5)|buy %item(@words,6)" "buy">%2</send>

If anyone can get it to #sub instead of the #gag i used I would really appreciate it

megamog75
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