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
How do "you" organize your .hps files?
Adrianis Offline
Senior Member

Posts: 620
Threads: 6
Joined: Feb 2012
Reputation: 27
#11
RE: How do "you" organize your .hps files?

I do like Chaser & Damascus, try and keep related functions in the same sections. It gives a logical layout of the script in the same way a player would be progressing through a level. A section in my script tends to be around a specific event, room or section of a level, but also in Spacies we use a lot of scripts for custom entity or light actions that are not related to any event or room in particular, so I group those together too, with a title and description for the group

Additionally, since OnStart & OnEnter can get very, very cluttered on large levels I tend to have custom 'setup' functions where I put all of the function calls that normally go into OnStart & OnEnter, then call to those functions from OnStart & OnEnter so it's nice and clean.

lil' snippet here
void OnStart()
{
    AutoDoorSetup();      // AUTO-DOORS
    PowerCableSetup();    // POWER CABLE PUZZLE
    HallwayLightsSetup(); // HALLWAY LIGHTS
}

...


/**************************************************
    HALLWAY LIGHTS
    
    Progressively turn on lights, with flickering
****************************************************/

void HallwayLightsSetup()
    {
        AddEntityCollideCallback("Player", "SA_hallway_lights_2", "Hallway_lights_start", true, 1);
        for (int c=1; c<=12; c++)
        {
            SetLightVisible("spot_hallway_left_"+c, false);
            SetLightVisible("spot_hallway_right_"+c, false);
            SetLightVisible("point_hallway_"+c, false);
        }
        for (int c=1; c<=3; c++) SetLocalVarInt("inHallwayLightsFlicker"+c, 0);
    }

...

This has an additional benefit of meaning that if a setup stage needs to be performed every time you go into the level, instead of having 2 lots of the same code in OnStart & OnEnter, I can simply call to 'EventSetup()' again and have the code only in 1 place if it needs changing

Basic rule is, your going to read your code 100 times more than you're going to write it, and chances are if your going to spend a decent amount of time on your mod your going to have to read code you wrote months ago, so having a logical & consistent layout that you understand is important, regardless of what that layout is

(This post was last modified: 08-08-2013, 12:44 PM by Adrianis.)
08-08-2013, 12:38 PM
Find


Messages In This Thread
RE: How do "you" organize your .hps files? - by Adrianis - 08-08-2013, 12:38 PM



Users browsing this thread: 1 Guest(s)