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
Script Help Script help needed
Your Computer Offline
SCAN ME!

Posts: 3,456
Threads: 32
Joined: Jul 2011
Reputation: 235
#11
RE: Script help needed

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

PHP Code: (Select All)
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 asEntityint 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 asStickyAreastring &in asBodyName)
    {
        if (
StringContains(asBodyNameoven_object_name))
            
SetAllowStickyAreaAttachment(true);
        else
        {
            
SetAllowStickyAreaAttachment(false);
            return;
        }

        
AddDebugMessage(asStickyArea " " asBodyNametrue);

        
asBodyName StringSub(asBodyName0oven_object_name.length() + 2);
        
AddDebugMessage(asBodyNamefalse);

        if (
StringContains(asStickyArea"1") && StringContains(asBodyName"1"))
            
SetLocalVarInt(asStickyArea1);

        else if (
StringContains(asStickyArea"2") && StringContains(asBodyName"2"))
            
SetLocalVarInt(asStickyArea1);

        else if (
StringContains(asStickyArea"3") && StringContains(asBodyName"3"))
            
SetLocalVarInt(asStickyArea1);

        else if (
StringContains(asStickyArea"4") && StringContains(asBodyName"4"))
            
SetLocalVarInt(asStickyArea1);
    }

void DetachObjectOven(string &in asStickyAreastring &in asBodyName)
    {
        
SetLocalVarInt(asStickyArea0);
    }

void CompleteOvenPuzzle(string &in asTimer)
    {
        
SetSwingDoorLocked(oven_door_namefalsetrue);
        
SetMessage("Messages""correctcombinationchemicals"0);
    } 

Tutorials: From Noob to Pro
(This post was last modified: 09-19-2012, 07:23 PM by Your Computer.)
09-19-2012, 06:30 PM
Website Find
FlawlessHappiness Offline
Posting Freak

Posts: 3,980
Threads: 145
Joined: Mar 2012
Reputation: 171
#12
RE: Script help needed

Very nice script YC! I love it!

Trying is the first step to success.
09-19-2012, 06:38 PM
Find
Steve Offline
Member

Posts: 178
Threads: 17
Joined: Jun 2012
Reputation: 7
#13
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...

PHP Code: (Select All)
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 asEntityint 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 asStickyAreastring &in asBodyName)
    {
        if (
StringContains(asBodyNameoven_object_name))
            
SetAllowStickyAreaAttachment(true);
        else
        {
            
SetAllowStickyAreaAttachment(false);
            return;
        }

        
AddDebugMessage(asStickyArea " " asBodyNametrue);

        
asBodyName StringSub(asBodyName0oven_object_name.length() + 2);
        
AddDebugMessage(asBodyNamefalse);

        if (
StringContains(asStickyArea"1") && StringContains(asBodyName"1"))
            
SetLocalVarInt(asStickyArea1);

        else if (
StringContains(asStickyArea"2") && StringContains(asBodyName"2"))
            
SetLocalVarInt(asStickyArea1);

        else if (
StringContains(asStickyArea"3") && StringContains(asBodyName"3"))
            
SetLocalVarInt(asStickyArea1);

        else if (
StringContains(asStickyArea"4") && StringContains(asBodyName"4"))
            
SetLocalVarInt(asStickyArea1);
    }

void DetachObjectOven(string &in asStickyAreastring &in asBodyName)
    {
        
SetLocalVarInt(asStickyArea0);
    }

void CompleteOvenPuzzle(string &in asTimer)
    {
        
SetSwingDoorLocked(oven_door_namefalsetrue);
        
SetMessage("Messages""correctcombinationchemicals"0);
    } 
Nice script Big Grin 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.
09-19-2012, 08:29 PM
Find
Your Computer Offline
SCAN ME!

Posts: 3,456
Threads: 32
Joined: Jul 2011
Reputation: 235
#14
RE: Script help needed

oven_object_name shouldn't end with an underscore or any suffix. oven_object_name should be the name that all the objects have in common. In your case it would be simply "object", since you have object_1, object_2, object_3 and object_4.

Tutorials: From Noob to Pro
(This post was last modified: 09-19-2012, 08:39 PM by Your Computer.)
09-19-2012, 08:38 PM
Website Find
Steve Offline
Member

Posts: 178
Threads: 17
Joined: Jun 2012
Reputation: 7
#15
RE: Script help needed

so?
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.
09-19-2012, 08:51 PM
Find
Steve Offline
Member

Posts: 178
Threads: 17
Joined: Jun 2012
Reputation: 7
#16
RE: Script help needed

Oka after some week I'm back and eager to end this I tried what you said YC but It doesn't seem to work. I have the script as the previous reply.

CURRENTLY WORKING ON:
Final Light = 40%
Need of voice actors.
10-04-2012, 03:46 PM
Find
Steve Offline
Member

Posts: 178
Threads: 17
Joined: Jun 2012
Reputation: 7
#17
RE: Script help needed

bumbosaurus

CURRENTLY WORKING ON:
Final Light = 40%
Need of voice actors.
10-05-2012, 04:55 PM
Find
Robby Offline
Posting Freak

Posts: 2,549
Threads: 38
Joined: Jun 2009
Reputation: 47
#18
RE: Script help needed

(10-05-2012, 04:55 PM)Steve Wrote: bumpity bump bump bump
Well, looking at your script, it's quite complicated. I mean I know scripting and all, but you're already using advanced functions I never really did.

I'd love to help, but my limited knowledge prevents me from that.

Infrequently active. Don't expect an immediate response. Best to contact me at a different locale. If I create a thread, expect me to be quite active.
10-05-2012, 05:48 PM
Website Find
The chaser Offline
Posting Freak

Posts: 2,486
Threads: 76
Joined: Jun 2012
Reputation: 113
#19
RE: Script help needed

Whoa, I just can't read the script that way. Put it in code, remember. I'm practising with these, maybe I can solve your problem.

THE OTHERWORLD (WIP)
[Image: k6vbdhu]

Aculy iz dolan.
10-05-2012, 08:33 PM
Find
Steve Offline
Member

Posts: 178
Threads: 17
Joined: Jun 2012
Reputation: 7
#20
RE: Script help needed

(10-05-2012, 08:33 PM)The chaser Wrote: Whoa, I just can't read the script that way. Put it in code, remember. I'm practising with these, maybe I can solve your problem.
you mean like this?
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.
10-06-2012, 08:02 PM
Find




Users browsing this thread: 3 Guest(s)