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 Help Sanity Function
Romulator Offline
Not Tech Support ;-)

Posts: 3,628
Threads: 63
Joined: Jan 2013
Reputation: 195
#2
RE: Sanity Function

Hello! It's actually rather simple. We simply use an "If-Conditional" to check whether the sanity is lesser than a certain value, and if so, execute some code. If you see the first if-block on that page I linked, and combine it with a function where we return a value on the Engine Scripts page, you can make something like this:

Spoiler below!
PHP Code: (Select All)
void OnStart()
{
    
AddEntityCollideCallback("Player""Area_sanity_collide_event""trigger_function"false0);
}

void trigger_function(string &in asParentstring &in asChildint alState)
{
    if(
GetPlayerSanity() < 33.0f)
    {
    
//Code, if true, here. That is, if the player has less than 33.0 sanity.
    
}


Or

PHP Code: (Select All)
void OnStart()
{
    
AddEntityCollideCallback("Player""Area_sanity_collide_event""trigger_function"false1);
}

void trigger_function(string &in asParentstring &in asChildint alState)
{
    if(
GetPlayerSanity() < 33.0f)
    {
    
//Code, if true, here. That is, if the player has less than 33.0 sanity.
    
}
    else
    {
    
//Code, if false, here. That is, if the player has more than 33.0 sanity.
    
}



A few notes:
  • We know that we can check the Player's sanity because of how it is written in the Engine Scripts page. Because it is called a float, we can use that in the if-conditional to check something, as it "returns" that value. Thus, we could check the Player's health or local variables in a similar manner.
  • In the above examples, the game will check every time you pass through the ScriptArea. You can fix that by changing the false to true in the CollideCallback declaration.

Feel free to ask if you have questions! Smile

Discord: Romulator#0001
[Image: 3f6f01a904.png]
(This post was last modified: 08-05-2017, 03:42 PM by Romulator.)
08-05-2017, 02:44 PM
Find


Messages In This Thread
Sanity Function - by PeterP - 08-05-2017, 01:37 PM
RE: Sanity Function - by Romulator - 08-05-2017, 02:44 PM
RE: Sanity Function - by PeterP - 08-05-2017, 03:38 PM



Users browsing this thread: 1 Guest(s)