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
Lever help
Storfigge Offline
Member

Posts: 101
Threads: 31
Joined: Sep 2012
Reputation: 0
#1
Lever help

I have two levers in my map. One which is suppose to activate the other lever and that lever is suppose to change map when you pull it. For some reason I can't find out why I change map when I pull the first lever instead??
Here's the code.

void OnStart()
{
AddEntityCollideCallback("Player", "armour_script", "armour", true, 1);
AddEntityCollideCallback("Player", "laugh_1", "laugh1", true, 1);
AddUseItemCallback("", "hollow_needle_1", "castle_9", "unlock_door", true);
AddEntityCollideCallback("elevator_cogwheel01_1", "Cog1", "attach1", true, 1);
AddEntityCollideCallback("elevator_cogwheel02_1", "Cog2", "attach2", true, 1);
AddEntityCollideCallback("elevator_cogwheel03_1", "Cog3", "attach3", true, 1);
SetLocalVarInt("CogCount", 0);
AddEntityCollideCallback("cog_1", "Cog1", "Elevator_start", true, 1);
AddEntityCollideCallback("cog_2", "Cog2", "Elevator_start", true, 1);
AddEntityCollideCallback("cog_3", "Cog3", "Elevator_start", true, 1);
SetEntityConnectionStateChangeCallback("elevator_machine_main_lever_1", "e_lever");
AddEntityCollideCallback("Player", "ScriptArea_1", "scripta", true, 1);
AddEntityCollideCallback("Player", "doll_poof", "poof", true, 1);
AddEntityCollideCallback("Player", "throw_g", "throw", true, 1);
SetEntityConnectionStateChangeCallback("elevator_lever_1", "ele_lever");
}

void armour(string &in asParent, string &in asChild, int alState)
{
SetPropStaticPhysics("armour_1", false);
SetPropStaticPhysics("armour_2", false);
SetPropStaticPhysics("armour_3", false);
SetPropStaticPhysics("armour_4", false);
SetPropStaticPhysics("armour_5", false);
SetPropStaticPhysics("armour_6", false);
AddPropImpulse("armour_1", -2, -2, -2, "world");
AddPropImpulse("armour_2", -2, -2, -2, "world");
AddPropImpulse("armour_3", -2, -2, -2, "world");
AddPropImpulse("armour_4", -2, -2, -2, "world");
AddPropImpulse("armour_5", -2, -2, -2, "world");
AddPropImpulse("armour_6", -2, -2, -2, "world");
GiveSanityDamage(19.0f, true);
}

void laugh1(string &in asParent, string &in asChild, int alState)
{
PlaySoundAtEntity("", "00_laugh.snt", "Player", 0, true);
}

void unlock_door(string &in asItem, string &in asEntity)
{
SetSwingDoorLocked("castle_9", false, true);
PlaySoundAtEntity("", "unlock_door", "castle_9", 0, false);
RemoveItem("hollow_needle_1");
}

void attach1(string &in asParent, string &in asChild, int alState)
{
SetEntityActive("cog_1", true);
SetEntityActive("elevator_cogwheel01_1", false);
PlaySoundAtEntity("", "wheel_metal_min_max.snt", "Player", 0, false);
}

void attach2(string &in asParent, string &in asChild, int alState)
{
SetEntityActive("cog_2", true);
SetEntityActive("elevator_cogwheel02_1", false);
PlaySoundAtEntity("", "wheel_metal_min_max.snt", "Player", 0, false);
}

void attach3(string &in asParent, string &in asChild, int alState)
{
SetEntityActive("cog_3", true);
SetEntityActive("elevator_cogwheel03_1", false);
PlaySoundAtEntity("", "wheel_metal_min_max.snt", "Player", 0, false);
}

void Elevator_start(string &in asParent, string &in asChild, int alState)
{
AddLocalVarInt("CogCount", 1);
if (GetLocalVarInt("CogCount")==3)
{
SetLeverStuckState("elevator_machine_main_lever_1", 0, true);
}
}

void e_lever(string &in asEntity, int alState)
{
SetEntityActive("ScriptArea_1", true);
SetLeverStuckState("elevator_lever_1", 0, true);
RotatePropToSpeed("elevator_machine_cog_main_1", 1, 1.5, 1, 0, 0, false, "");
RotatePropToSpeed("elevator_machine_cog_small_3", 1, 1.5, 1, 0, 0, false, "");
RotatePropToSpeed("elevator_machine_cog_small_2", 1, 1.5, 0, 0, 1, false, "");
RotatePropToSpeed("elevator_machine_cog_small_1", 1, 1.5, 0, 0, 1, false, "");
RotatePropToSpeed("cog_1", 1, 1.5, 0, 0, 1, false, "");
RotatePropToSpeed("cog_2", 1, 1.5, 0, 0, 1, false, "");
RotatePropToSpeed("cog_3", 1, 1.5, 0, 0, 1, false, "");
PlaySoundAtEntity("", "13_press_done.snt", "Player", 0, false);
PlaySoundAtEntity("", "13_machine_run_custom.snt", "elevator_machine_cog_small_2", 0, false);
}

void DoorLockedPlayer(string &in entity)
{
if(GetSwingDoorLocked("castle_4") == true)
{

SetMessage("Messages", "msgname8", 0);
}
}

void scripta(string &in asParent, string &in asChild, int alState)
{
PlaySoundAtEntity("", "19_creak.snt", "Player", 0, false);
SetEntityActive("ceiling_doll_1", true);
SetEntityActive("ceiling_doll_2", true);
SetEntityActive("doll_poof", true);
SetEntityActive("blood_spatter03_1", true);
SetEntityActive("blood_spatter03_2", true);
SetEntityActive("blood_spatter03_3", true);
SetEntityActive("throw_g", true);
}


void poof(string &in asParent, string &in asChild, int alState)
{
AddTimer("T1", 1.5f, "Timer_1");
}

void Timer_1(string &in asTimer)
{
SetEntityActive("ceiling_doll_2", false);
CreateParticleSystemAtEntity("Player", "ps_debris_tunnel.ps", "ceiling_doll_2", true);
GiveSanityDamage(20.0f, true);
PlaySoundAtEntity("", "03_in_a_bottle.snt", "Player", 0, false);
}

void throw(string &in asParent, string &in asChild, int alState)
{
SetEntityActive("throw_grunt", true);
AddPropImpulse("throw_grunt", 0, 0, -10, "world");
}

void ele_lever(string &in asEntity, int alState)
{
PlaySoundAtEntity("", "14_elevator_activate.snt", "Player", 0, false);
PlaySoundAtEntity("", "elevator_move_normal.snt", "Player", 0, false);
AddTimer("T1", 4.0f, "Timer_2");
}

void Timer_2(string &in asTimer)
{
ChangeMap("Dungeons_1.map", "PlayerStartArea_1", "", "");
}



void OnEnter()
{
PlayMusic("10_amb.ogg", true, 2, 2, 0, true);
}


void OnLeave()
{

}


elevator_lever_1 is suppose to change map.

05-01-2013, 06:11 PM
Find
OriginalUsername Offline
Posting Freak

Posts: 896
Threads: 42
Joined: Feb 2013
Reputation: 34
#2
RE: Lever help

Could you clean it up a little? Like just posting the lines you're having trouble with, it's easier to spot the mistake Wink
Also, do you have all the names right? So lever1 activates lever2, etc.?
05-01-2013, 06:19 PM
Find
WALP Offline
Posting Freak

Posts: 1,221
Threads: 34
Joined: Aug 2012
Reputation: 45
#3
RE: Lever help

Make your script more readable by deleting everything that is not related to the lever before you ask for help please.
05-01-2013, 06:21 PM
Find
Storfigge Offline
Member

Posts: 101
Threads: 31
Joined: Sep 2012
Reputation: 0
#4
RE: Lever help

Sorry guys Tongue

void OnStart()
{
AddEntityCollideCallback("cog_1", "Cog1", "Elevator_start", true, 1);
AddEntityCollideCallback("cog_2", "Cog2", "Elevator_start", true, 1);
AddEntityCollideCallback("cog_3", "Cog3", "Elevator_start", true, 1);
SetEntityConnectionStateChangeCallback("elevator_machine_main_lever_1", "e_lever");
SetEntityConnectionStateChangeCallback("elevator_lever_1", "ele_lever");
}


void Elevator_start(string &in asParent, string &in asChild, int alState)
{
AddLocalVarInt("CogCount", 1);
if (GetLocalVarInt("CogCount")==3)
{
SetLeverStuckState("elevator_machine_main_lever_1", 0, true);
}
}

void e_lever(string &in asEntity, int alState)
{
SetEntityActive("ScriptArea_1", true);
SetLeverStuckState("elevator_lever_1", 0, true);
RotatePropToSpeed("elevator_machine_cog_main_1", 1, 1.5, 1, 0, 0, false, "");
RotatePropToSpeed("elevator_machine_cog_small_3", 1, 1.5, 1, 0, 0, false, "");
RotatePropToSpeed("elevator_machine_cog_small_2", 1, 1.5, 0, 0, 1, false, "");
RotatePropToSpeed("elevator_machine_cog_small_1", 1, 1.5, 0, 0, 1, false, "");
RotatePropToSpeed("cog_1", 1, 1.5, 0, 0, 1, false, "");
RotatePropToSpeed("cog_2", 1, 1.5, 0, 0, 1, false, "");
RotatePropToSpeed("cog_3", 1, 1.5, 0, 0, 1, false, "");
PlaySoundAtEntity("", "13_press_done.snt", "Player", 0, false);
PlaySoundAtEntity("", "13_machine_run_custom.snt", "elevator_machine_cog_small_2", 0, false);
}

void ele_lever(string &in asEntity, int alState)
{
PlaySoundAtEntity("", "14_elevator_activate.snt", "Player", 0, false);
PlaySoundAtEntity("", "elevator_move_normal.snt", "Player", 0, false);
AddTimer("T1", 4.0f, "Timer_2");
}

void Timer_2(string &in asTimer)
{
ChangeMap("Dungeons_1.map", "PlayerStartArea_1", "", "");
}

void OnEnter()
{
PlayMusic("10_amb.ogg", true, 2, 2, 0, true);
}


void OnLeave()
{

}

05-01-2013, 06:32 PM
Find
WALP Offline
Posting Freak

Posts: 1,221
Threads: 34
Joined: Aug 2012
Reputation: 45
#5
RE: Lever help

what does the cogweels do?
05-01-2013, 07:08 PM
Find
Tomato Cat Offline
Senior Member

Posts: 287
Threads: 2
Joined: Sep 2012
Reputation: 20
#6
RE: Lever help

Ok, I'm guessing that if you pull the machine_lever, it will start the machinery if all the parts are correct etc etc, and elevator_lever starts the elevator if the machinery is active?

Now, is the problem with being able to pull elevator_lever before being able to pull machine_lever? Or is it pulling machine_lever and changing the map?
05-01-2013, 07:16 PM
Find
Storfigge Offline
Member

Posts: 101
Threads: 31
Joined: Sep 2012
Reputation: 0
#7
RE: Lever help

(05-01-2013, 07:16 PM)Mr Credits Wrote: Ok, I'm guessing that if you pull the machine_lever, it will start the machinery if all the parts are correct etc etc, and elevator_lever starts the elevator if the machinery is active?

Now, is the problem with being able to pull elevator_lever before being able to pull machine_lever? Or is it pulling machine_lever and changing the map?

The problem is that when i pull elevator_machine_main_lever_1 I change map. i'm suppose ti change map when I pull elevator_lever_1.

05-01-2013, 08:40 PM
Find
Tomato Cat Offline
Senior Member

Posts: 287
Threads: 2
Joined: Sep 2012
Reputation: 20
#8
RE: Lever help

I'm assuming the elevator lever is stuck in the map editor, right?

Lets say it's stuck at -1. "Down", I think. When you pull the elevator machinery lever, it unsticks the elevator lever to 0. Which is calling the StateChangeCallback, thus changing your map. See, it calls the function when the state changes, regardless of whether it's 1, 0, or -1.

Obviously that isn't what you wish to have happen, so you'll have to change it. Try this:

PHP Code: (Select All)
void ele_lever(string &in asEntityint alState)
{

    if(
alState == 1//Up, I think
    
{
       
PlaySoundAtEntity("""14_elevator_activate.snt""Player"0false);
       
PlaySoundAtEntity("""elevator_move_normal.snt""Player"0false);
       
AddTimer("T1"4.0f"Timer_2");
     }

(This post was last modified: 05-01-2013, 09:57 PM by Tomato Cat.)
05-01-2013, 09:44 PM
Find
Storfigge Offline
Member

Posts: 101
Threads: 31
Joined: Sep 2012
Reputation: 0
#9
RE: Lever help

No. One lever is support to tp me to another map, the second 1. Bit instead it's the first lever that tp me even though i haven't programmed it to do so.

05-02-2013, 01:22 PM
Find
PutraenusAlivius Offline
Posting Freak

Posts: 4,713
Threads: 75
Joined: Dec 2012
Reputation: 119
#10
RE: Lever help

(05-01-2013, 06:32 PM)Storfigge Wrote: Sorry guys Tongue

void OnStart()
{
AddEntityCollideCallback("cog_1", "Cog1", "Elevator_start", true, 1);
AddEntityCollideCallback("cog_2", "Cog2", "Elevator_start", true, 1);
AddEntityCollideCallback("cog_3", "Cog3", "Elevator_start", true, 1);
SetEntityConnectionStateChangeCallback("elevator_machine_main_lever_1", "e_lever");
SetEntityConnectionStateChangeCallback("elevator_lever_1", "ele_lever");
SetLocalVarInt("CogCount", 0); //I added this because I found out the LocalVarInt hasn't been called yet.
SetLocalVarInt("MachineryRun", 0);
}


void Elevator_start(string &in asParent, string &in asChild, int alState)
{
AddLocalVarInt("CogCount", 1);
if (GetLocalVarInt("CogCount")==3)
{
SetLeverStuckState("elevator_machine_main_lever_1", 0, true);
}
}

void e_lever(string &in asEntity, int alState)
{
SetEntityActive("ScriptArea_1", true);
SetLeverStuckState("elevator_lever_1", 0, true);
RotatePropToSpeed("elevator_machine_cog_main_1", 1, 1.5, 1, 0, 0, false, "");
RotatePropToSpeed("elevator_machine_cog_small_3", 1, 1.5, 1, 0, 0, false, "");
RotatePropToSpeed("elevator_machine_cog_small_2", 1, 1.5, 0, 0, 1, false, "");
RotatePropToSpeed("elevator_machine_cog_small_1", 1, 1.5, 0, 0, 1, false, "");
RotatePropToSpeed("cog_1", 1, 1.5, 0, 0, 1, false, "");
RotatePropToSpeed("cog_2", 1, 1.5, 0, 0, 1, false, "");
RotatePropToSpeed("cog_3", 1, 1.5, 0, 0, 1, false, "");
PlaySoundAtEntity("", "13_press_done.snt", "Player", 0, false);
PlaySoundAtEntity("", "13_machine_run_custom.snt", "elevator_machine_cog_small_2", 0, false);
AddLocalVarInt("MachineryRun", 1);
}

void ele_lever(string &in asEntity, int alState)
{
if(GetLocalVarInt("MachineryRun") == 1);
{
PlaySoundAtEntity("", "14_elevator_activate.snt", "Player", 0, false);
PlaySoundAtEntity("", "elevator_move_normal.snt", "Player", 0, false);
AddTimer("T1", 4.0f, "Timer_2");
}
}

void Timer_2(string &in asTimer)
{
ChangeMap("Dungeons_1.map", "PlayerStartArea_1", "", "");
}

void OnEnter()
{
PlayMusic("10_amb.ogg", true, 2, 2, 0, true);
}


void OnLeave()
{

}

"Veni, vidi, vici."
"I came, I saw, I conquered."
05-02-2013, 01:33 PM
Find




Users browsing this thread: 1 Guest(s)