The following warnings occurred:
Warning [2] count(): Parameter must be an array or an object that implements Countable - Line: 906 - File: showthread.php PHP 7.2.24-0ubuntu0.18.04.17 (Linux)
File Line Function
/showthread.php 906 errorHandler->error



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
Need help with script involving making trees appear/disappear
Cakeslam Offline
Junior Member

Posts: 4
Threads: 1
Joined: Sep 2012
Reputation: 0
#1
Need help with script involving making trees appear/disappear

Edit: Wrong section, sorry! Moved to Development Support.

Ok so for part of my custom story the player is in the forest. I'm trying to set up a script so that when the player interacts with a locked door they hear a scream and then some trees appear to block the previous path while some trees disappear to reveal a new path. I've used the SetEntityActive function but something's not right.

Also, I want the message "It's locked" to appear when the player tries to open the door but that's not working either, so any help with that would be appreciated as well.

Here's the script:

void OnStart()
{
    GiveItemFromFile("lantern", "lantern.ent");
        SetPlayerLampOil(50.0f);
    AddUseItemCallback("", "gate_key", "garden_gate", "unlock_garden_gate", true);
    SetEntityPlayerInteractCallback("garden_gate", "garden_gate_locked", false);
    SetEntityPlayerInteractCallback("garden_gate", "tree_door", true);
    SetEntityPlayerInteractCallback("garden_gate", "forest_scream", true);
    AddEntityCollideCallback("Player", "lantern_message", "lantern_message", true, 1);
}

void lantern_message(string &in asChild, string &in asParent, int alState)
{
    SetMessage("Messages", "lantern_message", 0);
}

void tree_door(string &in asParent, string &in asChild, int alState)
{
    SetEntityActive("tree_door_1", false);
    SetEntityActive("tree_door_2", false);
    SetEntityActive("tree_door_3", true);
    SetEntityActive("tree_door_4", true);
}

void garden_gate_locked(string &in Entity) // Needs to be fixed
{
    if(GetSwingDoorLocked("garden_gate") == true)
    {
        SetMessage("Messages", "locked", 0);
    }
}

void unlock_garden_gate(string &in asItem, string &in asEntity)
{
    SetSwingDoorLocked(asEntity, false, true);
    PlaySoundAtEntity("", "unlock_door", asEntity, 0, false);
    RemoveItem(asItem);
}

void forest_scream(string &in Entity)
{
    PlaySoundAtEntity("", "15_prisoner_scream.snt", "gate_key", 0, false);
    GiveSanityDamage(10.0f, true);
}

I only started scripting yesterday so there are probably quite a few errors in that script. Any help with cleaning it up in general would be greatly appreciated! Big Grin
(This post was last modified: 09-03-2012, 05:11 PM by Cakeslam.)
09-03-2012, 05:05 PM
Find


Messages In This Thread
Need help with script involving making trees appear/disappear - by Cakeslam - 09-03-2012, 05:05 PM



Users browsing this thread: 2 Guest(s)