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
shaun.murray
Magician


Joined: 23 Jul 2005
Posts: 334
Location: Chicago

PostPosted: Wed Jul 02, 2008 1:26 pm   

smart heal's not working... =[
 
Code:
#var {hit_min} {1000}
#var {hit_cur} {500}
#var {spi_max} {1000}
#var {spi_cur} {500}
#var {autoheal} {1}
#alias {heal} {invoke 'compelled rejuvination'}
#alias {healme} {$PossibleHeals = 0;$NeededHeals = 0;#if (@autoheal = 1) {#if (@hit_cur <= @hit_min) {$NeededHeals = {(@hit_min - @hit_cur) / 198};$PossibleHeals = {(@spi_max - @spi_cur) / 40};#loop %min( $NeededHeals, $PossibleHeals) { heal };emote AutoHeals Completed!};#var autoheal 10}}
#trig {~< emote ~> (*)Sheykh(*) AutoHeals Completed!$} {#if (@autoheal = 10) {#var autoheal 1}}


For some reason, its not sending the heals. Prolly something dumb I'm missing, but I haven't had any coffee yet... ^^ TIA!
Reply with quote
Fang Xianfu
GURU


Joined: 26 Jan 2004
Posts: 5155
Location: United Kingdom

PostPosted: Wed Jul 02, 2008 2:58 pm   
 
I can't test it right now, but I'd check to see if removing the spaces around "heal" makes a difference. Then I'd check that the values of $NeededHeals and $PossibleHeals are working. As you have them there, surrounded by {}, they're probably going to end up as strings, which you don't want (because who knows what %min will decide a string equals?). You probably mean () rather than {}.

If you've still not got it working, post again later and I'll know to take another look.
_________________
Rorso's syntax colouriser.

- Happy bunny is happy! (1/25)
Reply with quote
shaun.murray
Magician


Joined: 23 Jul 2005
Posts: 334
Location: Chicago

PostPosted: Wed Jul 02, 2008 3:13 pm   
 
actually, when i first wrote it out, the spaces where not in there, and it took away the "blue alias" and made it black. my thinking is that then it would send just 'heal' and not the alias 'heal' to the mud, which... obviously wouldn't work. not following what you mean by the local variables. meaning... remove the red in.... $NeededHeals = { STUFF }? I can try that...
Reply with quote
shaun.murray
Magician


Joined: 23 Jul 2005
Posts: 334
Location: Chicago

PostPosted: Wed Jul 02, 2008 3:28 pm   
 
Took out the braces, and it still doesn't work.... =[
Reply with quote
Tech
GURU


Joined: 18 Oct 2000
Posts: 2733
Location: Atlanta, USA

PostPosted: Wed Jul 02, 2008 4:44 pm   
 
The reason it doesn't work is because the curly braces
shaun.murray wrote:
$NeededHeals = { STUFF }
tell CMUD to treat you text like a literal string instead of an expression. Remove them and it should work.

Try this for the healme alias.
Code:
$PossibleHeals = 0
$NeededHeals = 0
#if (@autoheal = 1) {
  #if (@hit_cur <= @hit_min) {
    $NeededHeals = (@hit_min - @hit_cur) / 198
    $PossibleHeals = (@spi_max - @spi_cur) / 40
    #loop %min( $NeededHeals, $PossibleHeals) {heal}
    emote AutoHeals Completed!
    }
  #var autoheal 10
  }
_________________
Asati di tempari!
Reply with quote
Arde
Enchanter


Joined: 09 Sep 2007
Posts: 605

PostPosted: Wed Jul 02, 2008 5:03 pm   
 
shaun.murray
If something somewhere is not working properly, just add a bunch of #PRINT commands to your script and let CMUD tell you what is the problem.

Code:

$PossibleHeals = 0
$NeededHeals = 0
#if (@autoheal = 1) {
  #PRINT "First #IF entered"
  #if (@hit_cur <= @hit_min) {
    #PRINT "Second #IF entered"
    $NeededHeals = {(@hit_min - @hit_cur) / 198}
    $PossibleHeals = {(@spi_max - @spi_cur) / 40}
    #PRINT "Loop counter is "
    #PRINT %min( $NeededHeals, $PossibleHeals)
    #loop %eval(%min( $NeededHeals, $PossibleHeals)) {#PRINT Looping;heal}
    emote AutoHeals Completed!
    }
  #var autoheal 10
  }



Now test it
Code:

#SHOW "< emote > abc 123 xyzSheykhabc 123 xyz AutoHeals Completed!"
healme


You will see:
Code:

Loop counter is
(1000 - 500) / 19

i.e. your loop counter not get evaluated to a number. So, use the %eval(), but I wonder why CMUD return a string from %min().

P.S. Darn, CMUD hangs after all of this. Evil or Very Mad

UPDATE: Hmm, restarting CMUD helps the original script to run. What is going on?


Last edited by Arde on Wed Jul 02, 2008 5:07 pm; edited 1 time in total
Reply with quote
shaun.murray
Magician


Joined: 23 Jul 2005
Posts: 334
Location: Chicago

PostPosted: Wed Jul 02, 2008 5:05 pm   
 
Huh, ok. That works. Quick question tho. The way that the alias is used, is that it is CONSTANTLY being called, before I take any sort of action. But the inside of that alias determins whether or not a heal should be done. The issue now, is that I'm getting spammed with emotes. While its not "hurting" anything, I would like to only do a final emote at the end, as to reset the variable autoheal back to heal if need be. Is there a way to do that? Meaning, only do the emote if it actually does any heals? THANKS A TON THO! =D
Reply with quote
Arde
Enchanter


Joined: 09 Sep 2007
Posts: 605

PostPosted: Wed Jul 02, 2008 5:15 pm   
 
Ok, ignore my suggestion about using the %eval(), because on CMUD restart your script works normally. Shocked
_________________
My personal bug|wish list:
-Wrong Priority when copy-paste setting
-1 prompt trigger for Mapper, Session and General Options, not 3 different!
-#SECTION can terminate threads
-Buttons can't start threads
Reply with quote
Zugg
MASTER


Joined: 25 Sep 2000
Posts: 23379
Location: Colorado, USA

PostPosted: Wed Jul 02, 2008 5:25 pm   
 
I'll check to see if there is a problem with %min returning a string instead of an integer.

But shaun, you should also clean up your original script a bit. You are using {} too much. The syntax for #VAR and #ALIAS is:

#VAR varname value
#ALIAS aliasname {script}

So instead of using

#var {hit_min} {1000}

you should use

#var hit_min 1000

and instead of

#alias {heal} {invoke 'compelled rejuvination'}

it should be:

#alias heal {invoke 'compelled rejuvination'}

It's important to use the correct syntax or you might run into more problems in the future.
Reply with quote
Zugg
MASTER


Joined: 25 Sep 2000
Posts: 23379
Location: Colorado, USA

PostPosted: Wed Jul 02, 2008 5:29 pm   
 
Just did a quick test of %min and it seems to work fine here. Here was my test:
Code:
$Value1 = 3
$Value2 = 10
#loop %min( $Value1, $Value2) {#show loop %i}

It properly ran the loop 3 times, so I don't think the %eval is needed. If you need %eval, then that usually means that something is getting stored as a string somewhere. Probably because you are using extra {} where you shouldn't. Try to remember that {} are just like " quotes except the they allow variables and functions to be expanded within them.

For example, the line:

$NeededHeals = {(@hit_min - @hit_cur) / 198}

really needs to be this:

$NeededHeals = ((@hit_min - @hit_cur) / 198)

to get a number instead of a string.
Reply with quote
shaun.murray
Magician


Joined: 23 Jul 2005
Posts: 334
Location: Chicago

PostPosted: Wed Jul 02, 2008 6:03 pm   
 
Hahahahah! Sometimes, I scare myself.... =\

Code:
$PossibleHeals = 0
$NeededHeals = 0
#if (@autoheal = 1) {
  #if (@hit_cur <= @hit_min) {
    $NeededHeals = (@hit_min - @hit_cur) / 198
    $PossibleHeals = @spi_cur / 40
    #loop %min( $NeededHeals, $PossibleHeals) {heal}
    emote AutoHeals Completed!
    }
  #var autoheal 10
  }


Basically, the line $PossibleHeals = (@spi_max - @spi_cur) / 40 needed to be changed to $PossibleHeals = @spi_cur / 40 because the @spi_max - @spi_cur was giving me a zero, so it wasn't firing. Dum dum dum.... LoL! Works like a champ now! Thanks all!

And Zugg... I was putting those brackets in there for ease of reading. ^^ I'll just post "as is" from no on, I think me trying to make the code easier to read, was in fact, makeing the guru's confused as to what I am trying to accomplish, LoL! Thanks again!! =D
Reply with quote
Rahab
Wizard


Joined: 22 Mar 2007
Posts: 2320

PostPosted: Wed Jul 02, 2008 7:26 pm   
 
Um, yeah, if you put something in code tags, people expect it to be your actual code. Don't modify it for display.
Reply with quote
Arde
Enchanter


Joined: 09 Sep 2007
Posts: 605

PostPosted: Wed Jul 02, 2008 8:56 pm   
 
Zugg wrote:
Just did a quick test of %min and it seems to work fine here.

Yeah, it works fine for me too. Dunno what screwed up that CMUD instance...
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