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
[SOLVED] Still one problem to solve
Steve Offline
Member

Posts: 178
Threads: 17
Joined: Jun 2012
Reputation: 7
#1
[SOLVED] Still one problem to solve

Okay so I have been busy with this script for a time now and I still can't seem to solve it I have this script the thing it should do is that when object_1-4 touches stickyArea_1-4 the puzzle should be completed. But now it doesn't really do anything.
this is the script:
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);
}


CURRENTLY WORKING ON:
Final Light = 40%
Need of voice actors.
(This post was last modified: 10-25-2012, 12:34 PM by Steve.)
10-14-2012, 08:42 PM
Find
Steve Offline
Member

Posts: 178
Threads: 17
Joined: Jun 2012
Reputation: 7
#2
RE: Still one problem to solve

nobody? If nobody know what wrong then I'm gonna try a making a new script...

CURRENTLY WORKING ON:
Final Light = 40%
Need of voice actors.
10-17-2012, 04:37 PM
Find
Akos115 Offline
Member

Posts: 101
Threads: 14
Joined: Aug 2012
Reputation: 0
#3
RE: Still one problem to solve

Try SetMultiSliderCallback instead of SetEntityConnectionStateChangeCallback.
I think it should work then.

(This post was last modified: 10-17-2012, 10:02 PM by Akos115.)
10-17-2012, 10:01 PM
Find
The chaser Offline
Posting Freak

Posts: 2,486
Threads: 76
Joined: Jun 2012
Reputation: 113
#4
RE: Still one problem to solve

It's a complicated script. I don't really know what to do, because I know a little about sticky areas. I hate the inability to help people Sad

THE OTHERWORLD (WIP)
[Image: k6vbdhu]

Aculy iz dolan.
10-18-2012, 06:41 AM
Find
Ongka Offline
Member

Posts: 225
Threads: 3
Joined: Nov 2010
Reputation: 20
#5
RE: Still one problem to solve

So basically you're trying to place 4 objects on 4 sticky area, but want to make it possible to place them in any order, right?
It probably isn't as complicated as you think it would be.

AttachObject gets called when you place the object on the sticky area, I think you already know how to configure this, if not, ask.
void AttachObject(string &in asArea, string &in asBody, string &in asEntity)
{
SetLocalVarInt(asArea, 1); //For example: Name your areas "sticky_1" "sticky_2" and so on
SetEntityInteractionDisabled(asEntity, true);
}

void CheckIngredients(string &in asEntity, int alState)
{
if(alState == 1)
{
if (GetLocalVarInt("sticky_1") == 1
&& GetLocalVarInt("sticky_2") == 1
&& GetLocalVarInt("sticky_3") == 1
&& GetLocalVarInt("sticky_4") == 1)
{
AddDebugMessage("OvenPuzzle: Correct!", false);
AddTimer("CompleteOvenPuzzle", 1, "CompleteOvenPuzzle");
}
}
}
Note: This will only work if any of the objects can be placed on any sticky area. You have to configure this by yourself if but it seems you've already done that.

[Image: 18694.png]
(This post was last modified: 10-18-2012, 09:09 AM by Ongka.)
10-18-2012, 09:08 AM
Find
Steve Offline
Member

Posts: 178
Threads: 17
Joined: Jun 2012
Reputation: 7
#6
RE: Still one problem to solve

(10-18-2012, 09:08 AM)Ongka Wrote: So basically you're trying to place 4 objects on 4 sticky area, but want to make it possible to place them in any order, right?
It probably isn't as complicated as you think it would be.

AttachObject gets called when you place the object on the sticky area, I think you already know how to configure this, if not, ask.
void AttachObject(string &in asArea, string &in asBody, string &in asEntity)
{
SetLocalVarInt(asArea, 1); //For example: Name your areas "sticky_1" "sticky_2" and so on
SetEntityInteractionDisabled(asEntity, true);
}

void CheckIngredients(string &in asEntity, int alState)
{
if(alState == 1)
{
if (GetLocalVarInt("sticky_1") == 1
&& GetLocalVarInt("sticky_2") == 1
&& GetLocalVarInt("sticky_3") == 1
&& GetLocalVarInt("sticky_4") == 1)
{
AddDebugMessage("OvenPuzzle: Correct!", false);
AddTimer("CompleteOvenPuzzle", 1, "CompleteOvenPuzzle");
}
}
}
Note: This will only work if any of the objects can be placed on any sticky area. You have to configure this by yourself if but it seems you've already done that.
well no it's only supposed to work if the correct objects are in the correct sticky area's so 1 for 1 an d 2 for 2 ect.

CURRENTLY WORKING ON:
Final Light = 40%
Need of voice actors.
10-18-2012, 01:55 PM
Find
Ongka Offline
Member

Posts: 225
Threads: 3
Joined: Nov 2010
Reputation: 20
#7
RE: Still one problem to solve

The areas are called sticky_1 - 4 and the entites which are placed on the areas are called _body_1 - 4
void AttachObject(string &in asArea, string &in asBody, string &in asEntity)
{
    if(asArea + asEntity == "sticky_1_body_1")
    {
    SetLocalVarInt(asArea, 1); //In this case the Var is called sticky_1
    SetEntityInteractionDisabled(asEntity, true);
    }
    else if(asArea + asEntity == "sticky_2_body_2")
    {
    SetLocalVarInt(asArea, 1); //In this case the Var is called sticky_2
    SetEntityInteractionDisabled(asEntity, true);
    }
    else if(asArea + asEntity == "sticky_3_body_3")
    {
    SetLocalVarInt(asArea, 1); //In this case the Var is called sticky_3
    SetEntityInteractionDisabled(asEntity, true);
    }
    else if(asArea + asEntity == "sticky_4_body_4")
    SetEntityInteractionDisabled(asEntity, true);
    {
    SetLocalVarInt(asArea, 1); //In this case the Var is called sticky_4
    SetEntityInteractionDisabled(asEntity, true);
    }
    else
    {
    AddDebugMessage(asEntity + " doesn't fit on " + asArea, false);
    }    
}

void CheckIngredients(string &in asEntity, int alState)
{
if(alState == 1)
{
if (GetLocalVarInt("sticky_1") == 1
&& GetLocalVarInt("sticky_2") == 1
&& GetLocalVarInt("sticky_3") == 1
&& GetLocalVarInt("sticky_4") == 1)
{
AddDebugMessage("OvenPuzzle: Correct!", false);
AddTimer("CompleteOvenPuzzle", 1, "CompleteOvenPuzzle");
}
}
}
Try it out, may or may not work.

[Image: 18694.png]
10-18-2012, 04:40 PM
Find
Akos115 Offline
Member

Posts: 101
Threads: 14
Joined: Aug 2012
Reputation: 0
#8
RE: Still one problem to solve

Try GetEntitiesCollide instead of making variables?

10-18-2012, 04:48 PM
Find
Ongka Offline
Member

Posts: 225
Threads: 3
Joined: Nov 2010
Reputation: 20
#9
RE: Still one problem to solve

There surely are easier ways to script it, but i usually don't use sticky areas.

[Image: 18694.png]
10-18-2012, 04:53 PM
Find
Steve Offline
Member

Posts: 178
Threads: 17
Joined: Jun 2012
Reputation: 7
#10
RE: Still one problem to solve

I finaly did it with this script I made;
Spoiler below!
void OnStart()
{
SetEntityConnectionStateChangeCallback("Lever_1", "CheckIngredients");
}
////////////LEVER CHECK/////////////////
void CheckIngredients(string &in asEntity, int alState)
{
if(alState == 1)
{
if (GetLocalVarInt("oven_1_correct") == 1
&& GetLocalVarInt("oven_2_correct") == 1
&& GetLocalVarInt("oven_3_correct") == 1
&& GetLocalVarInt("oven_4_correct") == 1)
{

AddDebugMessage("OvenPuzzle: Correct!", false);
AddTimer("ovencomplete", 1, "CompleteOvenPuzzle");
}
else
{
AddDebugMessage("OvenPuzzle: Wrong!", false);
SetMessage("Messages", "IncorrectCombination", 0);
}
}
}

void PutObjectOven_1(string &in asStickyArea, string &in asBodyName)
{
SetLocalVarInt("oven_1_correct", 1);
}
void DetachObjectOven_1(string &in asStickyArea, string &in asBodyName)
{
SetLocalVarInt("oven_1_correct", 0);
}
void PutObjectOven_2(string &in asStickyArea, string &in asBodyName)
{
SetLocalVarInt("oven_2_correct", 1);
}
void DetachObjectOven_2(string &in asStickyArea, string &in asBodyName)
{
SetLocalVarInt("oven_2_correct", 0);
}
void PutObjectOven_3(string &in asStickyArea, string &in asBodyName)
{
SetLocalVarInt("oven_3_correct", 1);
}
void DetachObjectOven_3(string &in asStickyArea, string &in asBodyName)
{
SetLocalVarInt("oven_3_correct", 0);
}
void PutObjectOven_4(string &in asStickyArea, string &in asBodyName)
{
SetLocalVarInt("oven_4_correct", 1);
}
void DetachObjectOven_4(string &in asStickyArea, string &in asBodyName)
{
SetLocalVarInt("oven_4_correct", 0);
}
void CompleteOvenPuzzle(string &in asTimer)
{
SetSwingDoorLocked("extaction_oven_6", false, true);
SetMessage("Messages", "correctcombinationchemicals", 0);
}

CURRENTLY WORKING ON:
Final Light = 40%
Need of voice actors.
(This post was last modified: 10-24-2012, 09:23 PM by Steve.)
10-24-2012, 09:23 PM
Find




Users browsing this thread: 1 Guest(s)