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
Multiple Issues Help Setting up the elevator machine
Tomato Cat Offline
Senior Member

Posts: 287
Threads: 2
Joined: Sep 2012
Reputation: 20
#11
RE: Setting up the elevator machine

As far as the cogwheels/sticky areas go, you have to set the "AttachableBodyName" (The object to be attached) and attach function (Called when said object attaches) in the level editor. Both are found under the "Area" tab. Make sure you uncheck CanDetach, just for this example.


Here's a function you could use:

PHP Code: (Select All)
//But first declare a local variable in OnStart
SetLocalVarInt("Cogs",0);
//You might also have to set sticky area attachment in OnStart, try it with and without
SetAllowStickyAreaAttachment(true);

//This will be called each time a cog attaches
void Mount_Cog(string &in asStickyAreastring &in asBodyName)
{
    if(
GetLocalVarInt("Cogs") <= 3)
    {
        
AddLocalVarInt("Cogs",1);
        
AddDebugMessage("Attaching cog "+asBodyName+" to area "+asStickyArea,false);
        
AddDebugMessage("Cogs is at "+GetLocalVarInt("Cogs"),false);
    }


Try that out and make some adjustments. Let me know how it works!
(This post was last modified: 05-08-2013, 04:12 AM by Tomato Cat.)
05-08-2013, 04:00 AM
Find
serbusfish Offline
Member

Posts: 211
Threads: 75
Joined: Aug 2012
Reputation: 0
#12
RE: Setting up the elevator machine

I'm not sure which areas of that script im supposed to be editing? I take I need to put the names of my cog pieces in there somewhere?

Sorry if im sounding stupid but as it stands im not understanding what each piece of the script is doing, the reason I dont have a problem with making collide callbacks, item pickup commands, etc is that I learnt what each does and how it works, at the moment I just dont 'get' how VarInt' commands work Sad

On the plus side all 3 of my cogs slide onto the correct area and stay there. I guess when the lever is pulled i'll need to de-activate them and active the mounted versions?

05-08-2013, 12:31 PM
Find
Tomato Cat Offline
Senior Member

Posts: 287
Threads: 2
Joined: Sep 2012
Reputation: 20
#13
RE: Setting up the elevator machine

(05-08-2013, 12:31 PM)serbusfish Wrote: I'm not sure which areas of that script im supposed to be editing? I take I need to put the names of my cog pieces in there somewhere?

Sorry if im sounding stupid but as it stands im not understanding what each piece of the script is doing, the reason I dont have a problem with making collide callbacks, item pickup commands, etc is that I learnt what each does and how it works, at the moment I just dont 'get' how VarInt' commands work Sad

On the plus side all 3 of my cogs slide onto the correct area and stay there. I guess when the lever is pulled i'll need to de-activate them and active the mounted versions?

Ah, sorry. I should be more specific.

When you click on a sticky area in the level editor, 2 tabs will appear to the right of the viewing screen called General and Area. General sets the properties for its size, rotation, and name. The Area tab sets more specific things like the item that attaches to it, the function called on attach, the noise that's played on attach etc etc.

The SetLocalVarInt function declares an integer variable that can be used throughout the script it's declared in. In the Mount_Cog function, it's incremented each time a cog attaches. We'll need it for the lever function!

If the cogs mounting and the debug messages are showing, then everything is working! =) As far as making them spin goes, I'm not entirely sure. You may not have to replace them. Try using RotatePropToSpeed on the already mounted cogs.

Also, I recommend you visit the HPL2 function wiki. It provides more in-depth information on each function.
(This post was last modified: 05-08-2013, 02:47 PM by Tomato Cat.)
05-08-2013, 02:46 PM
Find
serbusfish Offline
Member

Posts: 211
Threads: 75
Joined: Aug 2012
Reputation: 0
#14
RE: Setting up the elevator machine

I did it! Well, almost.

Using the scripts you guys provided plus a tiny bit of stealing from Frictionals script (Angel) I have managed to make the machine require 3 pieces of coal + 3 cog wheels, and the cog wheels turn when the machine starts as well as giving sanity boost, play happy music, etc.

However, I have noticed there are still a couple of tiny flaws. First of all basically once 3 coals have been placed in the burner the machine will work, even when you havent pulled the lever to make the burner burn the coal. Obviously this isnt ideal, I want the player to have to pull the handle to start the burner before it will work.

Second problem, ive made it so when you interact with the lever it displays the message saying the machine doesnt have enough coal. Trouble is this message pops up when you spawn into the level for some reason.

void OnStart()

{

SetEntityConnectionStateChangeCallback("coal_lever", "BurnerFail");

}

void BurnerFail(string &in asEntity, int alState)
{
    if(GetLocalVarInt("Coal") < 3)
    {
        SetMessage("Messages", "BurnerNotReady", 0);
    }
}

I have no idea why its doing that?

And my final problem is the burner effects start up as soon as the third piece of coal is placed in the burner, of course i know why this happens im just not really sure how to make this happen with the lever instead?

void CheckCoalCount()
{
if(GetLocalVarInt("Coal") == 3)
{
SetMessage("Messages", "BurnerReady", 0);
PlaySoundAtEntity("BurnerSound", "general_fire_burning", "AreaBurnerParticle", 1, true);
CreateParticleSystemAtEntity("Fire", "ps_fire_stove_small.ps", "AreaBurnerParticle", true);
    }

(This post was last modified: 05-09-2013, 03:35 AM by serbusfish.)
05-09-2013, 03:28 AM
Find
PutraenusAlivius Offline
Posting Freak

Posts: 4,713
Threads: 75
Joined: Dec 2012
Reputation: 119
#15
RE: Setting up the elevator machine

CODE 1
void OnStart()

{

SetEntityConnectionStateChangeCallback("coal_lever", "BurnerFail");

}

void BurnerFail(string &in asEntity, int alState)
{
    if(alState == 1) //1 up, -1 down, 0 between
        {
               if(GetLocalVarInt("Coal") < 3)
           {
           SetMessage("Messages", "BurnerNotReady", 0);
               }

              else
              {
               //Put command here... (Delete the else part if you already had another parameter for the success coal part.
              }
        }
}

CODE 2
void CheckCoalCount()
{
if(GetLocalVarInt("Coal") == 3)
{
SetMessage("Messages", "BurnerReady", 0);
PlaySoundAtEntity("BurnerSound", "general_fire_burning", "AreaBurnerParticle", 1, true);
CreateParticleSystemAtEntity("Fire", "ps_fire_stove_small.ps", "AreaBurnerParticle", true);
//Put the CPSAT and the PSAT on the machinery lever part.
}

"Veni, vidi, vici."
"I came, I saw, I conquered."
05-09-2013, 03:47 AM
Find
Tomato Cat Offline
Senior Member

Posts: 287
Threads: 2
Joined: Sep 2012
Reputation: 20
#16
RE: Setting up the elevator machine

You can merge this:

PHP Code: (Select All)
void CheckCoalCount()
{
if(
GetLocalVarInt("Coal") == 3
{
SetMessage("Messages""BurnerReady"0);
PlaySoundAtEntity("BurnerSound""general_fire_burning""AreaBurnerParticle"1true);
CreateParticleSystemAtEntity("Fire""ps_fire_stove_small.ps""AreaBurnerParticle"true);
    }


With your existing Burner function:

PHP Code: (Select All)
void BurnerFail(string &in asEntityint alState
{
    if(
alState == 1//1 up, -1 down, 0 between
        
{
               if(
GetLocalVarInt("Coal") < 3)
           {
           
SetMessage("Messages""BurnerNotReady"0);
           }
              
               
//Like JAP was saying. "else if" will test if the initial "if" was false
              
else if(GetLocalVarInt("Coal") == 3)
              {
                
//Basically copy your CheckCoalCount function here.
                //Using this else if, you don't have to create an entirely new function
              
}
        }


Let me clarify a few things. Is the machine itself starting when the burner lever is pulled, or is it that you can pull the burner lever before the coal pieces are in?
(This post was last modified: 05-09-2013, 04:21 AM by Tomato Cat.)
05-09-2013, 04:21 AM
Find
serbusfish Offline
Member

Posts: 211
Threads: 75
Joined: Aug 2012
Reputation: 0
#17
RE: Setting up the elevator machine

(05-09-2013, 03:47 AM)JustAnotherPlayer Wrote: CODE 1
(snip)

CODE 2
(snip)

Thanks a lot dude that's sorted out both of those problems Smile

(05-09-2013, 04:21 AM)Tomato Cat Wrote: Let me clarify a few things. Is the machine itself starting when the burner lever is pulled, or is it that you can pull the burner lever before the coal pieces are in?

The machine has a main start lever near the cogs as well as the burner lever. If 3 coal are in the burner the machine will start if I pull the start lever even though I havent yet pulled the coal burner lever.

I have thought of a way around this, I can make it so when the coal lever is pulled to 1 position and 3 coals are in place it will become stuck.

Now at the moment the script checks the cog amount and coal amount before the machine will start, so here I could put another check in place that checks that the lever position is at 1, THEN make the machine start.

The problem is im not sure what command will do this? For the others I have "GetLocalVarInt" but that wont work for lever position, is there something like "GetalState" or something like that that'll check the state of the lever? Ive looked through the engine scripts webpage but dont see anything like that.

05-09-2013, 02:13 PM
Find
PutraenusAlivius Offline
Posting Freak

Posts: 4,713
Threads: 75
Joined: Dec 2012
Reputation: 119
#18
RE: Setting up the elevator machine

It's
PHP Code: (Select All)
if(alState == 1//1 up, -1 down, 0 between
{


"Veni, vidi, vici."
"I came, I saw, I conquered."
05-09-2013, 02:27 PM
Find
serbusfish Offline
Member

Posts: 211
Threads: 75
Joined: Aug 2012
Reputation: 0
#19
RE: Setting up the elevator machine

(05-09-2013, 02:27 PM)JustAnotherPlayer Wrote: It's
PHP Code: (Select All)
if(alState == 1//1 up, -1 down, 0 between
{


But how do I tell it which lever should be at that state? As it stands it is checking the 'LocalVarInt' for Wheels and Coal, there is no lever currently defined.

Here is the actual code I have (its from frictionals script and is placed before the onstart bit, its a bit strange but it works):

void StartMachine(string sEntity)
{
    PlaySoundAtEntity("s1"+sEntity, "13_ignite", sEntity, 0.2f, false);
    PlaySoundAtEntity("s2"+sEntity, "13_machine_fail", sEntity, 0.2f, false);

    if(GetLocalVarInt("WheelOK") == 3 && GetLocalVarInt("Coal") == 3)
    {
        for(int i=1;i<=6;i++){
            CreateParticleSystemAtEntity("DoneP"+i, "ps_steam.ps", "DoneParticles_"+i, true);
            PlaySoundAtEntity("DoneS"+i, "13_steam", "DoneParticles_"+i, 0.5, true);
        }
        for(int i=1;i<=8;i++)
            CreateParticleSystemAtEntity("SteamP"+i, "ps_steam_cloud.ps", "SteamCloud_"+i, true);
        
        SetGlobalVarInt("ElevatorMachineRunning", 1);
        
        
        
        StartScreenShake(0.03f, 2.0f, 0.5f,1.5f);
        
        PlaySoundAtEntity("s3"+sEntity, "13_machine_run", sEntity, 2, true);
        PlaySoundAtEntity("s31"+sEntity, "13_machine_extra", sEntity, 2, true);
        PlaySoundAtEntity("s4"+sEntity, "13_whomp", sEntity, 4, true);
        
        PlayMusic("13_puzzle_machine.ogg", false, 1.0f, 0.5f, 10, false);
        
        GiveSanityBoost();
        
        RunWheels(1.0f,-1.0f);
        
        SetLeverStuckState(sEntity, 1, false);
    }
    else
    {
        StartScreenShake(0.01f, 1.0f, 0.25,0.5f);

        AddTimer("stopwheels", 1, "TimerMachineError");
        
        RunWheels(1.0f,-1.0f);

(This post was last modified: 05-09-2013, 02:52 PM by serbusfish.)
05-09-2013, 02:52 PM
Find
PutraenusAlivius Offline
Posting Freak

Posts: 4,713
Threads: 75
Joined: Dec 2012
Reputation: 119
#20
RE: Setting up the elevator machine

Let's just say it's "MachineryLever". You put that to the function that contains the if else.

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




Users browsing this thread: 3 Guest(s)