05-14-2013, 11:38 AM
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
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
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
Code:
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