Steve
Member
Posts: 178
Threads: 17
Joined: Jun 2012
Reputation:
7
RE: Script help needed
(09-19-2012, 06:30 PM) Your Computer Wrote: You're still working on this? Here's my working version of it. All four sticky areas have the same detach and attach functions. The local map variable names have the names of the sticky areas. Study, modify, etc...
const string [] oven_sticky_areas = { "OvenArea_1" , "OvenArea_2" , "OvenArea_3" , "OvenArea_4" }; const string oven_object_name = "oven_object" ; const string oven_door_name = "mansion_1" ; const string oven_lever_name = "lever_simple01_22" ; void OnStart () { SetEntityConnectionStateChangeCallback ( oven_lever_name , "CheckIngredients" ); } ////////////LEVER CHECK///////////////// void CheckIngredients ( string & in asEntity , int alState ) { if( alState == 1 ) { if ( GetLocalVarInt ( oven_sticky_areas [ 0 ]) == 1 && GetLocalVarInt ( oven_sticky_areas [ 1 ]) == 1 && GetLocalVarInt ( oven_sticky_areas [ 2 ]) == 1 && GetLocalVarInt ( oven_sticky_areas [ 3 ]) == 1 ) { AddDebugMessage ( "OvenPuzzle: Correct!" , false ); AddTimer ( "CompleteOvenPuzzle" , 1 , "CompleteOvenPuzzle" ); } else { AddDebugMessage ( "OvenPuzzle: Wrong!" , false ); SetMessage ( "Messages" , "IncorrectCombination" , 0 ); } } } void AttachObjectOven ( string & in asStickyArea , string & in asBodyName ) { if ( StringContains ( asBodyName , oven_object_name )) SetAllowStickyAreaAttachment ( true ); else { SetAllowStickyAreaAttachment ( false ); return; } AddDebugMessage ( asStickyArea + " " + asBodyName , true ); asBodyName = StringSub ( asBodyName , 0 , oven_object_name . length () + 2 ); AddDebugMessage ( asBodyName , false ); if ( StringContains ( asStickyArea , "1" ) && StringContains ( asBodyName , "1" )) SetLocalVarInt ( asStickyArea , 1 ); else if ( StringContains ( asStickyArea , "2" ) && StringContains ( asBodyName , "2" )) SetLocalVarInt ( asStickyArea , 1 ); else if ( StringContains ( asStickyArea , "3" ) && StringContains ( asBodyName , "3" )) SetLocalVarInt ( asStickyArea , 1 ); else if ( StringContains ( asStickyArea , "4" ) && StringContains ( asBodyName , "4" )) SetLocalVarInt ( asStickyArea , 1 ); } void DetachObjectOven ( string & in asStickyArea , string & in asBodyName ) { SetLocalVarInt ( asStickyArea , 0 ); } void CompleteOvenPuzzle ( string & in asTimer ) { SetSwingDoorLocked ( oven_door_name , false , true ); SetMessage ( "Messages" , "correctcombinationchemicals" , 0 ); }
Nice script
thank you YC yes I still haven't made it completely yet I gave up for a short period and continued a bit with the level_editing. But i guessed I should complete this one first.
I only have one request though, could you give me some annotations of what i should fill in with what?
I have this at the moment and my object names are (object_1, object_2, object_3, object_4)
Spoiler below!
const string[] oven_sticky_areas = {"OvenArea_1", "OvenArea_2", "OvenArea_3", "OvenArea_4"};
const string oven_object_name = "object_";
const string oven_door_name = "extaction_oven_6";
const string oven_lever_name = "Lever_1";
void OnStart()
{
SetEntityConnectionStateChangeCallback(oven_lever_name, "CheckIngredients");
}
////////////LEVER CHECK/////////////////
void CheckIngredients(string &in asEntity, int alState)
{
if(alState == 1)
{
if (GetLocalVarInt(oven_sticky_areas[0]) == 1
&& GetLocalVarInt(oven_sticky_areas[1]) == 1
&& GetLocalVarInt(oven_sticky_areas[2]) == 1
&& GetLocalVarInt(oven_sticky_areas[3]) == 1)
{
AddDebugMessage("OvenPuzzle: Correct!", false);
AddTimer("CompleteOvenPuzzle", 1, "CompleteOvenPuzzle");
}
else
{
AddDebugMessage("OvenPuzzle: Wrong!", false);
SetMessage("Messages", "IncorrectCombination", 0);
}
}
}
void AttachObjectOven(string &in asStickyArea, string &in asBodyName)
{
if (StringContains(asBodyName, oven_object_name))
SetAllowStickyAreaAttachment(true);
else
{
SetAllowStickyAreaAttachment(false);
return;
}
AddDebugMessage(asStickyArea + " " + asBodyName, true);
asBodyName = StringSub(asBodyName, 0, oven_object_name.length() + 2);
AddDebugMessage(asBodyName, false);
if (StringContains(asStickyArea, "1") && StringContains(asBodyName, "1"))
SetLocalVarInt(asStickyArea, 1);
else if (StringContains(asStickyArea, "2") && StringContains(asBodyName, "2"))
SetLocalVarInt(asStickyArea, 1);
else if (StringContains(asStickyArea, "3") && StringContains(asBodyName, "3"))
SetLocalVarInt(asStickyArea, 1);
else if (StringContains(asStickyArea, "4") && StringContains(asBodyName, "4"))
SetLocalVarInt(asStickyArea, 1);
}
void DetachObjectOven(string &in asStickyArea, string &in asBodyName)
{
SetLocalVarInt(asStickyArea, 0);
}
void CompleteOvenPuzzle(string &in asTimer)
{
SetSwingDoorLocked(oven_door_name, false, true);
SetMessage("Messages", "correctcombinationchemicals", 0);
}
As I have it now it doesn't seem to work though
CURRENTLY WORKING ON:
Final Light = 40%
Need of voice actors.