Jump to content

Photo

My item script DeathPotionWhenUsed will not compile


  • Please log in to reply
3 replies to this topic

#1 LikeLike888

LikeLike888

    Spicy food lover!!

  • Members
  • Real Name:Jason
  • Location:North America

Posted 24 February 2018 - 08:29 AM

Here is its coding

import "std.zh"
item script DeathPotionWhenUsed{
void run(){
while ( Game->Counter[CR_LIFE] !== 0 )
{
  Game->Counter[CR_LIFE -= 0.25;
  Game->PlaySound(23);
}
}
}

 

 

 

To type up such a code I went to

Quest

Scripts

Compile ZScript

Edit



#2 strike

strike

    life is fragile, temporary, and precious

  • Members
  • Real Name:Olórin

Posted 24 February 2018 - 09:35 AM

I don't code in ZScript so this answer may be completely wrong. But I'll just guess and someone will give you a real answer eventually so : P My two guesses are that !== should be != or that 0.25 should be 1. Maybe this is a waste of a comment so sorry if that is the case : |



#3 Jamian

Jamian

    ZC enthusiast

  • Members

Posted 24 February 2018 - 01:24 PM

It would help if you described what you precisely want your script to do. ;) I'm guessing you want this script to slowly kill Link once he drinks a "death potion".

 

- "not equals" is indeed != (and not !==)

- The life counter is an integer, not a double. You cannot use floating point numbers. 1 is equivalent to 1/16th of a heart, so that's already a very small amount of health and should be sufficient for whatever you want to do.

- More importantly, item scripts only run for 1 frame. You cannot have any kind of loop inside of them.


Edited by Jamian, 25 February 2018 - 03:28 AM.

  • LikeLike888 likes this

#4 Timelord

Timelord

    The Timelord

  • Banned
  • Location:Prydon Academy

Posted 25 February 2018 - 12:27 AM

The error preventing it from compiling is a missing right brace after CR_LIFE; although if you fix that, it'll hang ZC when you use it.

Every while loop does not need Waitframe() : Only infinite loops need that.

That doesn't matter here, as item scripts run only for one frame, so an infinite loop in one is pointless.

Game->Counter[] will truncate -= 0.25 to -= 0. It's a short, and you can only use whole numbers.

Nothing in ZC is a double. We're 32b. :)
item script Poison
{
    void run()
    {
         Game->DCounter[CR_LIFE] -= Game->MCounter[CR_LIFE];
    }
}



Try using DCounter for a 'drain until expended'effect.
  • LikeLike888 likes this


1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users