The following warnings occurred:
Warning [2] count(): Parameter must be an array or an object that implements Countable - Line: 906 - File: showthread.php PHP 7.2.24-0ubuntu0.18.04.17 (Linux)
File Line Function
/showthread.php 906 errorHandler->error



Facebook Twitter YouTube Frictional Games | Forum | Privacy Policy | Dev Blog | Dev Wiki | Support | Gametee


Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Script Help [Solved] Two Conditionals on same line?
Romulator Offline
Not Tech Support ;-)

Posts: 3,628
Threads: 63
Joined: Jan 2013
Reputation: 195
#1
[Solved] Two Conditionals on same line?

Was just wondering if I can make two if statements on the same line and progress with the code if both conditions are met?

PHP Code: (Select All)
void OnStart()
    {
    
SetLocalVarInt("can_craft"0);
    
AddEntityCollideCallback("Player""craft_box""check_collide"false0);
    
SetEntityPlayerLookAtCallback("sign_key_1""key_1_message"false);  //Signs are ScriptAreas.
    
}

void key_1_message(string &in asEntityint 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: (Select All)
void check_collide(string &in asParentstring &in asChildint 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!

Discord: Romulator#0001
[Image: 3f6f01a904.png]
(This post was last modified: 06-11-2015, 10:10 AM by Romulator.)
06-10-2015, 03:23 PM
Find


Messages In This Thread
[Solved] Two Conditionals on same line? - by Romulator - 06-10-2015, 03:23 PM
RE: Two Conditionals on same line? - by Kreekakon - 06-10-2015, 03:53 PM
RE: Two Conditionals on same line? - by Romulator - 06-11-2015, 10:09 AM
RE: Two Conditionals on same line? - by Mudbill - 06-10-2015, 04:07 PM
RE: Two Conditionals on same line? - by Mudbill - 06-10-2015, 10:01 PM



Users browsing this thread: 1 Guest(s)