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
chris123zugg
Apprentice


Joined: 23 Aug 2013
Posts: 175

PostPosted: Mon Apr 16, 2018 7:35 pm   

Capturing randomness
 
I never did get this fixed but i have a similar issue but a bit more complicated only due to the randomness of what is missing and what is showing.
I'll put a bit of it up here:


Code:
[[ O:10 PE:128 HS:116 ]]


I tried this:

Code:
[~[%s(*)%s~]~]

which will capture, but for the life of me i can't get a working script for the random portions of this.


any ideas would be appreciated, thanks
Reply with quote
shalimar
GURU


Joined: 04 Aug 2002
Posts: 4662
Location: Pensacola, FL, USA

PostPosted: Tue Apr 17, 2018 3:28 am   
 
#TR {~[~[ O:(%d) PE:(%d) HS:(%d) ~]~]} {
$o=%1
$pe=%2
$hs=%3
//Do more stuff with the above local variables
}
_________________
Discord: Shalimarwildcat
Reply with quote
chris123zugg
Apprentice


Joined: 23 Aug 2013
Posts: 175

PostPosted: Thu Apr 19, 2018 5:45 pm   
 
The problem i'm having is that they aren't there until i cast them, and then if NOT there, to cast them.
How should i go about setting that up as far as capturing using the provided capture i gave above
Reply with quote
shalimar
GURU


Joined: 04 Aug 2002
Posts: 4662
Location: Pensacola, FL, USA

PostPosted: Fri Apr 20, 2018 12:37 pm   
 
If there is nothing there, there will be nothing to capture in the first place so the trigger won't fire...
I'm not sure I understand the issue.
if it's an optional section just use the anonymous variable with a null member: {optional pattern here|}

Perhaps if you show me what you do with a given example of randomness.
_________________
Discord: Shalimarwildcat
Reply with quote
chris123zugg
Apprentice


Joined: 23 Aug 2013
Posts: 175

PostPosted: Fri Apr 20, 2018 12:55 pm   
 
well the place holder is this

Code:
[[ ]]


so literally there are 20+ items that could be inside those brackets
I'm trying to find the 'best' way to format a script that can capture each one, and them make further scripts off them

for example:
Code:
[[ O:10 PE:128 HS:116 ]]


the O:10 is a song called 'o muse' of which i have a variable made for when i cast it to on, and when it ends there is a message i set the variable to off.
however it would be MUCH simpler and easier if i could get that to work with a capture with the above caption.

i DID try this though to no avial, as it repeated too often and on too many things so it made what i needed impossible, or i just dont know hw to properly write the script

Code:
[~[%s(*)%s~]~]

[code]#IF %match(%1, "O") {bard.omuse=on} <--- which works, but i couldn't find a way to capture the timer with it!!!

so i tried this:

[code][~[%s(%w)~:(%d)%s~]~] [/code]
and i ticked the repeat within line box to see if it would work, and it did work, however it caused looping, and also rewriting of the variable i set for that!
so i tried this:
[code][~[%s(%w)~:(%d)%s~]~] [/code]
bard.skilln=%1
bard.skillt=%2
#IF (@bard.skilln=="O") {whats the point, again it has no timer!!!}
so yeah, if you could help me get a working script to capture the name of the skill and then the time as well i would be all set!
thanks again for your help!
Reply with quote
shalimar
GURU


Joined: 04 Aug 2002
Posts: 4662
Location: Pensacola, FL, USA

PostPosted: Fri Apr 20, 2018 2:39 pm   
 
#TR {~[~[(*)~]~]} {
$list=%replace(%trim(%1), " ", "|")
//needs to do more
}

That pattern should fire weather there is anything inside the brackets or not.
%trim will turn the whitespace into a null value when empty
the %replace will turn whatever is left into a stringlist with each of your timers.

in the above example you would end up with:

$list=O:10|PE:128|HS:116
_________________
Discord: Shalimarwildcat
Reply with quote
shalimar
GURU


Joined: 04 Aug 2002
Posts: 4662
Location: Pensacola, FL, USA

PostPosted: Fri Apr 20, 2018 2:56 pm   
 
Code:
#FORALL $list {
  #SWITCH (%match(%i, "O:(%d)", $timer)) {
    bard.omuse=on
    //the timer is in $timer
    }
    (%match(%i, "PE:(%d)", $timer)) {
    //whatever this one does
    //the timer is still $timer
    }
  }


Just expand that out to cover all the possible timers it can hold
_________________
Discord: Shalimarwildcat
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