Jump to content
Pottyscotty

Don't activate light if headlights are on

Recommended Posts

I have a command that will turn on TLT_YELLOW however I want it so that it will not do so if the headlights are on, except I am not sure how to get about this.

Basically if the command is activated when the headlights are also on, nothing will happen. However if the headlights are off and you activate the command, it will work.

http://pastebin.com/yjNHHHW7

 

Link to comment
Share on other sites

I don't think there is a way for you to check if the headlights are enabled or not. 

 

Theese are all the possible light commands

void EnableBlueLights(bool enable_);
		bool IsBlueLightEnabled() const;
		void EnableHeadLights(bool enable_);
		void EnableBreakLights(bool enable_); // aus Kombatibilitätsgründen noch da
		void EnableBrakeLights(bool enable_);
		bool IsBrakeLightEnabled() const;
		void EnableSpecialLights(bool enable_);
		bool IsSpecialLightEnabled() const;
		void EnableTrafficLight(TrafficLightType type_);
		void EnableBlinker(BlinkerLightType type_);
		BlinkerLightType GetBlinkerStatus() const;
		void SetLightEnabled(int id_, bool enable_);

 

Link to comment
Share on other sites

15 minutes ago, bma said:

I don't think there is a way for you to check if the headlights are enabled or not. 

 

Theese are all the possible light commands


void EnableBlueLights(bool enable_);
		bool IsBlueLightEnabled() const;
		void EnableHeadLights(bool enable_);
		void EnableBreakLights(bool enable_); // aus Kombatibilitätsgründen noch da
		void EnableBrakeLights(bool enable_);
		bool IsBrakeLightEnabled() const;
		void EnableSpecialLights(bool enable_);
		bool IsSpecialLightEnabled() const;
		void EnableTrafficLight(TrafficLightType type_);
		void EnableBlinker(BlinkerLightType type_);
		BlinkerLightType GetBlinkerStatus() const;
		void SetLightEnabled(int id_, bool enable_);

 

Thanks, I was told the same somewhere else as well. One of the ways I was told I could do it was by getting the script to check the time and base it on that instead.

Link to comment
Share on other sites

//in the top of your script
int Agerskov_hour;
int Agerskov_minute;
int Agerskov_second;

//Just after void PushActions(GameObject *Caller, Actor *Target, int childID) {	
Game::GetTime(Agerskov_hour, Agerskov_minute, Agerskov_second);

//Whereever you need it after Game::GetTimer
if(Agerskov_hour > 7 && Agerskov_hour < 17 && Agerskov_minute == 0 && Agerskov_second < 4)

 

Link to comment
Share on other sites

Upon adding the second bit I get an error while loading the mod that says "Unrecognized Language".

 

        void PushActions(GameObject *Caller, Actor *Target, int childID)
        Game::GetTime(Agerskov_hour, Agerskov_minute, Agerskov_second);
        {
                Vehicle v(Caller);
                v.EnableTrafficLight(TLT_YELLOW);
                v.AssignCommand(CMD_WWTD_OFF);
                v.RemoveCommand(CMD_WWTD_ON);
                Audio::PlaySample3D(SND_TOGGLE, v.GetPosition());
        }
};

 

Link to comment
Share on other sites

        void PushActions(GameObject *Caller, Actor *Target, int childID)
        {
                Game::GetTime(Agerskov_hour, Agerskov_minute, Agerskov_second);
                Vehicle v(Caller);
                v.EnableTrafficLight(TLT_YELLOW);
                v.AssignCommand(CMD_WWTD_OFF);
                v.RemoveCommand(CMD_WWTD_ON);
                Audio::PlaySample3D(SND_TOGGLE, v.GetPosition());
        }
};
Link to comment
Share on other sites

59 minutes ago, bma said:

I presume this isn't how to do an 'if' function either considering I get a different error (Symbol V not defined in current scope). I can't see anything different between mine and other if functions though apart from when they return false/true - Is this a requirement?

        void PushActions(GameObject *Caller, Actor *Target, int childID)
        {
                Game::GetTime(Agerskov_hour, Agerskov_minute, Agerskov_second);
                if(Agerskov_hour > 7 && Agerskov_hour < 17 && Agerskov_minute == 0 && Agerskov_second < 4)
                	Vehicle v(Caller);
                	v.EnableTrafficLight(TLT_YELLOW);
                	v.AssignCommand(CMD_WWTD_OFF);
                	v.RemoveCommand(CMD_WWTD_ON);
                	Audio::PlaySample3D(SND_TOGGLE, v.GetPosition());
        }
};

 

Link to comment
Share on other sites

You take the Vehicle v (Caller); out of the if statement and put it beneeth "game::GetTime" and then you should change the if statement to something realistic :) the one i added was just to show some of the different elements :)

 

Edit: dude you need to remeber {} around the code you want the if statement to include ;)

Link to comment
Share on other sites

20 minutes ago, bma said:

You take the Vehicle v (Caller); out of the if statement and put it beneeth "game::GetTime" and then you should change the if statement to something realistic :) the one i added was just to show some of the different elements :)

Edit: dude you need to remeber {} around the code you want the if statement to include ;)

Told you I was terrible at this stuff :D

It's not crashing now although it doesn't seem to want to activate no matter what the time of day is. Are you able to explain how the timing works as I'm not sure what values mean what.

        void PushActions(GameObject *Caller, Actor *Target, int childID)
        {
                Game::GetTime(Agerskov_hour, Agerskov_minute, Agerskov_second);
                Vehicle v(Caller);
                {
		if(Agerskov_hour > 7 && Agerskov_hour < 17 && Agerskov_minute == 0 && Agerskov_second < 4)
                		v.EnableTrafficLight(TLT_YELLOW);
                		v.AssignCommand(CMD_WWTD_OFF);
                		v.RemoveCommand(CMD_WWTD_ON);
                		Audio::PlaySample3D(SND_TOGGLE, v.GetPosition());
	}
        }
};

 

Link to comment
Share on other sites

if(Agerskov_hour > 7 && Agerskov_hour < 18)

okay, lets take a basic lesson in if statements. 

&& means AND and || means OR. 

your current if statement says: 

Agerskov_hour > 7 && Agerskov_hour < 17 && Agerskov_minute == 0 && Agerskov_second < 4

So what this means is that before the statement is true, all of the following criterias has to be true:

- The hour has to be more than 7
- The hour has to be less than 17
- The minut has to be 0
- The second has to be less than 4

If just one of theese things are false it won't work. 

 

What you are looking for is proberly something like
- Hour is more than 7 
- Hour is less than 18

if(Agerskov_hour > 7 && Agerskov_hour < 18)
Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.



×
×
  • Create New...