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
TheGreatCthulhu Offline
Member

Posts: 213
Threads: 10
Joined: Oct 2010
Reputation: 32
#8
RE: Script Language Reference and Guide

Using a string as an array - nice! If I got it right it essentially searches for a "0" character, and then takes the value stored in the one before it, and than (I'm guessing now) replaces it with a "0" when it's done, while filling the string with something non-"0" from the right, right?

But, what happens when there's a "0" as the first character? Are some checks made, or does it just go: (strInput[0-1] - 48)?
Out of bounds access like that can stop the entire script from executing, maybe even crash the game.

Anyway, I do have 2 suggestions:
  1. If GetNewSpawnString() is made to take a string& (inout), then it doesn't have to return the string (although it can, for convenience), you can just set it via the reference param, just like GetSetNextSpawnSequential() does. Along the lines of
    PHP Code: (Select All)
    void A(strings) { B(s); }   // corresponds to GetSetNextSpawnSequential()
    void B(strings) { NewString(); }   // corr. to GetNewSpawnString() 
  2. You could also avoid all the string-gymnastics if you simply store the index of the current character as a (game-)global variable. Then you just get the index global var, test against the string's length, and get the char, incrementing the index afterwards. (Or, if you're going backwards, start at length() - 1, test if its >0, decrement). This would eliminate the need for having special tokens like "0" in your string.
(This post was last modified: 01-15-2013, 03:17 PM by TheGreatCthulhu.)
01-15-2013, 03:11 PM
Find


Messages In This Thread
RE: Script Language Reference and Guide - by TheGreatCthulhu - 01-15-2013, 03:11 PM



Users browsing this thread: 1 Guest(s)