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 Elevator Lever to Level Transition
Mudbill Offline
Muderator

Posts: 3,881
Threads: 59
Joined: Apr 2013
Reputation: 179
#4
RE: Elevator Lever to Level Transition

First off you can remove those Once, Twice, Thrice scripts and use a single one with parameters to shorten the code.

PHP Code: (Select All)
void RodMeOnce(string &in asItemstring &in asEntity)
{
    
SetEntityActive(asEntity "_stat"true);
    
PlaySoundAtEntity("""13_rod_in.snt""rods"0false);
    
RemoveItem(asEntity);
    
AddLocalVarInt("Rods"1);
    
    if(
GetLocalVarInt("Rods") == 3)
    {
        
PlaySoundAtEntity("""13_machine_extra.snt""machine_sound"0false);
        
PlaySoundAtEntity("""13_machine_run.snt""machine_sound"0false);
    }


Do the sounds play though? I think the script stops right there. There are only those three callbacks when you enter, and those three code blocks (which could be only one) don't seem to advance the script to the other ones. Unless you have callbacks added to entities in the level? I'm guessing you do at least for the levers. I can't really check the level at the moment though.



This script might not do what you want it to. Let's just see what will happen if done.

PHP Code: (Select All)
void LeverBox(string &in asEntityint LeverState)
{
    if(
GetLeverState("lever_machine_lever_1") == -1
    
&& GetLeverState("lever_machine_lever_2") == -1
    
&& GetLeverState("lever_machine_lever_3") == -1
    
&& GetLeverState("lever_machine_lever_4") == -1
    
&& GetLeverState("lever_machine_lever_5") == -1
    
&& GetLeverState("lever_machine_lever_6") == -1)
        {
            
PlaySoundAtEntity("""sob01.snt""Player"0false);
            
SetEntityActive("elevator_lever_1"false);
            
SetEntityActive("elevator_lever_2"true);
                
            for(
int i 1<= 6i++)
            
SetEntityInteractionDisabled("lever_machine_lever_"+itrue);
        }
        
    if(
GetLeverState("elevator_lever_2") == -1)
    {
        
SetEntityPlayerInteractCallback("elevator_lever_2""Activate"true);
    }


Is this callback added to all the lever_machine_lever entities? Anything else?

Pulling all lever_machine_lever to state -1 will activate the main code, which plays some sounds and changes the elevator_lever entity. To prevent this some happening again, interaction is disabled for these levers. The last part will only activate if elevator_lever_2 is already set to state -1 before the other levers are set, or else they will remain uninteractable and can not call the code. Because elevator_lever_2 is enabled after pulling the other levers, this can cause it to not be finished, unless this callback is also added to the elevator_lever_2, however if so, it will also run the main code again once pulled, because even though the other levers are uninteractable, they're still in state -1 which will pass the code.

(This post was last modified: 11-26-2014, 08:46 AM by Mudbill.)
11-26-2014, 08:31 AM
Find


Messages In This Thread
Elevator Lever to Level Transition - by AGP - 11-26-2014, 06:39 AM
RE: Elevator Lever to Level Transition - by AGP - 11-26-2014, 07:51 AM
RE: Elevator Lever to Level Transition - by Mudbill - 11-26-2014, 08:31 AM
RE: Elevator Lever to Level Transition - by AGP - 11-26-2014, 08:48 AM
RE: Elevator Lever to Level Transition - by AGP - 11-26-2014, 08:38 AM
RE: Elevator Lever to Level Transition - by AGP - 11-26-2014, 08:57 AM
RE: Elevator Lever to Level Transition - by AGP - 11-26-2014, 09:03 AM
RE: Elevator Lever to Level Transition - by AGP - 11-26-2014, 09:13 AM
RE: Elevator Lever to Level Transition - by AGP - 11-26-2014, 09:36 AM



Users browsing this thread: 1 Guest(s)