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
Problem with lever & mixture
Shadowfied Offline
Senior Member

Posts: 261
Threads: 34
Joined: Jul 2010
Reputation: 5
#1
Problem with lever & mixture

Again, working hard on my custom story, I've run into a problem.

In this part of the map, the player needs to apply an ingredient to a mixture making it complete. I have most of the stuff setup, there is one issue however.

I have an "extaction oven" (I assume FG misspelled extraction) placed where the player must put a pot of an unfinished mixture next to. Then the player must put a bottle of Nitroglycerin in the oven and pull the lever next to it.

It all works, but there are no rules for the lever, it can be pulled any time, even before placing the items.

I need some kind of script which makes the lever only work when both the Nitroglycerin and the half filled pot are placed. I'm guessing that is some "if" script, but I have no idea how to make those kind of scripts. I have no problems with basic scripts so if someone could just give me an example or idea I would really learn from it.

I hope you understand what I mean.

Current - Castle Darkuan
Other - F*cked Map
(This post was last modified: 01-11-2012, 01:37 AM by Shadowfied.)
01-11-2012, 01:36 AM
Find
Statyk Offline
Schrödinger's Mod

Posts: 4,390
Threads: 72
Joined: Sep 2011
Reputation: 241
#2
RE: Problem with lever & mixture

Could you put an image in a spoiler of the area to be worked so I can get an idea?... I'm kinda confused by your explanation.
01-11-2012, 02:02 AM
Find
Shadowfied Offline
Senior Member

Posts: 261
Threads: 34
Joined: Jul 2010
Reputation: 5
#3
RE: Problem with lever & mixture

[Image: kBdirl.jpg]
(Click on it for full size)

Perhaps I should say that when both items are in place and the lever is pulled, that's when I want the unfinished mixture turning into the finished one.

Current - Castle Darkuan
Other - F*cked Map
(This post was last modified: 01-11-2012, 02:05 AM by Shadowfied.)
01-11-2012, 02:04 AM
Find
Statyk Offline
Schrödinger's Mod

Posts: 4,390
Threads: 72
Joined: Sep 2011
Reputation: 241
#4
RE: Problem with lever & mixture

So the unfinished mixture goes on the right under the tube, the Nitroglycerine goes in the box?

(I need to know so I can set up a bit of a script, sorry)
(This post was last modified: 01-11-2012, 02:47 AM by Statyk.)
01-11-2012, 02:47 AM
Find
Shadowfied Offline
Senior Member

Posts: 261
Threads: 34
Joined: Jul 2010
Reputation: 5
#5
RE: Problem with lever & mixture

(01-11-2012, 02:47 AM)Statyk Wrote: So the unfinished mixture goes on the right under the tube, the Nitroglycerine goes in the box?

(I need to know so I can set up a bit of a script, sorry)
Yeah.

Current - Castle Darkuan
Other - F*cked Map
01-11-2012, 02:50 AM
Find
Statyk Offline
Schrödinger's Mod

Posts: 4,390
Threads: 72
Joined: Sep 2011
Reputation: 241
#6
RE: Problem with lever & mixture

I'll try a script in a little while and come back because like I said, I'm not the best if scripter, so I would like to test this before I send it out, you know?
01-11-2012, 02:55 AM
Find
Shadowfied Offline
Senior Member

Posts: 261
Threads: 34
Joined: Jul 2010
Reputation: 5
#7
RE: Problem with lever & mixture

(01-11-2012, 02:55 AM)Statyk Wrote: I'll try a script in a little while and come back because like I said, I'm not the best if scripter, so I would like to test this before I send it out, you know?
Yeah, I appreciate it.

Current - Castle Darkuan
Other - F*cked Map
01-11-2012, 09:39 AM
Find
Shadowfied Offline
Senior Member

Posts: 261
Threads: 34
Joined: Jul 2010
Reputation: 5
#8
RE: Problem with lever & mixture

Perhaps this will help showing what I want:





Current - Castle Darkuan
Other - F*cked Map
01-11-2012, 12:08 PM
Find
Statyk Offline
Schrödinger's Mod

Posts: 4,390
Threads: 72
Joined: Sep 2011
Reputation: 241
#9
RE: Problem with lever & mixture

I got it. I apologize for leaving you last night >> I was modeling my angel and forgot... BUT, I came up with a script during school. Let me type it up and I'll be right back! It stops the lever from doing anything, displays a message when only one substance is added, and runs the effect when they are both added.


This is quite a bit, but I gave info for each function. Change capitalized strings to your needs:


void OnStart()
{
SetLocalVarInt("mixtures", 0); //Creates a "bank" for the lever.
AddUseItemCallback("", "NITROGLYCERIN", "BOXAREA", "Nitrofunc", true); //Using Nitroglycerine on the machine
AddUseItemCallback("", "UNFIN_MIX", "MIXAREA", "UnFinfunc", true); //Using Unfinished Mix on the machine
SetEntityConnectionStateChangeCallback("LEVER", "Leverfunc"); //Lever function
}

void Nitrofunc(string &in asItem, string &in asEntity)
{
AddLocalVarInt("mixtures", 1); //Adds 1 to the "bank" when Nitroglyc is used on the area.
SetEntityActive("NITROGLYC_STATIC", true); //activates the Nit. prop
PlaySoundAtEntity("", "pick_glass.snt", "BOXAREA", 0, true); //sound for placement
}

void UnFinfunc(string &in asItem, string &in asEntity)
{
AddLocalVarInt("mixtures", 1); //Adds 1 to the "bank" when Unfinished Mixture is used on the area.
SetEntityActive("UNFINMIX_STATIC", true); //activates the Unfin mix prop
PlaySoundAtEntity("", "pick_glass.snt", "MIXAREA", 0, true); //sound for placement
}

void Leverfunc(string &in asEntity, int alState)
{
if(alState == -1)
{
//Pulls lever in wrong direction. Leave blank for no effect
}

if(alState == 1)
{
GetLocalVarInt("mixtures"); //Checks "bank" when pulled.
{
if(GetLocalVarInt("mixtures") == 0) //if bank has 0 in it:
{
//Left blank for no function when machine is empty of substances
}
if(GetLocalVarInt("mixtures") == 1) //if bank has 1 in it:
{
SetMessage("CATEGORYNAME", "ENTRYNAME", 4); //Displays message for 4 seconds. OPTIONAL
}
if(GetLocalVarInt("mixtures") == 2) //if bank has 2 in it:
{
SetEntityActive("NITROGLYC_STATIC", false); //disables Nitroglyc prop
SetEntityActive("UNFINMIX_STATIC", false); //disables Unfinished Mix prop
SetEntityActive("FINISHEDMIX", true); //gives the finished mixture
GiveSanityBoost(); //Puzzle-complete effect
SetLeverStuckState("LEVER", 1, true); //Sets the lever locked so player can't use it again.
}
}
}
}


I have not tested this yet, so please let me know how everything works out... This was fun to create.

Also, for the message, I suggest saying something like "I need something else..." It's not necessary, but there if you're interested =]
(This post was last modified: 01-11-2012, 09:27 PM by Statyk.)
01-11-2012, 08:56 PM
Find
Shadowfied Offline
Senior Member

Posts: 261
Threads: 34
Joined: Jul 2010
Reputation: 5
#10
RE: Problem with lever & mixture

Statyk, you just put a huge smile on my face. It works perfectly!

Thank you so very much! I really really appreciate it!


I've never used ANY scripts with "Ints" or whatever. But, does this work like...by adding one of the items, the int increases with 1, and when it is 2 the script making the final mixture works?

Current - Castle Darkuan
Other - F*cked Map
01-11-2012, 10:56 PM
Find




Users browsing this thread: 1 Guest(s)