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
Script Help Using Global.hps to use a script in every level
Cyfiawn Offline
Junior Member

Posts: 27
Threads: 8
Joined: Jun 2012
Reputation: 0
#1
Using Global.hps to use a script in every level

Hi all,

I'm looking to make a script run in every level. The script is to change an item in your inventory based on your sanity. I've tried a couple of methods but none seem to work. Here's my code as it stands:

global.hps
void OnGameStart()
{
    StartLocketLoop();
}

void StartLocketLoop();
{
    AddDebugMessage("Locket Looping", false);
    if(GetPlayerSanity() >= 70 && !HasItem("HighSanityLocket"))
    {
        RemoveItem("MidSanityLocket");
        RemoveItem("LowSanityLocket");
        GiveItem("HighLocket", "Locket", "HighLocket", "locket.tga", 1);
        AddDebugMessage("Give High Locket", false);
    }
    else if(GetPlayerSanity() < 70 && GetPlayerSanity() >= 30 && !HasItem("MidSanityLocket"))
    {
        RemoveItem("HighSanityLocket");
        RemoveItem("LowSanityLocket");
        GiveItem("MidLocket", "Locket", "MidLocket", "locket.tga", 1);
        AddDebugMessage("Give Mid Locket", false);
    }
    else if(GetPlayerSanity() < 30 && !HasItem("LowSanityLocket"))
    {
        RemoveItem("MidSanityLocket");
        RemoveItem("HighSanityLocket");
        GiveItem("LowLocket", "Locket", "MidLocket", "locket.tga", 1);
        AddDebugMessage("Give Low Locket", false);
    }
    ReloopLocketTimer();
}

void ReloopLocketTimer()
{
    AddTimer("LocketLoop", 1.0f, StartLocketLoop);
}

I've tried calling "StartLocketLoop" from a map file as well, but it still doesn't want to trigger. I've tried putting the same script into Inventory.hps, but to no avail. Also, does the global.hps keep running between loading maps and relaunching the game etc?

Thanks,
Cyfiawn
(This post was last modified: 05-14-2013, 11:44 AM by Cyfiawn.)
05-14-2013, 11:38 AM
Find


Messages In This Thread
Using Global.hps to use a script in every level - by Cyfiawn - 05-14-2013, 11:38 AM



Users browsing this thread: 1 Guest(s)