Frictional Games Forum (read-only)
Script doesn't work? - Printable Version

+- Frictional Games Forum (read-only) (https://www.frictionalgames.com/forum)
+-- Forum: SOMA (https://www.frictionalgames.com/forum/forum-55.html)
+--- Forum: User created content (https://www.frictionalgames.com/forum/forum-79.html)
+---- Forum: Technical Support (https://www.frictionalgames.com/forum/forum-80.html)
+---- Thread: Script doesn't work? (/thread-54772.html)



Script doesn't work? - Henriksen - 10-24-2018

Hello!

Recently bought SOMA and have tried to get back into modding. I figured the scripting would be similar to the scripting in Amnesia, but I understand the language has changed somewhat. I have made a map and created a .hps file, but even the most basic functions doesn't seem to work. Another problem I'm having is having to restart the game in order for it to register the script having been changed.

I'll just put the script here since it's so short:


Quote:void Setup()
{

}

void OnStart()
{
cLux_AddDebugMessage("Hello.");
}

void OnEnter()
{

}

void OnLeave()
{

}


Thanks in advance


RE: Script doesn't work? - Abion47 - 10-24-2018

Is that the entire contents of your map script file? If so, then that's why it isn't working. The structure of the script files have changed from Amnesia. Where Amnesia's script files were just a bunch of root-level functions (like yours), SOMA's script files are fully enclosed in class objects like this:


Code:
class MapClass : cLuxMap
{
    void Setup()
    {

    }

    void OnStart()
    {
        cLux_AddDebugMessage("Hello.");
    }

    void OnEnter()
    {

    }

    void OnLeave()
    {

    }
}

Also, you shouldn't ever need to manually create the map script file yourself. When you create a map with the level editor, the script file ("MapName.hps") will automatically be generated in the same folder as your map with this whole structure along with all the common map functions. I don't recommend changing the default names of the class or those pre-generated functions unless you know what you are doing. (You can create your own custom functions as much as you want, though.)

For a description of all the map functions and how they work, you can read this page on the wiki. For a more general overview on how AngelScript in HPL3 works, I'd recommend following this tutorial.


RE: Script doesn't work? - Henriksen - 10-24-2018

I see, thank you. I made another map and got the default script file, but I still can't seem to get anything working. I'm currently trying to get a levithian to move from its current position to a trigger area using CharMover_MoveToEntity but I cant seem to get that to work either. I put the function(?) in the OnStart class(?). I have no idea what I'm doing wrong, but it seems the game isn't registring the changes I'm making to the file.

Quote:#include "interfaces/Map_Interface.hps"
#include "base/Inputhandler_Types.hps"

#include "helpers/helper_map.hps"
#include "helpers/helper_props.hps"
#include "helpers/helper_effects.hps"
#include "helpers/helper_audio.hps"
#include "helpers/helper_imgui.hps"
#include "helpers/helper_sequences.hps"
#include "helpers/helper_game.hps"
#include "helpers/helper_modules.hps"
#include "helpers/helper_ai.hps"

//--------------------------------------------------
 
/*Place any global values here. These must be const variables as they will not be saved*/
/*This is also the place for enums and classes, but these should be avoided whenever possible*/
 
//--------------------------------------------------
 
class cScrMap : iScrMap
{
//--------------------------------------------
 
//////////////////////////////////////////////////////////////////////////////////////////
// ==============
// MAIN CALLBACKS
// ==============
//{///////////////////////////////////////////////////////////////////////////////////////
 
//-------------------------------------------------------
 
////////////////////////////
// Set up map environment
void Setup()
{

}

//-------------------------------------------------------

////////////////////////////
// Run first time starting map
void OnStart()
{
        CharMover_MoveToEntity("leviathan_1","TriggerArea_1");
}

//-------------------------------------------------------

////////////////////////////
// Run when entering map
void OnEnter()
{
}

//-------------------------------------------------------

////////////////////////////
// Run when leaving map
void OnLeave()
{
}

//-------------------------------------------------------

////////////////////////////
// The player has died.
void OnPlayerKilled(int alRecentDeaths, const tString&in asSource)
{
}

//-------------------------------------------------------

////////////////////////////
// To get when player makes input (mostly used for debug)
void OnAction(int alAction, bool abPressed) 
{
if(abPressed==false) return;

if(alAction == eAction_Test1)
{
}
}

//-------------------------------------------------------

////////////////////////////
// This only used for pure debug purposes when info needs to printed.
float DrawDebugOutput(cGuiSet @apSet,iFontData @apFont,float afY)
{
//afY = cLux_DrawDebugText("My Debug value:"+..., afY);
return afY;
}
 
//-------------------------------------------------------
 
//} END MAIN CALLBACKS
 
 
//////////////////////////////////////////////////////////////////////////////////////////
// ==============
// MAIN FUNCTIONS
// ==============
//{///////////////////////////////////////////////////////////////////////////////////////
 
//-------------------------------------------------------
 
/*Put any variables that are used in more than one scene here.*/
 
//-------------------------------------------------------
 
/*Put any functions that are used in more than one scene here.*/
 
//-------------------------------------------------------
 
//} END MAIN FUNCTIONS
 
//////////////////////////////////////////////////////////////////////////////////////////
// ==============
// SCENE X *NAME OF SCENE*
// ==============
//{//////////////////////////////////////////////////////////////////////////////////////
 
/////////////////////////////////////////
// General
//{//////////////////////////////////////
 
//-------------------------------------------------------
 
/*Put any variables that are used by many events in Scene X here.*/
 
//-------------------------------------------------------
 
/*Put any functions that are used in more than one event in Scene X here.*/
 
//-------------------------------------------------------

//} END General
 
/////////////////////////////////////////
// Event *Name Of Event*
//{//////////////////////////////////////
 
//-------------------------------------------------------
 
/*Put any variables that are only used in Scene X, Event X here.*/
 
//-------------------------------------------------------
 
/*Put any functionsthat are only used in Scene X, Event X here.*/
 
//-------------------------------------------------------
 
//} END Event *Name Of Event*
 
//} END SCENE X
 
 
/////////////////////////////////////////
// ==============
// TERMINALS
// ==============
//{//////////////////////////////////////
 
//-------------------------------------------------------
 
/////////////////////////////////////////
// Terminal *Name Of Terminal*
//{//////////////////////////////////////
 
//-------------------------------------------------------
 
/*Put any variables that are only used Terminal here.*/
 
//-------------------------------------------------------
 
/*Put any functions that are only used Terminal here.*/
 
//-------------------------------------------------------
 
//} END Terminal *Name Of Terminal*

//} END TERMINALS
 
}



RE: Script doesn't work? - Abion47 - 10-25-2018

You might try moving the code into `OnEnter`. `OnStart` is for initialization stuff that happens the first time the game loads a particular map, while `OnEnter` is the one that fires when the map is loading the player into it.


RE: Script doesn't work? - Henriksen - 10-25-2018

(10-25-2018, 02:57 AM)Abion47 Wrote: You might try moving the code into `OnEnter`. `OnStart` is for initialization stuff that happens the first time the game loads a particular map, while `OnEnter` is the one that fires when the map is loading the player into it.

Thanks, I got it working at last by including these:

#include "helper_custom_depth.hps"
#include "helper_custom_depth_ai.hps"
#include "helper_custom_depth_ai_leviathan.hps"

Thanks again Smile