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.
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.
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)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?
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.)
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?