Josh707
Junior Member
Posts: 27
Threads: 5
Joined: Apr 2011
Reputation:
0
|
Valve interaction
Hey everyone, I have set up my map with toggle-able light switches and I want to know how to make a valve turn on a heater. I have tried to do SetEntityPlayerInteractCallback("heatervalve", "Turnonheater", true);
then
void Turnonheater(string &in entity)
{
PlaySoundAtEntity("", "22_fire.snt", "geostove", 0, false);
SetLampLit("bonfire", true, false);
}
But the stove turns on as soon as I touch the valve, not when it turns all the way... I have searched the script functions page for everything related to valves, interaction, wheels, buttons etc. and I have not found anything. How do I make it call a function when it's turned to the maximum?
tl;dr How do I make a valve call a function when I turn it all the way?
Try my custom story demo here!
Updated 23/04/11
(This post was last modified: 04-19-2011, 01:51 AM by Josh707.)
|
|
04-19-2011, 01:50 AM |
|
Anxt
Senior Member
Posts: 588
Threads: 12
Joined: Mar 2011
Reputation:
10
|
RE: Valve interaction
Select the object in the map editor that has the wheel on it. Go to the entity tab, and where it says "ConnectionStateChangeCallback" or something of the sort, type in the TurnOnHeater function name.
Then, make your function look like this:
void Turnonheater(string &in entity)
{
if(alState==1)
{
PlaySoundAtEntity("", "22_fire.snt", "geostove", 0, false);
SetLampLit("bonfire", true, false);
}
}
Get rid of the SetEntityPlayerInteractCallback you have as well, it will mess it up.
|
|
04-19-2011, 01:56 AM |
|
Josh707
Junior Member
Posts: 27
Threads: 5
Joined: Apr 2011
Reputation:
0
|
RE: Valve interaction
Error says: 'alState' is not declared, and Expression must be of boolean type
at the start you said the object that has the wheel on it, I just have a valve (rotating wheel with nothing behind it) stuck into the wall. Is that a problem or do I need to use a certain type of valve?
Try my custom story demo here!
Updated 23/04/11
(This post was last modified: 04-19-2011, 02:04 AM by Josh707.)
|
|
04-19-2011, 02:00 AM |
|
Apjjm
Is easy to say
Posts: 496
Threads: 18
Joined: Apr 2011
Reputation:
52
|
RE: Valve interaction
You will want the function "SetEntityConnectionStateChangeCallback" for that job.
Quote:void SetEntityConnectionStateChangeCallback(string& asName, string& asCallback);
A callback called when ever the connection state changes (button being switched on, lever switched, etc).
Callback syntax: void Func(string &in EntityName, int alState)
alState: -1 = off, 0 = between, 1 = on
E.g:
void OnStart()
{
SetEntityConnectionStateChangeCallback("valve", "callback_func");
}
void callback_func(string &in EntityName, int alState)
{
//Called when the var alState of the lever/valve changes between:
// -1 (off), 0 (middle), 1 (on)
if(alState == 1)
{ //Turn object on
}
else if(alState ==-1)
{ //Turn object off
}
}
(This post was last modified: 04-19-2011, 02:04 AM by Apjjm.)
|
|
04-19-2011, 02:04 AM |
|
Anxt
Senior Member
Posts: 588
Threads: 12
Joined: Mar 2011
Reputation:
10
|
RE: Valve interaction
Oh sorry, forgot to fix the function name. My bad. Should be:
void Turnonheater(string &in entity, int alState)
{
if(alState==1)
{
PlaySoundAtEntity("", "22_fire.snt", "geostove", 0, false);
SetLampLit("bonfire", true, false);
}
}
Forgot to add the alState bit. Now it should work.
|
|
04-19-2011, 02:12 AM |
|
Josh707
Junior Member
Posts: 27
Threads: 5
Joined: Apr 2011
Reputation:
0
|
RE: Valve interaction
Thank you! it worked. The first actual advice i've gotten on this forum
Try my custom story demo here!
Updated 23/04/11
(This post was last modified: 04-19-2011, 02:15 AM by Josh707.)
|
|
04-19-2011, 02:14 AM |
|
Anxt
Senior Member
Posts: 588
Threads: 12
Joined: Mar 2011
Reputation:
10
|
RE: Valve interaction
I do my best to help out when I can, if you need anything feel free to send me a PM, that way I will definitely see it.
|
|
04-19-2011, 02:27 AM |
|
Josh707
Junior Member
Posts: 27
Threads: 5
Joined: Apr 2011
Reputation:
0
|
RE: Valve interaction
Sounds good!
Try my custom story demo here!
Updated 23/04/11
|
|
04-19-2011, 12:48 PM |
|
|