Jump to content

Photo

Heart container


  • Please log in to reply
11 replies to this topic

#1 Christian

Christian

    Summoner

  • Members
  • Real Name:Chris
  • Location:New Jersey

Posted 29 November 2008 - 11:56 AM

So will this:
CODE
item script heart container{ void run(int m){ Screen->Message(m);  Waitframe(); Link-HP = MaxHP; } } }
re-fill link's health every time a heart container or a heart peice is picked up? And also plays a pick up string with it? Any errors i wrote?

#2 Surreal Canine

Surreal Canine

    Master of Disaster

  • Members
  • Real Name:Brian
  • Location:Somewhere

Posted 29 November 2008 - 12:17 PM

As a matter of fact, yes there is an error. The last statement should be
CODE
Link->HP = Link-> MaxHP;
and there should only be two closing braces at the end.

#3 Saffith

Saffith

    IPv7 user

  • Members

Posted 29 November 2008 - 12:19 PM

Don't use Waitframe(). It's the same as Quit() in item scripts, since they only run for one frame.

#4 Surreal Canine

Surreal Canine

    Master of Disaster

  • Members
  • Real Name:Brian
  • Location:Somewhere

Posted 29 November 2008 - 12:32 PM

QUOTE(Saffith @ Nov 29 2008, 12:19 PM) View Post

Don't use Waitframe(). It's the same as Quit() in item scripts, since they only run for one frame.

Unless you put it in a while() loop, in which case it'll stop the game from freezing. So yeah, take the Waitframe()out, and I'd say you should probably put the HP statement before the message statement.

Even better, edit the item itself to completely fill your HP when you pick it up. Just change "Increase Counter" on the Pickup tab to 384.

#5 Christian

Christian

    Summoner

  • Members
  • Real Name:Chris
  • Location:New Jersey

Posted 29 November 2008 - 02:11 PM

Thanks icon_smile.gif
CODE
const int S_PICKUP = 0;//String to play when a heart container is picked up      item script HeartContainer{ void run(){ Link->HP = Link->MaxHP; Screen->Message(S_PICKUP); }//end of void run   }//end of script
that will do icon_smile.gif

#6 Aslion

Aslion

    End Fascism

  • Members
  • Real Name:Ryan
  • Location:Plug One's spectacles

Posted 29 November 2008 - 02:47 PM

CODE
const int S_PICKUP = 0;//String to play when a heart container is picked up
item script HeartContainer{ void run(){ Link->HP = Link->MaxHP; Screen->Message(S_PICKUP);
}//end of void run
  }//end of script


Didn't compile for me unless it was arranged like that. Easier to read too.

#7 Saffith

Saffith

    IPv7 user

  • Members

Posted 29 November 2008 - 02:51 PM

Yeah, be careful if you're writing scripts on one line like that. Comments last to the end of the line, so you commented out the entire script.

#8 Joe123

Joe123

    Retired

  • Members

Posted 29 November 2008 - 02:53 PM

Mm, that'd be because in drzchulo's version he's started a new line halfway through a comment.

I'm assuming you didn't actually arrange it like that when you wrote it drz (dyumind if I call you drz?)?
It's obviously really quite difficult to read when you put it out on one line like that.

And you do need Waitframe() in an infinite while loop to stop it crashing Sillycat, but for that reason you can't have an infinite while loop in an item script (unless you just wanna crash the system).
Once it hits Waitframe(), the script ends.

#9 Aslion

Aslion

    End Fascism

  • Members
  • Real Name:Ryan
  • Location:Plug One's spectacles

Posted 29 November 2008 - 02:57 PM

Tweaked it a little. This does the same thing, except D0 is the number of the string to play.

CODE
item script HeartContainer{
void run(int m){
Link->HP = Link->MaxHP;
Screen->Message(m);
}
  }


And I'm assuming that this one will do that same thing, but with Magic.

CODE
item script MagicContainer{
void run(int m){
Link->MP = Link->MaxMP;
Screen->Message(m);
}
  }

Edited by Lithium, 29 November 2008 - 09:57 PM.


#10 Saffith

Saffith

    IPv7 user

  • Members

Posted 29 November 2008 - 03:06 PM

QUOTE(Lithium @ Nov 29 2008, 02:57 PM) View Post
And I'm assuming that this one will do that same thing, but with Magic.

CODE
item script MagicContainer{ void run(int m){ Link->HP = Link->MaxMP; Screen->Message(m);
}
  }

Almost. You missed Link->HP.


#11 Aslion

Aslion

    End Fascism

  • Members
  • Real Name:Ryan
  • Location:Plug One's spectacles

Posted 29 November 2008 - 03:12 PM

Whoops. I should fix that.

#12 Christian

Christian

    Summoner

  • Members
  • Real Name:Chris
  • Location:New Jersey

Posted 29 November 2008 - 06:34 PM

Of course joe you can call me "drz"(pronounced Dee-are-z) while i get my name changed icon_razz.gif and yeah, i totally forgot to move the script out of the comment,sorry about. Thanks lithium. I thought i added in the waitframe(); so when you pick it up, it will wait one frame then play the message icon_shrug.gif
CODE

item script HeartContainer{
      void run(int s){
            Link->HP = Link->MaxHP;
            Screen->Message(s);
              }//End of void run
}//End of script


there, it's all fixed up and ready to go..just set D0 to the message it will play when the heart container is picked up and it will heal your health completely after it icon_smile.gif

set the script in the item pick-up tab.

Edited by drzchulo973, 29 November 2008 - 09:48 PM.



1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users