Frictional Games Forum (read-only)

Full Version: Please check the troubleshooting guides before posting!
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
I tried running my game and I got this error message:

FATAL ERROR: Could not load script file 'custom_stories/(My Custom Story Name)/maps/(My Custom Story).hps'!
main (13,23): ERR : Expected identifier
main (14,10): ERR : Expected identifier
main (15,24): ERR : Expected identifier
main (16,31): ERR : Expected identifier
main (17,33): ERR : Expected identifier
main (19,17): ERR : Expected identifier
main (21,18): ERR : Expected identifier

Red Text= Lines 13-21
My .hps file:

void OnStart()
{
AddUseItemCallback("", "main_key", "main_door", "UseKeyOnDoor", true);
}

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

TeleportPlayer("Intro_0");
FadeOut(0);
SetPlayerActive(false);
SetSanityDrainDisabled(true);
ShowPlayerCrossHairIcons(false);

AddTimer("fadein", 3, "TimerIntroOutro");

PlayMusic("Mysterious_Journey_-_Epic_Trailer_Music.ogg", false, 1, 0, 1, true);



void TimerIntroOutro(string &in asTimer)
{
if(GetLocalVarInt("Intro") < 3) {

if(asTimer == "fadein") {
TeleportPlayer("Intro_" + GetLocalVarInt("Intro"));
FadeIn(1);
AddTimer("fadeout", 4, "TimerIntroOutro");
}

if(asTimer == "fadeout") {
FadeOut(1);
AddTimer("fadein", 1, "TimerIntroOutro");
AddLocalVarInt("Intro", 1);
}
}
else
{
TeleportPlayer("Spawn");
FadeIn(2);
SetPlayerActive(true);
SetSanityDrainDisabled(false);
ShowPlayerCrossHairIcons(true);

PlayMusic("Mysterious_Journey_-_Epic_Trailer_Music.ogg", false, 0.2, 1, 2, true);
}
}

void OnLeave()
{
SetupLoadScreen("Loading", "LoadScreen1", 0, "loading_screen1.jpg");
}
All of the code that does something with the game should be within some function (either inside OnStart(), OnEnter(), OnLeave(), or within some callback - such as a timer callback). The game will, at appropriate times, call these functions, and whatever code you put inside them will execute.

If you look at the code in red, you'll see that it's not inside any function (not surrounded by { and } ) - it sort of just hangs in "empty space", so even if it compiled, the game wouldn't know how or when to call that code.

Now, how exactly to fix this error depends on what exactly you want to do. When exactly you want this code to execute?
Based on the placement - maybe you want this to run when the player uses the key on a door?
If so, seems like moving those lines of code into the function above them should work:

PHP Code:
void UseKeyOnDoor(string &in asItemstring &in asEntity)
{
    
SetSwingDoorLocked(asEntityfalsetrue);
    
PlaySoundAtEntity("""unlock_door.snt"asEntity0false);
    
RemoveItem(asItem);

    
TeleportPlayer("Intro_0");
    
FadeOut(0);
    
SetPlayerActive(false);
    
SetSanityDrainDisabled(true);
    
ShowPlayerCrossHairIcons(false);

    
AddTimer("fadein"3"TimerIntroOutro");

    
PlayMusic("Mysterious_Journey_-_Epic_Trailer_Music.ogg"false101true);


P.S. When asking questions about scripting, you're more likely to get help if you explain what are you trying to do in more detail, what is the error, what is happening vs what should be happening, etc.

P.P.S. If you're not familiar with terms like "function" and "callback", check out the wiki, and some tutorials here on the forums to learn the basics - you can't really script if you don't understand what you're doing.
(08-16-2014, 05:41 PM)dailycreepypasta Wrote: [ -> ] TeleportPlayer("Intro_0");
FadeOut(0);
SetPlayerActive(false);
SetSanityDrainDisabled(true);
ShowPlayerCrossHairIcons(false);

AddTimer("fadein", 3, "TimerIntroOutro");

PlayMusic("Mysterious_Journey_-_Epic_Trailer_Music.ogg", false, 1, 0, 1, true);

As what TheGreatCthulhu said, this code is not contained in a function.