Facebook Twitter YouTube Frictional Games | Forum | Privacy Policy | Dev Blog | Dev Wiki | Support | Gametee


Thread Rating:
  • 3 Vote(s) - 5 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Script Language Reference and Guide
Adrianis Offline
Senior Member

Posts: 620
Threads: 6
Joined: Feb 2012
Reputation: 27
#9
RE: Script Language Reference and Guide

Yep, that's about right! Theres a string defined using the SetGlobalVarString in global.hps, thats set up to be, say, "10000". It's a bit of a bodge-job, because it essentially requires that I set up the global strings exactly right - not that it is complicated to set up (make sure it starts with '1', and make sure there are the right number of '0's), but it does require a certain amount of 'compatibility' between the number of positions available, the naming of SA's and entities to be used, and in the case of the GetSetNextSpawnRandom, the arguments given to the RandInt function Smile

So in answer to "what happens when there's a "0" as the first character?", there isn't a 0 as the first character Smile These aren't random or dynamically allocated strings, I had no intention of them being so, they are static and I set them up so the chances of that going wrong are low, added to that the fact that I've plastered warning comments all over the original code file, as well as the global.hps file

Your probably right though, currently the ValidateStringForInput function doesn't check that the first character is not 0 so I will add something in there (seems like the appropriate place for it)

Perhaps I should have qualified with some extra info, but in answer to your suggestions

1 - Thats perfectly valid, but I prefer not to use pointers unless necessary (I know I said they were awesome, and they are, but still..). In your example, both A and B will modify the original variable when they return - in my mind, there should only be 1 point where the modified value should be returned if possible.
Since A would be passed the reference, it then passes the reference to the original to B, when B returns it will modify the original, and when A returns it will also modify the original... For ease of debugging, B returns its own string, which A will use to overwrite the value of the original and return it.
B is written to have no other purpose than modifying the string (moved to a seperate function to prevent A from being too messy), so it doesn't need to have multiple return values.
Your method would certainly be more efficient, not having to pass around variables unnecessarily, but I'm not massively concerned about memory efficiency in these scripts, not unless theres going to be a real problem with it

2 - The problem is that the number of positions is deliberatly limited, e.g. level A has 4 positions, level B has 6, there would need to be an arbitrary limit set somewhere, so I thought it best to simply build it into the 'array' from the start to avoid having too many different required variables in different places if things need changing

An example of its usage would be
void ChangeTheMap(string &in strTimer)
{
            int inNextPos = GetSetNextSpawnSequential(GetGlobalVarString("globalstringname"));
            if (inNextPos == 0) return; // check for returned 0, if so, no places left so exit function
            ChangeMap("mapname.hps", "PlayerStartArea_" + inNextPos, etc...)
}

I was wary at first about using 'GetGlobalVarString()' as an argument, as I'm not sure exactly what it returns, but I tested it (extensively, and hopefully thoroughly) and it does work as intended. If you happen to know of a problem with doing this I would love to know it Tongue

01-15-2013, 05:14 PM
Find


Messages In This Thread
RE: Script Language Reference and Guide - by Adrianis - 01-15-2013, 05:14 PM



Users browsing this thread: 1 Guest(s)