User Tools

Site Tools


hpl2:tutorials:script:problem

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revision Previous revision
Next revision
Previous revision
hpl2:tutorials:script:problem [2012/05/15 17:21]
stepper
hpl2:tutorials:script:problem [2013/10/14 23:26] (current)
thegreatcthulhu [Unexpected end of file]
Line 12: Line 12:
  
  
-[[{{http://​i.imgur.com/​knVOP.png?​direct& ​ }}]] While this error is hard to find in a large script. I put it in a short script.+While this error is hard to find in a large script. I put it in a short script. 
 + 
 + 
 +{{http://​i.imgur.com/​knVOP.png ​   }}
  
  
Line 19: Line 22:
 The 132 in my line is the position, this is really hard to find in Notepad. But easy in Notepad++, it's on the side.\\ ​ The 132 in my line is the position, this is really hard to find in Notepad. But easy in Notepad++, it's on the side.\\ ​
 So, i now know 132 is the position from up to down in my script. 2 is the position in that line. (left to right)\\ ​ So, i now know 132 is the position from up to down in my script. 2 is the position in that line. (left to right)\\ ​
-So, the position is 132 to down and 2 to right. Now you can go look what is missing, or wrong.+So, the position is 132 to down and 2 to right. Now you can go look what is missing, or wrong. ​
  
  
-\\  +====== Fixing the errors======
-\\  +
-\\  +
-                    //Fatal error message box.// +
  
  
-====== Fixing ​the errors======+Debugging ​the error that cause the game to crash before it even starts is a pain; fortunately,​ you don't have to restart the game every time - there'​s an easier way to do it, assuming you've [[hpl2:​amnesia:​devenvguide|set up your development environment correctly]]. Make a copy of the your current, erroneous script text, and store it somewhere for the time being. The goal is to make the map load correctly. So, either revert your map script to an earlier, working version, or just delete everything, and just put in an empty OnStart() method. Also, make sure that the game launches in //windowed mode//, so that you can edit the script while the game is running.
  
  
-Now we are going to fix the errorsI have put some errors right hereif you have another ​error, ​please Message me on the forums.+Once the game loads the map successfully,​ bring up the development menu (F1), and then go to your script editor, delete everything, and paste back the original, error producing codeSaveswitch back to the game window, and reload the script. This time, the game will show you an error messagebut it will not crash. //This is a huge timesaver!//​ Take note of the error message; it will usually give you a reasonably accurate description of what the problem is (although sometimes it might be a bit cryptic), and it will point you to the line in the file where the problem appears to be (often, it is the correct line, sometimes, it is one line above, or below, or close by). Note that the code editors like [[hpl2:​third_party_tools:​text:​notepad|Notepad++]] or [[hpl2:​third_party_tools:​text:​geany|Geany]] show you what line you'​re ​on in their status line. Also, they support syntax highlighting,​ with will greatly improve ​the readability of your code and also help you find some of the common errors. These are third-party tools, and are free.
  
  
-===== **Unexpected end of file**  ​=====+Now we are going to fix the errors. I have put some errors right here, if you have another error, please Message me (stepper) on the forums. 
 + 
 +===== Unexpected end of file =====
  
  
Line 40: Line 42:
  
  
-{{http://​i.imgur.com/​SyBQW.png?​direct&​}}\\ +{{http://​i.imgur.com/​SyBQW.png?​direct&​}} 
 + 
 Oh look, i found it. My error tells that it's on (132, etc…) altough it's actually on (19, etc…) (not shown on the image) So now i just replace it. And Done! Oh look, i found it. My error tells that it's on (132, etc…) altough it's actually on (19, etc…) (not shown on the image) So now i just replace it. And Done!
 +
 +
 +However, if you use syntax highlighting capability that comes with code editors, you will probably be able to find the problem spot more quickly. This is because, if syntax highlighting is enabled, string literals (the things written in double quotes, "like this") are displayed in a different color then the rest of the text; so if you forget a closing quote, there will be a piece of your code that will //look a bit wrong//. Your error will be there. Even so, the error still might not be too easy to spot, but it will be easier compared to not having syntax highlighting,​ when the text looks uniformly black.
 +
 +
 +In any case, having syntax highlighting will help you avoid this type of error //as you write the script//, since you'll be immediately able to see that you've accidentally omitted a quotation mark.
 +
 +
 +Here's how syntax highlighting looks like:
 +
 +
 +{{:​hpl2:​tutorials:​script:​shlcode.jpg?​nolink& ​ }}
 +
 +
 +
 +HPL2 engine uses AngelScript for scripting, but since it's syntax is similar to the languages in the C family, you can set up your editor to use syntax highlighting for C# or C++, or, if you're using Notepad++ or Geany, configure your editor as described on the corresponding page on this wiki.
  
hpl2/tutorials/script/problem.1337102465.txt.gz · Last modified: 2012/05/15 17:21 by stepper