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
Please check the troubleshooting guides before posting!
dailycreepypasta Offline
Junior Member

Posts: 32
Threads: 18
Joined: Aug 2014
Reputation: 0
#1
Please check the troubleshooting guides before posting!

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");
}

Creator of "The Night I Went Insane".

http://www.moddb.com/mods/the-night-i-went-insane
08-16-2014, 05:41 PM
Find
TheGreatCthulhu Offline
Member

Posts: 213
Threads: 10
Joined: Oct 2010
Reputation: 32
#2
RE: Please check the troubleshooting guides before posting!

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: (Select All)
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.
(This post was last modified: 08-16-2014, 07:05 PM by TheGreatCthulhu.)
08-16-2014, 07:02 PM
Find
PutraenusAlivius Offline
Posting Freak

Posts: 4,713
Threads: 75
Joined: Dec 2012
Reputation: 119
#3
RE: Please check the troubleshooting guides before posting!

(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.

"Veni, vidi, vici."
"I came, I saw, I conquered."
(This post was last modified: 08-17-2014, 01:30 AM by PutraenusAlivius.)
08-17-2014, 01:30 AM
Find




Users browsing this thread: 1 Guest(s)