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
#21
RE: Setting up the elevator machine

How about a combination of both?

Like you were saying, you can check the state (the alState parameter) that the lever without having to lock it in place by doing something similar to this:

PHP Code: (Select All)
void LeverFunction(parameters etcetc//This is the function that is called when you pull the lever
{

   if(
alState == 1//Experiment with "1" & "-1". I think 1 is up, and -1 is down.
   
{
      
//Code to do here if the lever is pulled to the aforementioned state
   
}



However, you don't want the machine to start if the repairs aren't complete! To solve this, we'll need some code in the lever function will check if everything is complete.

Do you remember how we set those local integers? "Coal" and "Cogs?" We can use them to see if the machine's repairs are finished:

PHP Code: (Select All)
void leverfunction blahblah //Lever callback, sorry for my shorthand =p
{
   if(
alState == 1//This checks if the lever is pulled
   
{
     
      
//If it is pulled, checks if repairs are complete
      
if(GetLocalVarInt("Coal") == &&  GetLocalVarInt("Cogs") == 3)
      {
         
//This block is executed if everything is complete
         //Run your machine startup routine here
      
}

      else
      {
        
//This block executes if something isn't finished
       
}
   }


I hope it gives you a general idea. Adjust it to your liking!
05-09-2013, 02:57 PM
Find
serbusfish Offline
Member

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

I'm just about ready to cry at this!

The main problem im facing is if I move frictional's part of the script to the onstart section it throws up errors and wont load, but leaving it where it is means your solutions cant be implemented (unless im doing it wrong?).

void PullStartLever(string &in asEntity, int alState)
{
if(alState == -1) AddDebugMessage("Lever Min", false);
else if (alState == 1) StartMachine(asEntity);
}
/*If all settings correct start the machine, if not do a hickup start
*/
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)

PullStartLever in this case is linked to the main machine lever, when it is pulled it does the Var checks, somewhere in here I need another check for the other lever. Perhaps im missing something obvious but I just cant get it working. I tried adding this before the PullStartLever command:

void PullCoalLever(string &in asEntity, int alState)

{
if(alState == 1) AddLocalVarInt("LeverOn", 1);
}

but this just stops the machine from starting even if the burner is running. I guess in this case im using the AddLocalVarInt command wrong?

05-09-2013, 04:37 PM
Find
PutraenusAlivius Offline
Posting Freak

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

(05-09-2013, 04:37 PM)serbusfish Wrote: I'm just about ready to cry at this!

The main problem im facing is if I move frictional's part of the script to the onstart section it throws up errors and wont load, but leaving it where it is means your solutions cant be implemented (unless im doing it wrong?).

void PullStartLever(string &in asEntity, int alState)
{
if(alState == -1) AddDebugMessage("Lever Min", false);
else if (alState == 1) StartMachine(asEntity);
}
/*If all settings correct start the machine, if not do a hickup start
*/
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)

PullStartLever in this case is linked to the main machine lever, when it is pulled it does the Var checks, somewhere in here I need another check for the other lever. Perhaps im missing something obvious but I just cant get it working. I tried adding this before the PullStartLever command:

void PullCoalLever(string &in asEntity, int alState)

{
if(alState == 1) AddLocalVarInt("LeverOn", 1);
}

but this just stops the machine from starting even if the burner is running. I guess in this case im using the AddLocalVarInt command wrong?
void PullCoalLever(string &in asEntity, int alState)
{
if(alState == 1)
{
AddLocalVarInt("LeverOn", 1);
}
}

"Veni, vidi, vici."
"I came, I saw, I conquered."
05-09-2013, 04:53 PM
Find
Tomato Cat Offline
Senior Member

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

Just forget about FG's script and focus on building your own. Believe me, it's easier because you'll know precisely what's going.

I actually forgot about the coal lever. Instead of the elevator lever, the coal lever should check if the "Coal" variable is equal to 3.

Modify it like so:

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

{
   if(
alState == 1//Executed if the lever is pulled
   
{
       if(
GetLocalVarInt("Coal") == 3)) //Checks to see if all coal is inside
       

         
AddLocalVarInt("LeverOn"1); //This is what we'll check when we pull the elevator starting lever
        
}
    }


Ok, now the elevator lever will check if LeverOn is equal to 1.

PHP Code: (Select All)
void ElevatorStartFunction(parameters)
{
   if(
alState == 1//Executed if the lever is pulled
   
{
     
      
//If it is pulled, checks if repairs are complete
      
if(GetLocalVarInt("LeverOn") == &&  GetLocalVarInt("Cogs") == 3)
      {
         
//This block is executed if everything is complete
         //Run your machine startup routine here
      
}

      else
      {
        
//This block executes if something isn't finished
       
}
   }


That should fix it, given you've declared your callbacks/variables. Unless this isn't the issue you're having. ~.o
(This post was last modified: 05-09-2013, 05:25 PM by Tomato Cat.)
05-09-2013, 05:24 PM
Find
serbusfish Offline
Member

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

(05-09-2013, 05:24 PM)Tomato Cat Wrote: Just forget about FG's script and focus on building your own. Believe me, it's easier because you'll know precisely what's going.

I actually forgot about the coal lever. Instead of the elevator lever, the coal lever should check if the "Coal" variable is equal to 3.

Modify it like so:

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

{
   if(
alState == 1//Executed if the lever is pulled
   
{
       if(
GetLocalVarInt("Coal") == 3)) //Checks to see if all coal is inside
       

         
AddLocalVarInt("LeverOn"1); //This is what we'll check when we pull the elevator starting lever
        
}
    }


Ok, now the elevator lever will check if LeverOn is equal to 1.

PHP Code: (Select All)
void ElevatorStartFunction(parameters)
{
   if(
alState == 1//Executed if the lever is pulled
   
{
     
      
//If it is pulled, checks if repairs are complete
      
if(GetLocalVarInt("LeverOn") == &&  GetLocalVarInt("Cogs") == 3)
      {
         
//This block is executed if everything is complete
         //Run your machine startup routine here
      
}

      else
      {
        
//This block executes if something isn't finished
       
}
   }


That should fix it, given you've declared your callbacks/variables. Unless this isn't the issue you're having. ~.o

Yes you're right, I wanted to stick with it because apart from that one little detail it works as intended.

I will strip it out and build my own, hopefully I will get it working ok Tongue

05-09-2013, 05:59 PM
Find
serbusfish Offline
Member

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

Btw as im thinking about it, when in game on Frictional's level the coal pieces are black, but in mine they are red, how do they manage this as in the editor for both they are red?

05-10-2013, 12:53 AM
Find
PutraenusAlivius Offline
Posting Freak

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

(05-10-2013, 12:53 AM)serbusfish Wrote: Btw as im thinking about it, when in game on Frictional's level the coal pieces are black, but in mine they are red, how do they manage this as in the editor for both they are red?

The coal are both red.

"Veni, vidi, vici."
"I came, I saw, I conquered."
05-10-2013, 01:00 AM
Find




Users browsing this thread: 1 Guest(s)