Facebook Twitter YouTube Frictional Games | Forum | Privacy Policy | Dev Blog | Dev Wiki | Support | Gametee


Thread Rating:
  • 1 Vote(s) - 4 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Fatal Error Help!!
Abion47 Offline
Senior Member

Posts: 369
Threads: 22
Joined: Oct 2015
Reputation: 46
#6
Not Solved RE: Fatal Error Help!!

Okay.

First, you NEED to start practicing proper indenting of your code. Not only does it make your code much cleaner and easier to read and write, it also pinpoints simple mistakes. For example, if I was to take your code and indent it based on the placements of curly braces, several sources of the problem becomes obvious:

PHP Code: (Select All)
///////////////////////////
// Run when the map starts
void OnStart()
{
    
AddUseItemCallback("""RoomKey""Bedroom""usekeyondoor"true);
}

void usekeyondoor(string &in asItemstring &in asEntity);
SetLevelDoorLocked("Bedroom"falsetrue);
PlaySoundAtEntity("""unlock_door.snt"asEntity0false);
RemoveItem(asItem);

void OnLeave()


Every single line of code after void usekeyondoor(string &in asItem, string &in asEntity); is orphaned, meaning it has no function that it belongs to. This is not allowed in this scripting language - the vast majority of code that you write for HPL2 has to exist within a function.

The reason that it is orphaned is because of two things. First, you put a semicolon (";") at the end of the function declaration, which effectively ends the function. Second, you did not put any curly braces ("{" and "}") after the function declaration to encapsulate the code that will be inside the function. The engine cannot magically read your mind and deduce what you want it to do. If you want the code to be in a function, you have to tell it to be in a function.

Another issue is that last trailing closing curly brace ("}") at the end of your code. This has no preceding open curly brace ("{") and so is going to be orphaned as well, causing an error.

However, if in either my or Modbull's explanation of things you ever got confused by terminology such as "function declaration", then there is a more fundamental issue here. Your understanding of programming is extremely piecemeal, and you don't have the base knowledge required to read and write functional scripts. Rather than spend weeks or months trying to cobble together a general understanding, it will be much easier for you to go through a proper tutorial series and learn programming properly. I recommend a language like Javascript as a balance of ease of learning and similarity to HPL2. Go through the lessons at the link below, then revisit your code, at which point many of the mistakes you're making will become more clear.

http://www.learn-js.org/

12-12-2017, 11:51 PM
Find


Messages In This Thread
Fatal Error Help!! - by tigerlillymaya13 - 12-10-2017, 07:11 PM
RE: Fatal Error Help!! - by Mudbill - 12-11-2017, 01:21 AM
RE: Fatal Error Help!! - by tigerlillymaya13 - 12-11-2017, 04:27 PM
RE: Fatal Error Help!! - by Mudbill - 12-11-2017, 10:54 PM
RE: Fatal Error Help!! - by tigerlillymaya13 - 12-12-2017, 04:57 PM
RE: Fatal Error Help!! - by Abion47 - 12-12-2017, 11:51 PM
RE: Fatal Error Help!! - by tigerlillymaya13 - 12-13-2017, 05:05 PM
RE: Fatal Error Help!! - by tigerlillymaya13 - 12-13-2017, 11:20 PM



Users browsing this thread: 1 Guest(s)