- Home /
Health Script Help...?
Hi, major noob, just wondering why I am getting an error message for LINE 18, when I don't HAVE a line 18... Any Help? Here's the code ATM... Not 100% working, but the rest is solvable.
static var Blood : float = 2000;
public var infected : boolean = false;
var dead : boolean = false;
var brokenlimb : boolean = false;
private var bleedout : float = 2.0;
private var isbleeding : boolean = false;
function Update () {
if (Blood>0) dead && true;
if (brokenlimb && true) {
maxforwardspeed.float = 3;
}
if (isbleeding && true) Bleed ();
}
function Bleed () {
while ((isbleeding && true) && (Blood>0)) {
Blood -= bleedout*Time.deltaTime;
}
Note: The exact error message is: "(Assets/Insomniac Studios/Name Censored for Copyright Reasons/Ditto/Health.js(20,1): BCE0044: expecting }, found ".
1 : Don't bump after 1 hour, that's not cool. Your question is still visible.
2 : You havn't even posted the error message.
Ok, you get downvoted for bumping twice in 1 hour. Even as I'm writing the above comment, you bumped again.
Lol... I didn't see that comment at all, and I bumped and error messaged at the same time. XD
Answer by AlucardJay · Apr 26, 2013 at 12:09 AM
Line 9 makes no sense at all :
if (Blood) = 0 dead && true;
what is this supposed to be doing ?!
Edit : The problem is you don't have a closing curly brace for function Bleed()
And still, what is this line supposed to be doing :
if (Blood>0) dead && true;
One-line conditionals is not optimization. Format your code better, then you'll be able to actually read it :
if (brokenlimb && true) maxforwardspeed.float = 3;
not good
if (brokenlimb && true)
maxforwardspeed.float = 3;
better
if (brokenlimb && true) {
maxforwardspeed.float = 3;
}
very nice looking formatting.
Well, thanks for the formatting tip, I'm really new to coding. But... I posted the error message, and that format adjustment didn't solve my problem/the reason I posted this...
Line 9 makes no sense at all :
if (Blood) = 0 dead && true;
I cannot even guess what you are trying to do there.
I have updated the answer. The problem is you don't have a closing curly brace for function Bleed
Lol... THAN$$anonymous$$ YOU! I was such a noob there. XD Several hours of messing with it before posting this on unity answers, to get into a nerdfight with some random guy just to find out it was that $$anonymous$$OTHER*** CURLY BRACE! Anyways, thanks for the help. XP
Lol.. and just saying, line 9 is supposed to be the starter for the death script. There will be lots of ways to die, so I will just make it change a variable. I guess I should change it so it calls a function... :P
So you probably mean
if ( Blood <= 0 )
{
dead = true;
}
Look into conditional statements and operators.
Conditional statements are things like if else statements, for loops, etc.
Operators are the signs used in conditional statements.
Basic Operators :
== is equal to
!= is not equal to
> is greater than
< is less than
>= is greater than or equal to
<= is less than or equal to
&& if one condition is true AND another is also true
|| if one condition is true OR another is also true