I don't see what you're not understanding?Code:if(condition_to_be_met) { //Do something. } else { //Do something else. }
|
Lol.
I am such a re-noob.
the coding is } else {
What does ah do?
I don't see what you're not understanding?Code:if(condition_to_be_met) { //Do something. } else { //Do something else. }
This is my coding:
I don't know how to fix it. Again, the error is 'else' without 'if' } else {Code:if (!Item.isFullHelm(playerEquipment[playerHat]) && !Item.isFullMask(playerEquipment[playerHat]) && (playerLook[0] != 1)) playerProps.writeWord(0x100 + pBeard); // Beard else playerProps.writeByte(0); } else { playerProps.writeWord(-1); playerProps.writeWord(npcId); }
What?! D:
I will give rep to whoever helps DDx
by what you've provided I would assume the last block is executed if another condition failed, so it would be like this
Code:if (!Item.isFullHelm(playerEquipment[playerHat]) && !Item.isFullMask(playerEquipment[playerHat]) && (playerLook[0] != 1)) { playerProps.writeWord(0x100 + pBeard); } else { playerProps.writeByte(0); } } else { playerProps.writeWord(-1); playerProps.writeWord(npcId); }
It produced the same error..
I will try to teach you something about if statements, so that you can fix this yourself
This is a simple if statement:
This pretty much says: IF your hplevel goes above 99, im gonna have to change your co-ords.Code:if (hp > 99) { absX == 5000 absY == 5000 }
Okay, this is pretty simple. Moving on to else statements:
This is the same statement, but this version will show a GFX if your hp is not above 99:
Okay, this code will look if the player has above 99 hp. If the player doesn't have that the code will move on to else, to see what to do if the first statement wasn't do-able.Code:if (hp > 99) { absX == 5000 absY == 5000 } else { gfx(1800); }
Else statements are only for what to do if everything else goes wrong. (If none of the conditions are satisfyed).
You can also use ELSE IF. They are used if you want it to look for another thing if the above one is not satisfied.
A code with all this could be:
You see, using else if's you can make it look for another thing if the first one didn't go well.Code:if (imLaughing == true) { Dothis! } else if (imLaughing != true) { DoThis! } else if (imNotHere == true) { Dohis! } else { dontdoanything }
Else just specifys what to do if no IF's or ELSE IF's are satisfied.
My teaching skills are bad, and so is my examples.
I hope you learned something
lol not } else {
its } else
thats it
« Previous Thread | Next Thread » |
Thread Information |
Users Browsing this ThreadThere are currently 1 users browsing this thread. (0 members and 1 guests) |