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
Simple Scripting Problem
physcostealth Offline
Junior Member

Posts: 25
Threads: 12
Joined: Mar 2014
Reputation: 0
#1
Simple Scripting Problem

I'm having a little problem with scripting right now. Yesterday I was able to make the player walk into an area and have music play. Now, I want the player to walk into the same area and in doing so forces him to look at a door nearby. I've been scripting for a while today and I think everything is correct, but when I load the custom story it crashes. It did this to me yesterday when I tried loading the music area script, but all I did to fix it was delete the cache file of the map the script was tied to. Here's the code:

void OnStart()
    {
        AddEntityCollideCallback("Player", "SoundArea", "triggermusic", true, 1);
        AddEntityCollideCallback("Player", "SoundArea", "triggerlook", true, 1);
    }

void triggermusic(string &in asParent, string &in asChild, int alState)

    {
        PlayMusic("ThePatronusLight.ogg", true, 1.0, 0, 1, false);
    }
    
void triggerlook(string&in asTimer)    
    
    {
        StartPlayerLookAt("mansion_door", 1.0f, 1.0f, "");
        AddTimer("TimeDoor", 3.0f, "stoptimer");
    }
    
void stoptimer(string&is asTimer);
    {
        StopPlayerLookAt();
        SetPlayerActive(true);
    }

Any help will be appreciated. Thanks!
P.S All the names match with their counterparts in the level editor.
03-13-2014, 12:12 AM
Find Reply
Mudbill Offline
Muderator

Posts: 3,814
Threads: 59
Joined: Apr 2013
Reputation: 177
#2
RE: Simple Scripting Problem

I suggest indenting it correctly to make it easier to read. Tab only inside a block, not the block itself.

Your last timer, the stoptimer one, has a semi-colon at the end of the constructor. Remove that. Also add a space between string and &in within the parameters.

void stoptimer(string &in asTimer)
{
    StopPlayerLookAt();
    SetPlayerActive(true);
}

By the way, you can merge the triggermusic and triggerlook functions. Since they happen at the same time, they might as well be in the same function. It's not required though.

(This post was last modified: 03-13-2014, 12:51 AM by Mudbill.)
03-13-2014, 12:47 AM
Find Reply
Daemian Offline
Posting Freak

Posts: 1,129
Threads: 42
Joined: Dec 2012
Reputation: 49
#3
RE: Simple Scripting Problem

The only problem I see it's that triggerlook function is structured as if you were going to use it for a timer, but still you declare a callback for it.

Plus, you misspelled string&in, that could rise an error.

PHP Code: (Select All)
AddEntityCollideCallback("Player""SoundArea""triggerlook"true1); 

PHP Code: (Select All)
triggerlook(string&in asTimer

edit: And what he said above. xD

(This post was last modified: 03-13-2014, 12:55 AM by Daemian.)
03-13-2014, 12:53 AM
Find Reply
physcostealth Offline
Junior Member

Posts: 25
Threads: 12
Joined: Mar 2014
Reputation: 0
#4
RE: Simple Scripting Problem

Hey MudBill, you've been building the awesome temple story I've been watching lately. How would I be able to merge the two functions?

And thanks Amn, the misspelled code got rid of the crash. But when I enter the area the PlayerLookAt function doesn't do anything (the music plays, so I know that string is working). Could it be related to the structuring of the code? If so, how would I be able to fix this?

I was able to fix the problem. I combined the two functions together... I'm not sure if that's what fixed it or not.

void OnStart()
{
    AddEntityCollideCallback("Player", "SoundArea", "trigger", true, 1);
}

void trigger(string &in asParent, string &in asChild, int alState)

{
    PlayMusic("ThePatronusLight.ogg", true, 1.0, 0, 1, false);
    StartPlayerLookAt("mansion_door", 1.0f, 1.0f, "");
    AddTimer("TimeDoor", 3.0f, "timerstop");
}
    
void timerstop(string&in asTimer)
{
    StopPlayerLookAt();
    SetPlayerActive(true);
}
(This post was last modified: 03-13-2014, 01:13 AM by physcostealth.)
03-13-2014, 01:05 AM
Find Reply
Mudbill Offline
Muderator

Posts: 3,814
Threads: 59
Joined: Apr 2013
Reputation: 177
#5
RE: Simple Scripting Problem

Yes, that's exactly how you merge those functions. This looks just right Smile (Though the missing space is still absent, but if it works, perhaps it's not needed).

(This post was last modified: 03-13-2014, 05:20 PM by Mudbill.)
03-13-2014, 05:19 PM
Find Reply
DnALANGE Offline
Banned

Posts: 1,549
Threads: 73
Joined: Jan 2012
#6
RE: Simple Scripting Problem

Bump...
You should use the DEBUG MODE!
Google DEBUG MODE AMNESIA.
It should bring you there :
Well, i grabbed it for you.
You should have this into your FAVORITE ( internet explorere \ Firefox etc.. )
http://wiki.frictionalgames.com/hpl2/amn...evenvguide
For any more questions you can ask there here on the forum here :
-
Spoiler below!

Quote:In order to make maps for Amnesia you will need to set up the game, so you can easily test maps and reload scripts. First of all, follow these steps to create a dev user:
1.
Enter the game normally, create a profile name (e.g. MyName) and then exit.

2.
Enter the save directory (“My Documents/Amnesia/Main” in windows by default; ”~/.frictionalgames/Amnesia/Main” in Linux) and rename the user name (e.g. MyName) to “dev_user”.

3.
Open main_settings.cfg and set ShowMenu=“false”, ShowPreMenu=“false”, ExitMenuDirectly=“true”, LoadDebugMenu=“true” (also setting SaveConfig=“false” should be good).

4.
If Amnesia is 1.0.1 or above, you must set ForceCacheLoadingAndSkipSaving=“false” main_settings.cfg, or else map changes will not show!

5.
Open user_settings.cfg (in “dev_user” folder), inside the Debug element add AllowQuickSave=“true” (F4=save, F5=load) and change ScriptDebugOn=“true”.

6.
In user_settings.cfg, inside the Map element set Folder=”“ to the root folder for your maps (eg Folder=“MyMaps/”), this folder MUST be located inside the maps folder in the game directory (where you put the tools).

7.
In user_settings.cfg, inside the Map element set File=”“ to point to the map you want to load (eg File=“my_map.map”).

8.
In order to avoid running into “File index out of bounds” errors when designing your custom story in the level editor, edit the file resources.cfg located in the root the directory of Amnesia (i.e. where Amnesia is installed) and add the custom_stories directory to the list.


Now you can simply run Amnesia and the map will be loaded directly without any menu. You can now press F1 to open a debug menu to turn on/off various things and more importantly quick reload the map. This is probably the most important thing to do when editing. When changed a script or added entities to a map, do NOT restart the game, instead simply press “Quick reload”. If a mesh or texture has been updated, you need to press “Reload”.

(This post was last modified: 03-14-2014, 02:05 AM by DnALANGE.)
03-14-2014, 02:03 AM
Find Reply




Users browsing this thread: 1 Guest(s)