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] If 'something' collides with area function
FlawlessHappiness Offline
Posting Freak

Posts: 3,980
Threads: 145
Joined: Mar 2012
Reputation: 171
#1
[SOLVED] If 'something' collides with area function

Yea so i have a bookshelf in one room, with 3 empty spaces.


In another room there is a lot of books spread out.

I want the player to take three books, from all of those books on the floor, and put them into the three spaces.

So there has to be a script in the bookshelf which adds and subtracts 1, for every book colliding and not-colliding with it. And this collide-area has to have a certain script that makes the script trigger if 'something' collides with it.

Nothing else can collide with the script, because the spaces are just as small as the books are.

Does this kind of script exist?

I searched a bit for it, and i got that i could take the books names and make a 'for' script.

Is there an easier way around?

Trying is the first step to success.
(This post was last modified: 05-27-2012, 11:24 PM by FlawlessHappiness.)
05-27-2012, 07:04 PM
Find
Your Computer Offline
SCAN ME!

Posts: 3,456
Threads: 32
Joined: Jul 2011
Reputation: 235
#2
RE: If 'something' collides with area function

Sticky areas.

Tutorials: From Noob to Pro
05-27-2012, 07:13 PM
Website Find
FlawlessHappiness Offline
Posting Freak

Posts: 3,980
Threads: 145
Joined: Mar 2012
Reputation: 171
#3
RE: If 'something' collides with area function

Thank you! Still haven't explored all the possibilities of HPL Wink I will check it out!

I placed "Add_variable_1" and 2 and 3, under AttachFunction.

Here is my script so far

Spoiler below!


void Add_variable_1(string &in asStickyArea, string &in asBodyName)
{
SetLocalVarInt("book_placement_1", 1);

if(GetLocalVarInt("book_placement_1") == 1)
{
if(GetLocalVarInt("book_placement_2") == 1)
{
if(GetLocalVarInt("book_placement_3") == 1)
{
StartEffectFlash(1, 1.0, 1);
AddTimer("", 1, "RealLife_timer");
}
}
}
}

void Add_variable_2(string &in asStickyArea, string &in asBodyName)
{
SetLocalVarInt("book_placement_2", 1);

if(GetLocalVarInt("book_placement_1") == 1)
{
if(GetLocalVarInt("book_placement_2") == 1)
{
if(GetLocalVarInt("book_placement_3") == 1)
{
StartEffectFlash(1, 1.0, 1);
AddTimer("", 1, "RealLife_timer");
}
}
}
}

void Add_variable_3(string &in asStickyArea, string &in asBodyName)
{
SetLocalVarInt("book_placement_3", 1);

if(GetLocalVarInt("book_placement_1") == 1)
{
if(GetLocalVarInt("book_placement_2") == 1)
{
if(GetLocalVarInt("book_placement_3") == 1)
{
StartEffectFlash(1, 1.0, 1);
AddTimer("", 1, "RealLife_timer");
}
}
}
}

///TIMERS

void RealLife_timer(string &in asTimer)
{
TeleportPlayer("PlayerStartArea_3");
}


I had some problems with it, but now it works.

Remember to place something in the AttachAbleBodyName Smile

Trying is the first step to success.
(This post was last modified: 05-27-2012, 08:45 PM by FlawlessHappiness.)
05-27-2012, 07:14 PM
Find
Twitchez Offline
Member

Posts: 67
Threads: 17
Joined: Mar 2012
Reputation: 1
#4
RE: If 'something' collides with area function

Something similar I used for my mod (but with cogwheels) was that I put three script-areas in the places I wanted the cogs to be. Then I took each cog and made a copy of them, assigned them to static and "non-active". The last thing I did was to use the AddEntityCallBack, so when each cog entered the area near where it should have been, the static cog became "visible" and the one you were moving "non-visible".

And if you want to run some sort of script when all the books are in the bookshelf, add 1 to your LocalVarInt for every time you add a book, and for each time the Player puts a book in the bookshelf, run an "if" function. "If LocalVarInt ==3...".

//Kind Regards
05-27-2012, 08:43 PM
Find
FlawlessHappiness Offline
Posting Freak

Posts: 3,980
Threads: 145
Joined: Mar 2012
Reputation: 171
#5
RE: If 'something' collides with area function

Yep. The problem would just be that it wouldn't be the same book that appears, than the one you place

Trying is the first step to success.
05-27-2012, 10:50 PM
Find
Twitchez Offline
Member

Posts: 67
Threads: 17
Joined: Mar 2012
Reputation: 1
#6
RE: If 'something' collides with area function

(05-27-2012, 10:50 PM)beecake Wrote: Yep. The problem would just be that it wouldn't be the same book that appears, than the one you place
You don't have to make it a static, it's just a suggestion. Otherwise, AddEntityCollideCallback is a good suggestion for running your code and for AddLocalVarInt.

Amnesia - Abomination Ask me about anything :)
05-27-2012, 10:57 PM
Find
FlawlessHappiness Offline
Posting Freak

Posts: 3,980
Threads: 145
Joined: Mar 2012
Reputation: 171
#7
RE: If 'something' collides with area function

Yea Smile Except with that function i have to specify an item. I just want the player to grab 3 books and put them into the spaces Wink But anyway i have found a solution. The sticky area works perfectly!

Trying is the first step to success.
05-27-2012, 11:10 PM
Find
Your Computer Offline
SCAN ME!

Posts: 3,456
Threads: 32
Joined: Jul 2011
Reputation: 235
#8
RE: If 'something' collides with area function

(05-27-2012, 07:14 PM)beecake Wrote: I placed "Add_variable_1" and 2 and 3, under AttachFunction.

Here is my script so far

Spoiler below!


void Add_variable_1(string &in asStickyArea, string &in asBodyName)
{
SetLocalVarInt("book_placement_1", 1);

if(GetLocalVarInt("book_placement_1") == 1)
{
if(GetLocalVarInt("book_placement_2") == 1)
{
if(GetLocalVarInt("book_placement_3") == 1)
{
StartEffectFlash(1, 1.0, 1);
AddTimer("", 1, "RealLife_timer");
}
}
}
}

void Add_variable_2(string &in asStickyArea, string &in asBodyName)
{
SetLocalVarInt("book_placement_2", 1);

if(GetLocalVarInt("book_placement_1") == 1)
{
if(GetLocalVarInt("book_placement_2") == 1)
{
if(GetLocalVarInt("book_placement_3") == 1)
{
StartEffectFlash(1, 1.0, 1);
AddTimer("", 1, "RealLife_timer");
}
}
}
}

void Add_variable_3(string &in asStickyArea, string &in asBodyName)
{
SetLocalVarInt("book_placement_3", 1);

if(GetLocalVarInt("book_placement_1") == 1)
{
if(GetLocalVarInt("book_placement_2") == 1)
{
if(GetLocalVarInt("book_placement_3") == 1)
{
StartEffectFlash(1, 1.0, 1);
AddTimer("", 1, "RealLife_timer");
}
}
}
}

///TIMERS

void RealLife_timer(string &in asTimer)
{
TeleportPlayer("PlayerStartArea_3");
}


I had some problems with it, but now it works.

Remember to place something in the AttachAbleBodyName Smile

Here's the code i would have used; there's no need to add an AttachAbleBodyName to the sticky area:

PHP Code: (Select All)
void AttachFunction(string &in areastring &in object)
{
    
AddDebugMessage(objectfalse);

    if (!
StringContains(object"BookSyntax"))
    {
        
SetAllowStickyAreaAttachment(false);
        return;
    }

    
SetAllowStickyAreaAttachment(true);
    
AddLocalVarInt("AttachedBooks"1);

    if (
GetLocalVarInt("AttachedBooks") == 3)
    {
        
AddDebugMessage("Puzzle completed!"false);

        
// Complete puzzle
    
}
}

void DetachFunction(string &in areastring &in object)
{
    
AddDebugMessage("Detaching: "+objectfalse);
    
AddLocalVarInt("AttachedBooks", -1);


Tutorials: From Noob to Pro
05-28-2012, 07:52 AM
Website Find
FlawlessHappiness Offline
Posting Freak

Posts: 3,980
Threads: 145
Joined: Mar 2012
Reputation: 171
#9
RE: [SOLVED] If 'something' collides with area function

Yea.. well i don't know.. It works for me with my script Wink

Trying is the first step to success.
(This post was last modified: 05-28-2012, 10:55 AM by FlawlessHappiness.)
05-28-2012, 10:55 AM
Find




Users browsing this thread: 1 Guest(s)