Warning [2] count(): Parameter must be an array or an object that implements Countable - Line: 906 - File: showthread.php PHP 7.2.24-0ubuntu0.18.04.17 (Linux)
Common Custom Story Errors + Fixes! -- READ HERE BEFORE POSTING!!
I made this thread to help diminish the amount of reptitive/common questions that pop up here in the Development Support section of the forum. Hopefully if you're having a problem, this will clear it up for you without you having to make a thread. If nothing here helps, feel free to create a thread for it, do not respond in here with questions regarding your error!
Common Scripting Errors
________________________________________________
Q) I start a level and the game crashes with a report that comes up:
FATAL ERROR: Could not load script file
'.....map.hps'!
main (#, #): ERR : Expected/Unexpected "____" A)
Spoiler below!
This means at the hps the game trying to load, there is either something missing or unnecessary in the location described in: main (#, #). The first "#" is how many lines of code down it is, the second "#" is how many digits to the right it is in that line. If you played Battleship before, it's a lot like giving the code to an enemy to try and hit their ships. Though sometimes it does not appear EXACT.
Example) FATAL ERROR: Could not load script file
'.....map.hps'!
main (46, 2): ERR : Expected ";"
Line 43: void function(string &in asParent, string &in asChild, int alState)
Line 44: {
Line 45: PlaySoundAtEntity("", "spookysounds.snt", "ScriptArea_1", 0, false)
Line 46: AddTimer("", 5, "function2");
Line 47: }
Can you find it?... Line 46, two digits over (where AddTimer is starting) is expecting a ";". Obviously, there should not be one before it, so if Line 46 cannot be read, there is a problem before it. At the end of line 45, there should be a ";". Place that there and you should be good to go.
~ ~ ~
Q) I start a level and the game crashes with a report that comes up:
FATAL ERROR: Could not load script file
'.....map.hps'!
main (#, #): ERR : '_________' is not declared! A)
Spoiler below!
This means that a phrase in a function does not have quotations around it, or otherwise, not declared. Simply add quotations around the phrase the error gave and ta-dah!
Example) FATAL ERROR: Could not load script file
'.....map.hps'!
main (45, 24): ERR : 'spookysounds' is not declared
Line 43: void function(string &in asParent, string &in asChild, int alState)
Line 44: {
Line 45: PlaySoundAtEntity("", spookysounds.snt, "ScriptArea_1", 0, false);
Line 46: AddTimer("", 5, "function2");
Line 47: }
As the error states, there are no quotation marks around "spookysounds.snt" in Line 45, 24 digits over.
~ ~ ~
Q) The game doesn't crash, but the script doesn't work! Nothing happens! A)
Spoiler below!
There are a couple of possible reasons, try and see which one fits yours: 1 - Check to make sure your declarations are spelled correctly or that they are being declared at the correct place. (if you want a sound to occur at ScriptArea_1, make sure it says that and not ScriptArea_2) 2 - Make sure you have the correct syntax in your function callback! 3 - Are you scripting in the correct .hps and not perhaps a backup? (I've done it before...) 4 - If a script area is responsible, make sure:
....... a. The proper script areas are properly sized and active
....... b. The script area you are using is not activating somehow directly from the start and you are not within visual/audio distance to hear it activate. This can be caused by the AddEntityCollideCallback in your script. 1: Entering the Script Area, -1: Leaving the Script Area, 0: Leaving/entering the Script Area
~ ~ ~
Common .lang File Errors
________________________________________________
IMPORTANT: First off, note that if there is a problem in the .lang file, Amnesia WILL NOT give an error report. If there is an error, anything involving the .lang will not show in game. For example, if you create an entry for, say, a SetMessage, and you created it incorrectly, the custom story description, the credits, notes, diaries, etc will not show in-game. KEEP THIS IN MIND!
Q) I added a few entries and now nothing shows anywhere! A)
Spoiler below!
1: This is quite common as I have stated above. Make sure you spelled the most recent entry you created correctly and make sure you closed it off correctly!
<Entry Name="blahblah">Herpity Derp</Entry>
2: Make sure you have the proper Category created and that everything in the .lang is enclosed in:
<LANGUAGE>
...
...
...
</LANGUAGE>
3: Make sure you don't have unknown objects in your entries! (I've seen a "<P>" used before and it doesn't do anything, it only caused a failure)
4: Make sure the file itself is spelled EXACTLY: "extra_english.lang". No capitals or spelling errors. It should also be .lang, not .txt, .hps, .rtf, etc.
5: Make sure you have it located in: redist/custom_stories/MyCustomStory/... Don't put it in any other sub-folders!
~ ~ ~
Q) I pressed Enter/Return Key in my lang file to break lines, but it doesn't break in-game! It just stays one whole line! A)
Spoiler below!
Pressing Enter/Return Key does nothing but help you keep things organized. To break lines, use [br].
~ ~ ~
Q) I added a voice for my paper, but it won't play when I pick it up/the paper doesn't even open immediately! A)
1: The entity must be "diary_paper01", and not a note entity!
2: The "[voice narration.ogg]" must have its own line in the .lang. Putit at the top and write it like this: <CATEGORY Name="Journal">
<Entry Name="Diary_diary1_Name1">Diary Letter #1</Entry>
<Entry Name="Diary_diary1_Text1"> [voice diary1_pt1.ogg][br]
blahblahblahblah
The audio clip determines the length of time the page stays up and what page it "reads". Note above that what is depicted will have two pages, and need two different sound clips for each page.
~ ~ ~
Common Level Problems
________________________________________________
Q) I added new assets in the Level Editor, but they don't show up in-game! / Primitives don't show! A)
Spoiler below!
Check your custom story folder for a .map_cache located in the same location as the corresponding map. If there is one, delete it and run the level again.
~ ~ ~
Q) I added a new model that showed up when I imported to ModelEditor and picked a material, but it is invisible in the Level Editor! A)
Spoiler below!
This is a problem related to the model. The material simply helps the model use other textures mixed with variables such as translucency or UV animation. You need to open the model's .dae file in something like Notepad(++) and press Ctrl+F. This will bring up the search option. Search for "library_images" and under it, you will find directories to the diffuse of each mesh within the model. Make sure the directory is locating the proper texture you want and save it.
Once you saved it, open the .dae in ModelView. If the model loads with the texture, you should be good to go. To fix it further if need be, open the material regarding the model in MaterialEditor and do with it what you will. Save when finished and try loading the model in the Level Editor again. It should show up.
Q) I saved a map and opened it again and got a message that said:
WARNING:
Found some errors while loading file. Check log for details. File index out of bounds!
A)
Spoiler below!
The level editor is simply not loading any custom textures, particles, entities, static objects, billboards, etc. To fix, exit the level editor, BE CAREFUL NOT TO SAVE, and open the "resources.cfg" in your redist folder. Add this directory in there:
The Level Editor uses the directories in the resources.cfg to load assets. The custom_stories folder directory is not in there by default, so you have to add it manually if you have custom assets in your custom story folder. Save your resources.cfg and open the map in Level Editor again. Everything should load and the error should not come up anymore. (If you are trying to load an Isolated Full Conversion, simply add a directory to your IFC as well and it should work as well)
~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~
This is all I have off the top of my head for now! If anyone has more to contribute or something I need to fix, please respond here and I'll get to it as soon as I can. Hopefully this helped!
(This post was last modified: 03-11-2013, 07:29 PM by Statyk.)