serbusfish
Member
Posts: 211
Threads: 75
Joined: Aug 2012
Reputation:
0
|
Setting up the elevator machine
Ive attempted looking for a youtube tutorial on this but all I get are walkthoughs for the elevator part in the main game.
My scenario;
The map is filled with water. There is a lever that will open the drainage system and release all the water, however the machine that powers this is currently missing its cogs and coal. You need to replace the cogs, put a piece of coal in the machine, and then you'll be able to pull the lever and drain the water.
Here is all I have so far:
I know sticky areas need placing on the places where the cogs go, and of course those cogs need to be de-activated and scripted to activate when you place the actual cogs in place, but apart from that im pretty clueless.
Any help on this would be really appreciated, in fact rest assured anyone who can help me with this will get a their own section in the end credits!
|
|
05-07-2013, 01:30 AM |
|
Tomato Cat
Senior Member
Posts: 287
Threads: 2
Joined: Sep 2012
Reputation:
20
|
RE: Setting up the elevator machine
What do you have written so far? Post it and I can help guide you through everything. I would much prefer to help someone who is actively trying rather than just asking for a script on the forums.
|
|
05-07-2013, 02:42 AM |
|
Rapture
Posting Freak
Posts: 1,078
Threads: 79
Joined: May 2011
Reputation:
30
|
RE: Setting up the elevator machine
Do you plan to have a moving elevator or just using one as a "level door"?
|
|
05-07-2013, 03:09 AM |
|
serbusfish
Member
Posts: 211
Threads: 75
Joined: Aug 2012
Reputation:
0
|
RE: Setting up the elevator machine
(05-07-2013, 02:42 AM)Tomato Cat Wrote: What do you have written so far? Post it and I can help guide you through everything. I would much prefer to help someone who is actively trying rather than just asking for a script on the forums.
I dont have anything so far as I dont know where to begin.
I'm not asking for anyone to write the entire thing out for me, I simply need to know where to start, what commands are needed, etc. I have only been scripting since January but I know my way around most of the basic commands, but when it comes to something as complex (I think?) as this machine im a little out of my depth.
(05-07-2013, 03:09 AM)Rapture Wrote: Do you plan to have a moving elevator or just using one as a "level door"?
There is no actual elevator in my map, just the machine. What im planning is having the next level door down a flight of stairs, but because of the water you cant get down to it until its been drained.
I'll put a black box in front of the staircase so you cant go down it, then when the water has gone i'll make it deactivate the black box.
|
|
05-07-2013, 03:14 AM |
|
Tomato Cat
Senior Member
Posts: 287
Threads: 2
Joined: Sep 2012
Reputation:
20
|
RE: Setting up the elevator machine
(05-07-2013, 03:14 AM)serbusfish Wrote: I dont have anything so far as I dont know where to begin.
I'm not asking for anyone to write the entire thing out for me, I simply need to know where to start, what commands are needed, etc. I have only been scripting since January but I know my way around most of the basic commands, but when it comes to something as complex (I think?) as this machine im a little out of my depth.
Oh, no problem. =)
So, you want the player to replace 3 cogwheels, put some coal in and then pull the lever? Not terribly difficult once you get the hang of it. I'll give you a general idea and you can adjust it to your liking.
Let's start with the coal. I assume you're using the default elevator machine's coal burner.
Spawn in some coal pieces and keep the default names. Next, create a script area. Name it area_coal and place it inside the burner.
Then add a collide callback. The callback function will known as "CoalBurner."
AddEntityCollideCallback("coal_*","area_coal","CoalBurner",false,1); //The "*" basically means everything named coal_ and a number
You'll also need this local variable:
SetLocalVarInt("CoalCheck",0); //Place it alongside the collide callback
Now the function! What it essentially does is increment a variable every time a coal piece is added. If enough coal has already been added, the piece will disappear.
void CoalBurner(string &in asParent, string &in asChild, int alState) { if(GetLocalVarInt("CoalCheck") < 3) { //Increments CoalCheck variable and makes the piece disappear AddDebugMessage("Adding coal piece "+asParent,false); AddDebugMessage("Coal check now at "+GetLocalVarInt("CoalCheck"),false); SetPropActiveAndFade(asParent, false, 5.0f); AddLocalVarInt("CoalCheck",1); } else { //Makes the coal piece disappear SetPropActiveAndFade(asParent, false, 3.0f); AddDebugMessage("Too much coal, incinerating!",false); } }
Let me know how that turns out. Then I can help you with the sticky areas, if you like.
|
|
05-07-2013, 04:39 AM |
|
PutraenusAlivius
Posting Freak
Posts: 4,713
Threads: 75
Joined: Dec 2012
Reputation:
119
|
RE: Setting up the elevator machine
void OnStart() { SetLocalVarInt("Cogwheel", 0); SetLocalVarInt("Coal", 0); AddEntityCollideCallback("Coal1", "ScriptAreaCoal", "AddVar1", false, 1); //Change Coal1 to coal num 1 AddEntityCollideCallback("Coal2", "ScriptAreaCoal", "AddVar2", false, 1); //Change Coal2 to coal num 2 AddEntityCollideCallback("Coal3", "ScriptAreaCoal", "AddVar3", false, 1); //Change Coal3 to coal num 3 //You can add more but change the Parent and Function name. }
void AddVar1(string &in asParent, string &in asChild, int alState) { AddLocalVarInt("Coal", 1); CheckCoalCount(); }
void AddVar2(string &in asParent, string &in asChild, int alState) { AddLocalVarInt("Coal", 1); CheckCoalCount(); }
void AddVar3(string &in asParent, string &in asChild, int alState) { AddLocalVarInt("Coal", 1); CheckCoalCount(); }
void CheckCoalCount() { if(GetLocalVarInt("Coal") == 3) //Change 3 to how many coal you want { SetMessage("MsgCat", "MsgEntry", 0); //This is the message that will appear when enough coals are placed. //Place any other commands here... } }
Coal count script.
"Veni, vidi, vici."
"I came, I saw, I conquered."
|
|
05-07-2013, 04:46 AM |
|
serbusfish
Member
Posts: 211
Threads: 75
Joined: Aug 2012
Reputation:
0
|
RE: Setting up the elevator machine
Awesome, thanks a lot guys! Although I will say those 'VarInt' commands are something I havent used before and havent quite got my head around them yet. Im at work today but when I finish tonight I will give this a go
(This post was last modified: 05-07-2013, 12:27 PM by serbusfish.)
|
|
05-07-2013, 12:26 PM |
|
serbusfish
Member
Posts: 211
Threads: 75
Joined: Aug 2012
Reputation:
0
|
RE: Setting up the elevator machine
OK I have tried the script and when I put all 3 pieces of coal into the machine they disappear. Ive also had a mess with the sticky areas and replicated what Frictional did with their machine, and all 3 of the cogs click into place as they should. But that's as far as I have got. I have also put the lever to start the machine in place as well.
|
|
05-08-2013, 01:26 AM |
|
Tomato Cat
Senior Member
Posts: 287
Threads: 2
Joined: Sep 2012
Reputation:
20
|
RE: Setting up the elevator machine
Did you not want the coal to disappear?
Use this for the lever:
SetEntityConnectionStateChangeCallback(string& asName, string& asCallback);
//Callback syntax: void Function(string &in asEntity, int alState)
(This post was last modified: 05-08-2013, 02:05 AM by Tomato Cat.)
|
|
05-08-2013, 02:05 AM |
|
serbusfish
Member
Posts: 211
Threads: 75
Joined: Aug 2012
Reputation:
0
|
RE: Setting up the elevator machine
(05-08-2013, 02:05 AM)Tomato Cat Wrote: Did you not want the coal to disappear?
Use this for the lever:
SetEntityConnectionStateChangeCallback(string& asName, string& asCallback);
//Callback syntax: void Function(string &in asEntity, int alState)
Yes that's fine, I was just updating on what I had done
Ok ive used that command on a previous map so know what to do with it, however I dont know how I actually get the machines cogs and things to start up when the lever is pulled?
(This post was last modified: 05-08-2013, 03:11 AM by serbusfish.)
|
|
05-08-2013, 03:10 AM |
|
|