Jovismcp
Junior Member
Posts: 6
Threads: 1
Joined: Jul 2011
Reputation:
0
|
Scripting help needed
Hi, I've been working on a custom story and have read multiple tutorials but none of my scripts in the .hps files seem to work. I've checked and I'm pretty sure I have written the same as the authors and video makers word for word, but it doesn't work. I'm using TextWrangler on Mac OS X and I've checked that it is set to plain text, but it still fails to do anything. Things on the extra_english.lang file work but those on the .hps don't. Help would be much appreciated, thanks.
|
|
07-16-2011, 01:15 PM |
|
palistov
Posting Freak
Posts: 1,208
Threads: 67
Joined: Mar 2011
Reputation:
57
|
RE: Scripting help needed
Does Amnesia crash when you start up one of your scripted maps, or is it that your scripted events just don't happen at all?
If it's a crash on mapstart, fix the errors in your script file then try again. If it's your script simply not doing anything, make sure:
1) Your map's name and script file's name match: mymap.map & mymap.hps
2) Make sure your script has these three functions somewhere in it: void OnStart() {} void OnEnter() {} & void OnLeave() {}
3) Make sure for things like collide callbacks, item interactions, etc that they are added in your OnStart function. Collisions don't happen when they aren't declared, and interactions don't exist unless they are declared, etc. Make sure the functions have the proper tags too.
A function called by a collision between two entities needs this tag:
void YourCollisionCallback(string &in parent, string &in child, int state) {}
A function called after a timer runs out will have this tag:
void YourTimerCallback(string &in timer) {}
There are other types too, and if they aren't correct then the function won't do anything, and you might even crash on mapstart.
(This post was last modified: 07-16-2011, 04:05 PM by palistov.)
|
|
07-16-2011, 04:01 PM |
|
Jovismcp
Junior Member
Posts: 6
Threads: 1
Joined: Jul 2011
Reputation:
0
|
RE: Scripting help needed
(07-16-2011, 04:01 PM)palistov Wrote: Does Amnesia crash when you start up one of your scripted maps, or is it that your scripted events just don't happen at all?
If it's a crash on mapstart, fix the errors in your script file then try again. If it's your script simply not doing anything, make sure:
1) Your map's name and script file's name match: mymap.map & mymap.hps
2) Make sure your script has these three functions somewhere in it: void OnStart() {} void OnEnter() {} & void OnLeave() {}
3) Make sure for things like collide callbacks, item interactions, etc that they are added in your OnStart function. Collisions don't happen when they aren't declared, and interactions don't exist unless they are declared, etc. Make sure the functions have the proper tags too.
A function called by a collision between two entities needs this tag:
void YourCollisionCallback(string &in parent, string &in child, int state) {}
A function called after a timer runs out will have this tag:
void YourTimerCallback(string &in timer) {}
There are other types too, and if they aren't correct then the function won't do anything, and you might even crash on mapstart.
I've got all of those functions in my script and it seems correct, but it still doesn't work. It doesn't crash when I run it but for some reason, since I posted originally, the map that I load isn't the same as the map on the level editor. It contains all of the same fog effects and billboards but some of the static objects I added afterwards aren't there, there's just an extended floor where they should be, which isn't on the level editor, I've tried removing it and replacing it but it still seems to be there. There just seems to be a massive string of problems that don't like being solved.
|
|
07-17-2011, 09:07 AM |
|
palistov
Posting Freak
Posts: 1,208
Threads: 67
Joined: Mar 2011
Reputation:
57
|
RE: Scripting help needed
Ahh. Close Amnesia, open the folder that contains your map file and delete the map_cache file. Then re-launch Amnesia. That should solve your script problems, since the map cache has old information and may not match the names you use in your script. Good luck
|
|
07-17-2011, 09:09 AM |
|
Jovismcp
Junior Member
Posts: 6
Threads: 1
Joined: Jul 2011
Reputation:
0
|
RE: Scripting help needed
(07-17-2011, 09:09 AM)palistov Wrote: Ahh. Close Amnesia, open the folder that contains your map file and delete the map_cache file. Then re-launch Amnesia. That should solve your script problems, since the map cache has old information and may not match the names you use in your script. Good luck
Thanks, that solved the map problem but the scripts still fail to work. I'll post what I've got in the .hps file. Sorry if you find some really noobish mistakes:
void OnStart()
{
AddEntityCollideCallback("Player", "RoomTwoArea", "CollideRoomTwo", true, 1);
AddEntityCollideCallback("Player", "Rubble_Quest_Area", "GetRubbleQuest", true, 1);
AddEntityCollideCallback("Player", "Rubble_Complete_Area", "FinishRubbleQuest", true, 1);
}
void OnEnter()
{
}
void CollideRoomTwo(string &in asParent, string &in asChild, int State)
{
SetSwingDoorClosed("prison_section_1", true, true);
}
void GetRubbleQuest(string &in asParent, string &in asChild, int State)
{
AddQuest("rubblequest", "RubbleQuest");
}
void FinishRubbleQuest(string &in asParent, string &in asChild, int State)
{
CompleteQuest("rubble1quest", "RubbleQuest");
}
void OnLeave()
{
}
|
|
07-17-2011, 09:19 AM |
|
palistov
Posting Freak
Posts: 1,208
Threads: 67
Joined: Mar 2011
Reputation:
57
|
RE: Scripting help needed
AddQuest(" rubblequest", "RubbleQuest");
CompleteQuest(" rubble1quest", "RubbleQuest");
Quest name has to match. Also you can compact your script by having the quest functions combined into one.
void OnStart()
{
AddEntityCollideCallback("Player", "RoomTwoArea", "CollideRoomTwo", true, 1);
AddEntityCollideCallback("Player", "Rubble_Quest_Area", "RubbleQuest", true, 1);
AddEntityCollideCallback("Player", "Rubble_Complete_Area", "RubbleQuest", true, 1);
}
void RubbleQuest(string &in parent, string &in child, int state)
{
if(child == "Rubble_Quest_Area") AddQuest("rubblequest", "RubbleQuest");
if(child == "Rubble_Complete_Area") if(QuestIsAdded("rubblequest")) CompleteQuest("rubblequest", "RubbleQuest");
}
(This post was last modified: 07-17-2011, 09:32 AM by palistov.)
|
|
07-17-2011, 09:32 AM |
|
Jovismcp
Junior Member
Posts: 6
Threads: 1
Joined: Jul 2011
Reputation:
0
|
RE: Scripting help needed
(07-17-2011, 09:32 AM)palistov Wrote: AddQuest("rubblequest", "RubbleQuest");
CompleteQuest("rubble1quest", "RubbleQuest");
Quest name has to match. Also you can compact your script by having the quest functions combined into one.
void OnStart()
{
AddEntityCollideCallback("Player", "RoomTwoArea", "CollideRoomTwo", true, 1);
AddEntityCollideCallback("Player", "Rubble_Quest_Area", "RubbleQuest", true, 1);
AddEntityCollideCallback("Player", "Rubble_Complete_Area", "RubbleQuest", true, 1);
}
void RubbleQuest(string &in parent, string &in child, int state)
{
if(child == "Rubble_Quest_Area") AddQuest("rubblequest", "RubbleQuest");
if(child == "Rubble_Complete_Area") if(QuestIsAdded("rubblequest")) CompleteQuest("rubblequest", "RubbleQuest");
}
I've removed the '1' and combined the quest functions but it still won't add the memento or swing the door closed. Thanks for your help so far, and sorry for being so persistent.
|
|
07-17-2011, 09:48 AM |
|
Jovismcp
Junior Member
Posts: 6
Threads: 1
Joined: Jul 2011
Reputation:
0
|
RE: Scripting help needed
Hi, I'd just like to say that I managed to fix the problems.
|
|
07-17-2011, 09:23 PM |
|
|