Tomato Cat
Senior Member
Posts: 287
Threads: 2
Joined: Sep 2012
Reputation:
20
|
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:
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:
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") == 3 && 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 |
|
serbusfish
Member
Posts: 211
Threads: 75
Joined: Aug 2012
Reputation:
0
|
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 |
|
PutraenusAlivius
Posting Freak
Posts: 4,713
Threads: 75
Joined: Dec 2012
Reputation:
119
|
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 |
|
Tomato Cat
Senior Member
Posts: 287
Threads: 2
Joined: Sep 2012
Reputation:
20
|
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:
void PullCoalLever(string &in asEntity, int 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.
void ElevatorStartFunction(parameters) { if(alState == 1) //Executed if the lever is pulled { //If it is pulled, checks if repairs are complete if(GetLocalVarInt("LeverOn") == 1 && 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 |
|
serbusfish
Member
Posts: 211
Threads: 75
Joined: Aug 2012
Reputation:
0
|
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:
void PullCoalLever(string &in asEntity, int 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.
void ElevatorStartFunction(parameters) { if(alState == 1) //Executed if the lever is pulled { //If it is pulled, checks if repairs are complete if(GetLocalVarInt("LeverOn") == 1 && 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
|
|
05-09-2013, 05:59 PM |
|
serbusfish
Member
Posts: 211
Threads: 75
Joined: Aug 2012
Reputation:
0
|
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 |
|
PutraenusAlivius
Posting Freak
Posts: 4,713
Threads: 75
Joined: Dec 2012
Reputation:
119
|
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 |
|
|