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
Script doesn't work?
Henriksen Offline
Senior Member

Posts: 308
Threads: 71
Joined: Dec 2010
Reputation: 2
#1
Question  Script doesn't work?

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
10-24-2018, 05:45 PM
Find
Abion47 Offline
Senior Member

Posts: 369
Threads: 22
Joined: Oct 2015
Reputation: 46
#2
RE: Script doesn't work?

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:


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.

(This post was last modified: 10-24-2018, 07:38 PM by Abion47.)
10-24-2018, 07:35 PM
Find
Henriksen Offline
Senior Member

Posts: 308
Threads: 71
Joined: Dec 2010
Reputation: 2
#3
RE: Script doesn't work?

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
 
}
10-24-2018, 07:52 PM
Find
Abion47 Offline
Senior Member

Posts: 369
Threads: 22
Joined: Oct 2015
Reputation: 46
#4
RE: Script doesn't work?

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.

10-25-2018, 02:57 AM
Find
Henriksen Offline
Senior Member

Posts: 308
Threads: 71
Joined: Dec 2010
Reputation: 2
#5
RE: Script doesn't work?

(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
10-25-2018, 08:05 PM
Find




Users browsing this thread: 2 Guest(s)