06-10-2015, 03:23 PM
Was just wondering if I can make two if statements on the same line and progress with the code if both conditions are met?
The other conditional I need to check is if the Player is actually looking at the ScriptArea (in this case; sign_key_1), since if they are not, on looking away, the message just reappears for a bit.
I can code an extra line or two to actually make it work, but I would like to see if its possible to do it on one line, since it probably makes my code just that little bit more efficient and would benefit me somewhat in the future.
Thanks!
PHP Code:
void OnStart()
{
SetLocalVarInt("can_craft", 0);
AddEntityCollideCallback("Player", "craft_box", "check_collide", false, 0);
SetEntityPlayerLookAtCallback("sign_key_1", "key_1_message", false); //Signs are ScriptAreas.
}
void key_1_message(string &in asEntity, int alState)
{
if(GetLocalVarInt("can_craft") == 1) //Put extra conditional here
{
SetMessage("CraftTable", "Key_1", 0);
}
}
Spoiler below!
And this is what changes "can_craft", not that it really matters.
PHP Code:
void check_collide(string &in asParent, string &in asChild, int alState)
{
if(alState == 1)
{
if(GetLocalVarInt("can_craft") < 1)
{
AddLocalVarInt("can_craft", 1);
}
}
else
{
if(GetLocalVarInt("can_craft") > 0)
{
AddLocalVarInt("can_craft", -1);
}
}
}
The other conditional I need to check is if the Player is actually looking at the ScriptArea (in this case; sign_key_1), since if they are not, on looking away, the message just reappears for a bit.
I can code an extra line or two to actually make it work, but I would like to see if its possible to do it on one line, since it probably makes my code just that little bit more efficient and would benefit me somewhat in the future.
Thanks!