Facebook Twitter YouTube Frictional Games | Forum | Newsletter | Dev Blog | Dev Wiki | Support


Post Reply 
 
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Possible to have a universal script for a custom story?
Author Message
Shev Offline
Member

Posts: 238
Joined: Dec 2010
Reputation: 0
Post: #1
Possible to have a universal script for a custom story?

As in a script thats always running for every level or something.

I was looking at how the scripts for levels work now, and it seems like they're only running when they're in the area so I'm basically asking is there a way to get a script thats always running in the background of the custom story?

i spam meme 4 raeg
(This post was last modified: 01-18-2011 05:00 AM by Shev.)
01-18-2011 04:59 AM
Find all posts by this user Quote this message in a reply
Nye Offline
Member

Posts: 249
Joined: Jan 2011
Reputation: 2
Post: #2
RE: Possible to have a universal script for a custom story?

Sort of. You have to use global settings. You can't be running two scripts parralel to each other. However, you can set a global variable. Look at how the game devs did it. In the folder /maps/ of your custom story (or /maps/main/) in the real game, you should see/create a file called global.hps, you can save global variables here.

For example, when you leave an area, set a global variable named "area1left" to "1". Then, on returning to the area, ensure you have an if statement asking whether "area1left" is set to 1. If it's set to 1, the game shakes and the guardian spawns lots of slime everywhere and its all scary. Else, nothing happens, as it is the first time entering the area.

The syntax to use to set a global variable is:
void SetGlobalVarInt(string& asName, int alVal);

Where "string&asName" <---- is a name you choose for your global variable.
and int alVal <----- is the state you choose. In my example, it would be set to 1.

You can also do something similar for "localvariables", which are specific to just the local map.
(This post was last modified: 01-18-2011 11:36 AM by Nye.)
01-18-2011 11:14 AM
Find all posts by this user Quote this message in a reply
Shev Offline
Member

Posts: 238
Joined: Dec 2010
Reputation: 0
Post: #3
RE: Possible to have a universal script for a custom story?

(01-18-2011 11:14 AM)Nye Wrote:  Sort of. You have to use global settings. You can't be running two scripts parralel to each other. However, you can set a global variable. Look at how the game devs did it. In the folder /maps/ of your custom story (or /maps/main/) in the real game, you should see/create a file called global.hps, you can save global variables here.

For example, when you leave an area, set a global variable named "area1left" to "1". Then, on returning to the area, ensure you have an if statement asking whether "area1left" is set to 1. If it's set to 1, the game shakes and the guardian spawns lots of slime everywhere and its all scary. Else, nothing happens, as it is the first time entering the area.

The syntax to use to set a global variable is:
void SetGlobalVarInt(string& asName, int alVal);

Where "string&asName" <---- is a name you choose for your global variable.
and int alVal <----- is the state you choose. In my example, it would be set to 1.

You can also do something similar for "localvariables", which are specific to just the local map.

Alright, thanks a lot.

i spam meme 4 raeg
01-18-2011 03:06 PM
Find all posts by this user Quote this message in a reply
Rurikkur Offline
Junior Member

Posts: 26
Joined: Dec 2010
Reputation: 0
Post: #4
RE: Possible to have a universal script for a custom story?

Cool Big Grin That'll be really usefull Big Grin
01-18-2011 08:59 PM
Find all posts by this user Quote this message in a reply
Post Reply 




User(s) browsing this thread: 1 Guest(s)