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
lofor
Newbie


Joined: 04 Apr 2010
Posts: 4

PostPosted: Sun Apr 04, 2010 4:45 am   

Script to give same effect as old zmud plugin
 
Basicly what im looking to do is create the same effect in cmud as we currently get on wotmud in zmud using a plugin called spinning timer.

What the plugin does is seems to parse the -=+**+=- -= apart on the line so we can see how far through out timer we are for bash/charge/backstab etc.
Without the plugin it just runs at the start of the line ontop of each other.

Does anyone have any idea how you would go about creating this effect in cmud?


Using the plugin
A cute brown deer eyes you nervously.
A rust-colored bobcat crouches low, ready to pounce.
A young and strong buck is here, munching some grass.

* R HP:Healthy MV:Strong > bash cat
-=+**+=- -=
Your bash at a bobcat sends him sprawling!




Without the plugin
bash rat
-
A black cat has arrived from the west.

=
A rat stops following you.
Your bash at a rat sends it sprawling!
Reply with quote
MattLofton
GURU


Joined: 23 Dec 2000
Posts: 4834
Location: USA

PostPosted: Sun Apr 04, 2010 7:09 pm   
 
You really shouldn't ask questions in a manner that assumes we know what specific plugin or script you are talking about. And give better details, we don't even know how long a bash timer is nor do we know what each of the symbols used represent.
_________________
EDIT: I didn't like my old signature
Reply with quote
Rahab
Wizard


Joined: 22 Mar 2007
Posts: 2320

PostPosted: Mon Apr 05, 2010 1:00 am   
 
This looks like a visual display in which the mud sends out a sequence of characters separated by a backspace character, in a timed series, so that the successive characters appear on top of each other, giving an animated appearance. It sounds like this plugin simply removed the backspace character, so that the characters appear one after another, giving more of a linear graphic display of passage of time. Does this sound right, lofor?

If that's what you want, it should be trivial to strip out the backspace characters from the sequence. There are other more elaborate solutions we could come up with as well. For instance, if you know how many animated characters a bash pauses, you could display it in a gauge, with the bar stepping steadily to the end with every charactar from the mud.
Reply with quote
lofor
Newbie


Joined: 04 Apr 2010
Posts: 4

PostPosted: Mon Apr 05, 2010 2:17 am   
 
Yep that sounds right I think rehab. Basicly anything we do that involves a timer has this sequence of characters of varying length.

Mud is running off circlemud if thats any help.

Asked a few people on the mud and they said it "Removes CR-Null sequences" is that a backspace?
Reply with quote
Rahab
Wizard


Joined: 22 Mar 2007
Posts: 2320

PostPosted: Mon Apr 05, 2010 5:49 pm   
 
I've never heard of "CR-Null sequences". A backspace is ASCII 8. Unfortunately, I've just tested and it seems it is impossible to set a trigger on a backspace character, or replace a backspace character with %replace. It is easy to insert a backspace character with %char(8). So, this problem might be trickier than I thought. Any ideas from anyone else?
Reply with quote
Martaigne
Wanderer


Joined: 05 Jan 2002
Posts: 88
Location: Atlanta, GA

PostPosted: Mon Apr 05, 2010 6:21 pm   
 
I think he's referring to a carriage return character (ASCII 13), without the line feed (ASCII 10). It would return the cursor/prompt to the beginning of the same line rather than to the beginning of the next line.
_________________
Unwritten Legends
Reply with quote
Rahab
Wizard


Joined: 22 Mar 2007
Posts: 2320

PostPosted: Mon Apr 05, 2010 8:20 pm   
 
Ah, that would make sense, yes, and would produce the same visual effect. Unfortunately, I still have the same problem trying to make a trigger or replace pattern work with it. In fact, it appears that Cmud overlays the character before it processes a trigger on it! By the time the trigger goes to work, there is no backspace or CR in the line. To demonstrate:
Code:

#trigger {test} {#say success t}
#trigger {fest} {#say success f}
#show test
#show test%char(13)f

So, I'm afraid there is no way of removing a backspace or carriage-return without linefeed in a trigger. The trigger will never get that ANSI character. We may have to figure out an alternative solution to help lofor.
Reply with quote
MattLofton
GURU


Joined: 23 Dec 2000
Posts: 4834
Location: USA

PostPosted: Mon Apr 05, 2010 9:05 pm   
 
I think there's a preference or something to change the way carriage control is handled, but it seems to have been banished to the obscure reaches of the %pref(NewlineCRLF) function. Since he's only getting CR, perhaps this can be adjusted so that CMud does LF when it gets CR (assuming my understanding of what this pref does is up to snuff). If he's also getting CRLF, that might put in extra lines so he'd have to deal with those too. If that works, we could then probably use a multistate trigger to capture the gauge elements and then handle the display based on those.
_________________
EDIT: I didn't like my old signature
Reply with quote
Martaigne
Wanderer


Joined: 05 Jan 2002
Posts: 88
Location: Atlanta, GA

PostPosted: Tue Apr 06, 2010 1:44 pm   
 
Interestingly, I just noticed that CMUD translates %char(13) into the $ character used by triggers.

I created a trigger with the following pattern: ^[-=+~* ]%char(13)

The Perl Regex translation of this (on the pattern test tab) is: ^[-=\+\* ]+$

I always thought the $ character was for a CRLF, not just CR.

Maybe we can start a trigger with this as the pattern, turn off Trigger on Newline, and either make conditionals or separate triggers or play with the Repeat Within Line options to catch the other characters? Playing with it now.
_________________
Unwritten Legends
Reply with quote
Rahab
Wizard


Joined: 22 Mar 2007
Posts: 2320

PostPosted: Tue Apr 06, 2010 6:34 pm   
 
It "translates" it that way only if it is translating into perl regexp. The translation to perl regexp is not quite perfect. Cmud doesn't translate it that way when it receives an ASCII 13 from the mud, or from the command line. What it does then is move the cursor to the beginning of the line, without a linefeed,, just as ASCII 13 is supposed to do. Unfortunately, any character typed then will replace the character overwritten, and it is the modified line (which no longer contains an ASCII 13) that gets parsed by triggers.
Reply with quote
Rahab
Wizard


Joined: 22 Mar 2007
Posts: 2320

PostPosted: Tue Apr 06, 2010 8:39 pm   
 
Okay, I've done some testing. We may be able to do something; it depends on exactly when the mud is sending the ASCII 13. If the ASCII 13 comes immediately after the punctuation mark, then I don't know what to do. But if the ASCII 13 comes immediately before the _next_ mark, I think we can get a solution.

Lofor, could you run a small test? Execute the following on the commandline to create a test trigger, then on your mud, execute a bash or something else that causes the timer. Be sure it's a timer that has a "+" in it:
Code:
#trigger {+} {#say ASCII 13 is delayed!} "" prompt

If this test produces a message "ASCII 13 is delayed", then the ASCII 13 does not immediately follow the character, and we are in good shape.
Reply with quote
lofor
Newbie


Joined: 04 Apr 2010
Posts: 4

PostPosted: Fri Apr 09, 2010 10:31 am   
 
Hey ran the test and I am getting the ascii 13 is delayed. Sorry for the late responce been busy at work.


Code:
* HP:Scratched MV:Full - a dust-colored gelding: Beaten > bash
*                   
A dust-colored gelding tickles your body with his hit.

+ASCII 13 is delayed!
=
Your bash at a dust-colored gelding sends him sprawling!
Reply with quote
Rahab
Wizard


Joined: 22 Mar 2007
Posts: 2320

PostPosted: Fri Apr 09, 2010 1:48 pm   
 
Excellent! That means you could make a set of triggers, or a multitstate trigger, to catch the individual characters as they display, before they get overwritten. You could either do a #SUB to display a line of the right length, or change a variable which displays as a bar in a gauge. Here is a start that might give the idea:
[code]
#trigger timebar {-} {#sub "-"} "" "disabled|prompt"
#cond {=} {#sub "-="} "duration=500"
#cond {+} {#sub "-=+"} "duration=500"
#cond {~*} {#sub "-=+*"} "duration=500"
#cond {~*} {#sub "-=+**"} "duration=500"
#cond {+} {#sub "-=+**+"} "duration=500"
#cond {=} {#sub "-=+**+="} "duration=500"
#cond {-} {#sub "-=+**+=-"} "duration=500"
[code]
The duration means each stage waits half a second for the pattern to show up; if it doesn't happen, the trigger goes on to the next condition without doing anything. You can adjust the duration. You would need a trigger to turn this trigger on when needed, since you don't want it catching hyphens in ordinary text. Right now, this simplistic code doesn't have a way to turn itself off. It could also be thrown off if the mud accidentally delays the next character more than the duration. You might be able to remove the duration part if you are certain that the trigger will catch every character and have a good trigger for turning it off consistently--perhaps a trigger on the prompt. See if you can get something like this working, and decide if you need something more sophisticated.
Reply with quote
lofor
Newbie


Joined: 04 Apr 2010
Posts: 4

PostPosted: Sat Apr 10, 2010 12:30 am   
 
hmm didnt seem to work.

Im going to try and get something to do a loop once the - is displayed at the start of the line and print the characters till a new line starts.

Still new to this scripting stuff :)
Reply with quote
arglebargle4
Newbie


Joined: 12 Jul 2010
Posts: 3

PostPosted: Fri Aug 06, 2010 11:04 pm   New idea on this?
 
Ok, here's the theory I have so far.. keep in mind I am using the editor to do this, and don't know how to enter everything from the command line, so bear with me as I'm pretty much making up a way to describe what I put into the editor as I go.. if anything is unclear, let me know and I'll try to explain better.

class spinner
{
variable timer 0
variable max 0

gauge spin
value: @timer
max: @max

alias bash
{
#class timer 1
#class bash 1
#var max 10
#var timer 0
#send bash %1
}

class timer
{
trigger - {#math timer @timer+1}
trigger = {#math timer @timer+1}
trigger * {#math timer @timer+1}
trigger + {#math timer @timer+1}
}

class bash
{
trigger {As %1 avoids your bash, you topple over and fall to the ground!}
{
#var timer 0
#class bash 0
#class timer 0
}

trigger {Bash who?}
{
#var timer 0
#class bash 0
#class timer 0
}

trigger {Canceled.}
{
#var timer 0
#class bash 0
#class timer 0
}

trigger {Your bash at %1 sends it sprawling!}
{
#var timer 0
#class bash 0
#class timer 0
}
}
}




Ok the idea is that the BASH alias sets the @max value to the amount of symbols in the bash timer and turns on the triggers in the TIMER and BASH classes, the TIMER class advances the @timer variable filling up the gauge with each symbol of the timer. Upon completion of the timer the BASH class turns off both the TIMER and BASH class and resets the @timer back to zero.

That's the theory that I have so far, very welcome to improve on my idea!
Reply with quote
Rahab
Wizard


Joined: 22 Mar 2007
Posts: 2320

PostPosted: Mon Aug 09, 2010 7:42 pm   
 
To diplay this in a more useable format that other people could use directly:

In the Package Editor, click click on the "spinner" class.
Under the right-hand window, click the XML tab.
Highlight and copy the XML displayed in the window. This will contain the code for the entire class, including all the triggers inside it.
Here in the forum, post a reply.
In the reply, type: [code]
Then paste the code you copied
Then type [/code]
Submit the reply.

Your solution looks pretty good. You could include #GAG in your triggers to suppress the display of the -=*+ symbols, as well. One tip: instead of
Code:
#math timer @timer+1

you can use
Code:
timer = @timer+1

The #MATH command is generally not needed any more.
Reply with quote
arglebargle4
Newbie


Joined: 12 Jul 2010
Posts: 3

PostPosted: Thu Aug 12, 2010 7:05 am   
 
Ok, this seems to be working.. I think I'll try it with the other style too, with the symbols stacking.

Code:

<class name="spinner" id="221">
  <button type="Gauge" autopos="false" toolstyle="true" gaugelowcol="lime" gaugebackcol="#804000" priority="1270" id="222">
    <caption>spin</caption>
    <expr>@timer</expr>
    <gaugemax>@max</gaugemax>
  </button>
  <var name="timer" id="223">0</var>
  <var name="max" id="224">9</var>
  <class name="timer" enabled="false" id="225">
    <trigger priority="1590" trigontrig="false" newline="false" prompt="true" id="232">
      <pattern>+</pattern>
      <value>timer = @timer+1</value>
    </trigger>
    <trigger priority="1600" trigontrig="false" newline="false" prompt="true" id="233">
      <pattern>-</pattern>
      <value>timer = @timer+1</value>
    </trigger>
    <trigger priority="1610" trigontrig="false" newline="false" prompt="true" id="234">
      <pattern>=</pattern>
      <value>timer = @timer+1</value>
    </trigger>
    <trigger priority="1620" trigontrig="false" newline="false" prompt="true" id="235">
      <pattern>~*</pattern>
      <value>timer = @timer+1</value>
    </trigger>
  </class>
  <alias name="bash" id="226">
    <value>#class timer 1
#class bash 1
#var max 8
#var timer 0
#send bash %1</value>
  </alias>
  <class name="Bash" enabled="false" id="227">
    <trigger priority="1420" trigontrig="false" id="228">
      <pattern>Your bash at %1 sends %2 sprawling!</pattern>
      <value>#var timer 0
#class bash 0
#class timer 0</value>
    </trigger>
    <trigger priority="1430" trigontrig="false" id="229">
      <pattern>Cancelled.</pattern>
      <value>#var timer 0
#class bash 0
#class timer 0</value>
    </trigger>
    <trigger priority="1440" trigontrig="false" id="230">
      <pattern>As %1 avoids your bash, you topple over and fall to the ground!</pattern>
      <value>#var timer 0
#class bash 0
#class timer 0</value>
    </trigger>
    <trigger priority="1450" trigontrig="false" id="231">
      <pattern>Bash who?</pattern>
      <value>#var timer 0
#class bash 0
#class timer 0</value>
    </trigger>
    <trigger priority="160" id="236">
      <pattern>You need to have a shield or weapon to try it.</pattern>
      <value>#var timer 0
#class bash 0
#class timer 0</value>




What I've done is create an alias that sets the length of the timer (@max) and set up triggers for the possible responses (land/miss/etc) to turn off the timer class so it doesn't trigger off regular hyphens and asterisks, etc. I need a way to EXCLUDE certain things.. for instance the mud promt looks like this:

* R HP:Healthy MV:Tiring >


The * in the prompt is a variable thing, that indicates light/dark/mounted/sneaking.. it would be nice to be able to make it ignore that. I'm currently working around it by using a feature that disables it on the mud side, but most people like having that turned on.
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