About Us
Products
Purchase
Downloads
Support
Forums
Contact Us
Site
 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
Aon
Beginner


Joined: 12 Nov 2002
Posts: 15

PostPosted: Thu Dec 19, 2002 1:53 am   

Need to teach Zmud to count
 
---------------------------------------------------------------------
Force Power [**************************************************]
Force Jump [**************************** ]
Force Sight [***************** ]
Force Speed [****************************************** ]
Force Push [****************** ]
Force Pull [*************** ]
Force Lightning [********** ]
Force Grip [********** ]
Force Mind Trick [************ ]
Force Healing [*************************************** ]
Lightsabre Throw [************ ]
Lightsabre Skill [**************************************************]
Studytime Left [************ ]
---------------------------------------------------------------------

Trying to figure out how to make zmud read the stars and count them
then take that number and multiply it by 2 and then divide by 1100..
I know how to do everything but tell Zmud to count stars.. the %d or %n or %w nor * seem to work well enough.. But once I get it to just copy how many stars I was planning to make a if statement to see if that was equal to 1 star if not then use #add var * and keep checking to see if they equal till they did.. and then use that to add total in the end.. But maybe there is a simplier way.. Someone help me out please..lol
Reply with quote
Toetag
Magician


Joined: 10 Oct 2000
Posts: 356
Location: USA

PostPosted: Thu Dec 19, 2002 2:06 am   
 
will the strings before [ and after ] be consistant?

If so any way to put the string in a variable, count the LEN of the variable, subtract the left count and right count.

ie:

Force Power[
*****]

Left is 12 characters, right is 1, Len is 18. So 18 - (12 + 1) = #of stars

might check the LEFT / RIGHT / LEN functions. If you can't get them to work, let me know, see what I can come up with.

Killing a fly on a friends forhead may not be overkill, use a hatchet to make sure the job is done.
Reply with quote
Charbal
GURU


Joined: 15 Jun 2001
Posts: 654
Location: USA

PostPosted: Thu Dec 19, 2002 2:17 am   
 
This should work (untested):

#TRIGGER {~[([*])~]} {#SUB {~[%len(%1)~]}}

You are right about the pattern * not matching the * character itself. * will not match any zMUD special characters... %* is used for that. It matches _anything_.


 - Charbal
Reply with quote
LightBulb
MASTER


Joined: 28 Nov 2000
Posts: 4817
Location: USA

PostPosted: Thu Dec 19, 2002 2:26 am   
 
Even simpler would be to just capture the *'s. I added the %trim function to remove any leading/trailing spaces, since I noticed most of your bars end with one. Oh, and the * wildcard does match *'s, I tested.
#TR {Force Power ~[(*)~]} {#VAR powerstars {%trim(%1)};#VAR power %len(@powerstars}

LightBulb
Senior Member
Reply with quote
Charbal
GURU


Joined: 15 Jun 2001
Posts: 654
Location: USA

PostPosted: Thu Dec 19, 2002 2:45 am   
 
Ack, thanks for catching that. I mistakenly thought * matched like # and % do, apparently.

By starting a reply to Aon's first post, I figured out that what he was trying for was:


---------------------------------------------------------------------
Force Power [**************************************************]
Force Jump [**************************** ]
Force Sight [***************** ]
Force Speed [****************************************** ]
Force Push [****************** ]
Force Pull [*************** ]
Force Lightning [********** ]
Force Grip [********** ]
Force Mind Trick [************ ]
Force Healing [*************************************** ]
Lightsabre Throw [************ ]
Lightsabre Skill [**************************************************]
Studytime Left [************ ]
---------------------------------------------------------------------


but the spacing was not preserved.



So something like this should get it:

#TRIGGER {Force Power%s~[([*]){]| ]} {#VARIABLE ForcePower %len(%1)}

and similar triggers for everything else.

Or if you want one trigger for everything:
#TRIGGER {({Force Power|Force Jump|Force Sight|Force Speed|Force Push|Force Pull|Force Lightning|Force Grip|Force Mind Trick|Force Healing|Lightsabre Throw|Lightsabre Skill|Studytime Left})%s~[([*]){]| ]} {#VARIABLE %replace("%1", " ", "") %len(%2)}

That will save to the variables ForcePower, ForceJump, ForceSight, ForceSpeed, ForcePush, ForcePull, ForceLightning, ForceGrip, ForceMindTrick, ForceHealing, LightsabreThrow, LightsabreSkill, and StudytimeLeft.



 - Charbal
Reply with quote
Aon
Beginner


Joined: 12 Nov 2002
Posts: 15

PostPosted: Thu Dec 19, 2002 3:41 am   
 
heh I ended up using the #trigger ({Force Jump|Force Sight|Force Speed|Force Push|Force Pull|Force Lightning|Force Grip|Force Mind Trick|Force Healing|Lightsabre Throw|Lightsabre Skill})%s~[([*])%s~] but slightly modified of course.. I couldnt seem to get yours to work so I used that and then used another one without the %s at the end to cover if it was full.. Also when that trigger is set off it does #VARIABLE %replace( "%1", " ", "") %len( %2) ... heh seemed simmple I thought but aparently not.. trying to just add all the variables together and then *2 and /1100 using #math isnt working.. Its saving the numbers into a variable called 0 and not even adding the numbers.. Im so confused about that.. lol need some more help guys.. lol your way over my head.. took me like 10 minutes to even understand the trigger you guys wrote.. lol cause I had never used %s or anything..
Reply with quote
Aon
Beginner


Joined: 12 Nov 2002
Posts: 15

PostPosted: Thu Dec 19, 2002 4:17 am   
 
ALright I think I know why it wont work.. because the answer is like 0.44 or something.. What function is used to tell it not to drop off those Decimal places?
Reply with quote
MattLofton
GURU


Joined: 23 Dec 2000
Posts: 4834
Location: USA

PostPosted: Thu Dec 19, 2002 5:40 am   
 
quote:

ALright I think I know why it wont work.. because the answer is like 0.44 or something.. What function is used to tell it not to drop off those Decimal places?



For whatever reason I never bothered to inquire about, / will only return an integer answer. 25 / 3 = 8, for instance. Likewise, 1 / 2 = 0. I suppose this is due to some resolution/memory concern about the numbers, but all other non-divisory operators will return a floating-point number if needed.

If you are still using 6.16 or lower, there's nothing you can do to get it to calculate to a floating-point number. You can perform a few tricks to get rid of the decimals, though.

If you are using 6.40 or one of the betas from the past year or so, you can simply use %float() to cast one of your integers as a floating-point number. This will tell ZMud to perform floating-point math instead of integer math, and thus the decimals will be preserved.

li'l shmoe of Dragon's Gate MUD
Reply with quote
Charbal
GURU


Joined: 15 Jun 2001
Posts: 654
Location: USA

PostPosted: Thu Dec 19, 2002 7:41 am   
 
Mine was missing a curly brace which would definitely keep it from working:

#TRIGGER {({Force Power|Force Jump|Force Sight|Force Speed|Force Push|Force Pull|Force Lightning|Force Grip|Force Mind Trick|Force Healing|Lightsabre Throw|Lightsabre Skill|Studytime Left})%s~[([*]){]| ]}} {#VARIABLE %replace("%1", " ", "") %len(%2)}


 - Charbal
Reply with quote
LightBulb
MASTER


Joined: 28 Nov 2000
Posts: 4817
Location: USA

PostPosted: Thu Dec 19, 2002 8:06 am   
 
The trigger is now assuming there will be either 1 or no spaces at the end of the stars, and won't fire for any longer amount of spaces. Just use the * wildcard to match everything between the [ and the ], and use the %trim function to remove the spaces.

#TRIGGER {({Force Power|Force Jump|Force Sight|Force Speed|Force Push|Force Pull|Force Lightning|Force Grip|Force Mind Trick|Force Healing|Lightsabre Throw|Lightsabre Skill|Studytime Left})%s~[(*)~]} {#VARIABLE %remove("%1", " ") %len(%trim(%2))}

LightBulb
Senior Member
Reply with quote
Charbal
GURU


Joined: 15 Jun 2001
Posts: 654
Location: USA

PostPosted: Thu Dec 19, 2002 9:01 am   
 
Lightbulb hit that one right on the nose. That trigger should work for you.

My assumption came from looking at the post without formatting in the forum even though I posted the trigger with the correctly formatted version :P



 - Charbal
Reply with quote
Kjata
GURU


Joined: 10 Oct 2000
Posts: 4379
Location: USA

PostPosted: Thu Dec 19, 2002 1:05 pm   
 
Some extra info on the floating point math:
  • Like Matt said, and integer division returns an integer result (the fractional part is just dropped off). Thus 9/2 equals 2 and 3/6 equals 0.

  • However, if one of the operands in the division (or multiplication) is a floating point number, the result is a floating point number. So, in with the above example, 9.0/2, 9/2.0 and 9.0/2.0 all equal 4.5, the same way that 3.0/7, 3/7.0 and 3.0/7.0 all equal 0.5

  • Additionaly, you can make zMUD treat a number as a floating point number by putting it in the %float function

  • Finally, the %format may also be used to limit the number of decimal places displayed in a floating point number


  • Kjata
    Reply with quote
    Aon
    Beginner


    Joined: 12 Nov 2002
    Posts: 15

    PostPosted: Thu Dec 19, 2002 6:29 pm   
     
    hehe well I tried to use the %float but had problems with it so I choose to multipy the number by 200 instead of just 2 and then divide by 1100.. then add the "%" to the end of the number and that shows my percent.. lol I kinda like that better than having it to be a decimal answer anyways.. Thanks guys for all your help.. I do have one other thing I need to get solved..
    <[436788030] [115324H 114805M 114614V]>
    see that number 436788030? I would like to have Zmud take that number and #sub it with the same number just with ,'s in it.. So I can actually read it without having to put my finger on the monitor and try to figure it out.. lol
    Reply with quote
    Vijilante
    SubAdmin


    Joined: 18 Nov 2001
    Posts: 5182

    PostPosted: Thu Dec 19, 2002 9:49 pm   
     
    Use %format("&1.0n",@xp)

    That should do it if you put it in the right trigger, but I am sure you can figure that part out.
    Reply with quote
    Aon
    Beginner


    Joined: 12 Nov 2002
    Posts: 15

    PostPosted: Fri Dec 20, 2002 5:24 am   
     
    Hrm I got it to work.. But it seems not to work on the current prompt line.. Till after that line leaves the bottom row.. and only if I dont type a command on that line to make it leave.. So its really weird to me on why its doing that.. But on most line the Sub seems to work.. So thanks.. If any of you got any idea how to fix the fact that it wont work on the new prompt line that is brought up every time soemthing is typed or new information is received I would appreciate it.
    Reply with quote
    LightBulb
    MASTER


    Joined: 28 Nov 2000
    Posts: 4817
    Location: USA

    PostPosted: Fri Dec 20, 2002 7:06 am   
     
    Whenever you try to trigger on the prompt (or other lines that finish with the cursor on the same line, such as login and reroll questions) you need to change the trigger options from Trigger on Newline to Trigger on Prompt. This can be done using the checkboxes on the options tab in the editor. It can also be done from the command line when inputting the trigger there, using the nocr and prompt options.
    #TR "id" {trigger pattern} {trigger commands} {triggerclass} {options}
    NOTE: "id" is optional
    Example:
    #TR {~<~[(%d)~]} {#SUB ~<~[%format("&1.0n", %1)~]} {} {nocr|prompt}

    LightBulb
    Senior Member
    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