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 Problem.. Crowbar and open hatch.
sabrinagsoledad Offline
Junior Member

Posts: 32
Threads: 10
Joined: Feb 2016
Reputation: 0
#1
Script Problem.. Crowbar and open hatch.

HI.

I saw a video guide about how to write the script for using crowbar with all the effects...
In my case is not a door its a hatch...(kind of...) the item im using is hatch_metal01...because cealing hatch(the one i wanted) it never got locked.

When i enter to the game... nothing hapens.. the crowbar does nothing.

Here is my script... (my level items has the same names as the ones in the script, so there isnt a wrong name issue...

At first in "AddUseItemCallback("openhatch", "crowbar_1", "ScriptArea_1", instead of ScriptArea_1, was the name of the door item... that was hatch_1.... but it didnt work, so the one that make the guide told me that with some entitys u cant interact, so i could try to change hatch_1 to ScriptArea_1...
In both ways it dont work. Please what i should do?... (I also check the "script areas" position and the ScriptArea_1 is huge and just below the hatch).

Just to know... "crowbar_1" is the pickup crowbar, "joint" is a crowbar that appear stuck in the door the one i will move, and "brokencrowbar" is the one in two parts that will fall.


void OnStart()
{
AddUseItemCallback("openhatch", "crowbar_1", "ScriptArea_1", "UseCrowbarOnDoor", true);
AddEntityCollideCallback ("joint", "ScriptArea_1", "BreakHatch", true, 1);
}

void UseCrowbarOndoor(string &in asItem, string &in asEntity)
{
RemoveItem("crowbar_1");
PlaySoundAtEntity("", "player_crouch.snt", "Player", 0.05, false);
AddTimer(asEntity, 0.2, "TimerPlaceCrowbar");
}

void TimerPlaceCrowbar (string &in asTimer)
{
SetEntityActive("joint", true);
PlaySoundAtEntity("", "puzzle_place_jar.snt", asTimer, 0, false);
}

void BreakHatch(string &in asParent, string &in asChild, int alState)
{
SetEntityActive("joint", false);
SetEntityActive("brokencrowbar", true);
SetSwingDoorLocked("hatch", false, false);
SetSwingDoorClosed("hatch", false, false);
SetSwingDoorDisableAutoClose("hatch", true);
AddPropImpulse("hatch", 0, -3, 0, "world");
CreateParticleSystemAtEntity("", "ps_hit_wood.ps", "AreaEffect", false);
PlaySoundAtEntity("", "break_wood_metal.snt", "AreaEffect", 0, false);
GiveSanityBoostSmall();
PlayMusic("10_puzzle01.ogg", false, 0.7, 0.1, 10, false);
AddTimer ("", 0.1, "TimerPushHatch");
}

void TimerPushHatch (string &in asTimer)
{
AddPropImpulse("hatch", 0, -2, -1, "world");
AddTimer ("", 1.1, "TimerHatchCanClose");
}

void TimerHatchCanClose (string &in asTimer)
{
SetSwingDoorDisableAutoClose("hatch", false);
}



Thanks for the attention.
02-22-2016, 11:54 PM
Find
Spelos Away
Banned

Posts: 231
Threads: 19
Joined: Sep 2014
#2
RE: Script Problem.. Crowbar and open hatch.

[Image: rqRK3oA.png]

Hope this solves your problem.
02-23-2016, 12:06 AM
Find
sabrinagsoledad Offline
Junior Member

Posts: 32
Threads: 10
Joined: Feb 2016
Reputation: 0
#3
RE: Script Problem.. Crowbar and open hatch.

Hi..
I didnt have those activated... but still isnt working TT it could be the item used? i mean the door entity?
02-23-2016, 02:04 AM
Find
Spelos Away
Banned

Posts: 231
Threads: 19
Joined: Sep 2014
#4
RE: Script Problem.. Crowbar and open hatch.

PHP Code: (Select All)
AddTimer(asEntity0.2"TimerPlaceCrowbar"); 

That's not a float. You put a double there. Use:

PHP Code: (Select All)
AddTimer(asEntity0.2f"TimerPlaceCrowbar");

///....

AddTimer (""0.1f"TimerPushHatch");

///...

AddTimer (""1.1f"TimerHatchCanClose"); 

That's for all of your other functions as well..
1.3 is a double
1.3f is a float
THOSE FUNCIONS REQUIRE A FLOAT

PHP Code: (Select All)
PlaySoundAtEntity("""player_crouch.snt""Player"0.05ffalse); 

Although it should work regardless... =/

I've got it!

The simplest little mistake.

AddUseItemCallback("openhatch", "crowbar_1", "ScriptArea_1", "UseCrowbarOnDoor", true);

void UseCrowbarOndoor(string &in asItem, string &in asEntity)
...


Be sure to copy Function names to avoid this problem.
And let me mention that if you didn't check the ItemInteraction it still wouldn't work.

Fixed code:
PHP Code: (Select All)
void OnStart()
{
    
AddUseItemCallback("openhatch""crowbar_1""ScriptArea_1""UseCrowbarOnDoor"true);
    
AddEntityCollideCallback ("joint""ScriptArea_1""BreakHatch"true1);
}

void UseCrowbarOnDoor(string &in asItemstring &in asEntity)

    
RemoveItem("crowbar_1");
    
PlaySoundAtEntity("""player_crouch.snt""Player"0.05false);
    
AddTimer(asEntity0.2"TimerPlaceCrowbar");
}

void TimerPlaceCrowbar (string &in asTimer)

    
SetEntityActive("joint"true);
    
PlaySoundAtEntity("""puzzle_place_jar.snt"asTimer0false);
}

void BreakHatch(string &in asParentstring &in asChildint alState
{
    
SetEntityActive("joint"false);
    
SetEntityActive("brokencrowbar"true);
    
SetSwingDoorLocked("hatch"falsefalse);
    
SetSwingDoorClosed("hatch"falsefalse);
    
SetSwingDoorDisableAutoClose("hatch"true);
    
AddPropImpulse("hatch"0, -30"world");
    
CreateParticleSystemAtEntity("""ps_hit_wood.ps""AreaEffect"false);
    
PlaySoundAtEntity("""break_wood_metal.snt""AreaEffect"0false);
    
GiveSanityBoostSmall();
    
PlayMusic("10_puzzle01.ogg"false0.70.110false);
    
AddTimer (""0.1"TimerPushHatch");
}

void TimerPushHatch (string &in asTimer)
{
    
AddPropImpulse("hatch"0, -2, -1"world");
    
AddTimer (""1.1"TimerHatchCanClose");
}

void TimerHatchCanClose (string &in asTimer)
{
    
SetSwingDoorDisableAutoClose("hatch"false);


And I suggest making another Script Area for the crowbar, since I presume the one you have is already in that area and would basically trigger immediately.
(This post was last modified: 02-23-2016, 07:43 AM by Spelos.)
02-23-2016, 07:10 AM
Find
sabrinagsoledad Offline
Junior Member

Posts: 32
Threads: 10
Joined: Feb 2016
Reputation: 0
#5
RE: Script Problem.. Crowbar and open hatch.

Hi. Thank you so much!.. when i read like 30 times the same thing those damn mistakes wont appear. But now i have another issue, my joint (the crowbar attached) its moving, it lurches from side to side, im trying to moving its position to change that with no luck..

THANKS again!
02-23-2016, 01:56 PM
Find
Mudbill Offline
Muderator

Posts: 3,881
Threads: 59
Joined: Apr 2013
Reputation: 179
#6
RE: Script Problem.. Crowbar and open hatch.

It might be too close to something else, causing weird collisions. If I understand you correctly, it's jiggering and moving on its own?
Try moving it slightly in the editor. Feel free to post a screenshot.

02-23-2016, 02:08 PM
Find
sabrinagsoledad Offline
Junior Member

Posts: 32
Threads: 10
Joined: Feb 2016
Reputation: 0
#7
RE: Script Problem.. Crowbar and open hatch.

here is a picture of their positions., yes it's jiggering and moving on its own
(This post was last modified: 02-23-2016, 03:38 PM by sabrinagsoledad.)
02-23-2016, 02:19 PM
Find
sabrinagsoledad Offline
Junior Member

Posts: 32
Threads: 10
Joined: Feb 2016
Reputation: 0
#8
RE: Script Problem.. Crowbar and open hatch.

(02-23-2016, 02:19 PM)sabrinagsoledad Wrote: here is a picture of their positions., yes it's jiggering and moving on its own



-----

I SOLVE IT... its was it position....

Thanks
02-25-2016, 02:55 AM
Find




Users browsing this thread: 3 Guest(s)