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
#7
RE: Script Language Reference and Guide

Thanks for the response, that all seems very reasonable. For the references, I've only ever used pointers in C, and that uses a different notation altogether (type*) so that makes sense from your context.

I'm be happy to share my code if it'll be useful, it's pretty specific to a particular mechanic for Spacies but maybe theres some transferable stuff in there

Wrote this back in November, we needed a function that would return an integer that could be appended onto a string used for picking entities and script areas, and we also needed somewhere to store the locations that had been used already. So, I'm using a global string to store the numbers (array's don't get saved when the player quits the game, so had to be one of the function defined variables, string made the most sense), the function would need to return the modified global string as well as take it in to be read through, in order to get the next location

int GetSetNextSpawnSequential(string &inout strInput)
{
    int inNextPlayerPos; // return val
    int inAscii; // int holder for ascii nums
    bool blZeroFound = false; // defensive
    
    blZeroFound = ValidateStringForInput(strInput);
    
    if (blZeroFound)
    {
        for (int c = 0; c < strInput.length(); c++)
        {
            inAscii = strInput[c] - 48;
            if (inAscii == 0)
            {
                inNextPlayerPos = (strInput[c-1] - 48) + 1;
                strInput = GetNewSpawnString(strInput, inNextPlayerPos);
                return(inNextPlayerPos);
            }
        }
    }
    return(0);
}

There are a couple of other custom functions in there which carry out specific tasks, ValidateStringForInput is pretty self explanatory - checks whether there is any space left to use or whether all the locations had been used already, and GetNewSpawnString does the actual modifying of the string

If you have any suggestions I'd love to here them, I've yet to have anyone more experienced than myself check over it


"American English vs British English - a matter of preference"
Of course you mean American English vs English, one of which clearly came first, and the other of which is clearly an unnecessary attempt by colonial powers to seperate themselves from their Glorious Leaders
/imperialism Tongue
Ok I'll stop...

01-15-2013, 11:29 AM
Find


Messages In This Thread
RE: Script Language Reference and Guide - by Adrianis - 01-15-2013, 11:29 AM



Users browsing this thread: 1 Guest(s)