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


Thread Rating:
  • 25 Vote(s) - 4.44 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Help Us To Improve the Wiki!
JenniferOrange Offline
Senior Member

Posts: 424
Threads: 43
Joined: Jun 2011
Reputation: 33
#61
RE: Help Us To Improve the Wiki!

Thank you Tanshaydar, it worked with Firefox, so I created one! Smile

Ba-da bing, ba-da boom.
07-21-2011, 07:55 PM
Find
plutomaniac Offline
Super Moderator

Posts: 6,368
Threads: 45
Joined: May 2011
Reputation: 183
#62
RE: Help Us To Improve the Wiki!

Thank you Jennifer for your contribution. Great work! Smile
07-21-2011, 08:23 PM
Find
Tanshaydar Offline
From Beyond

Posts: 3,085
Threads: 17
Joined: Mar 2009
Reputation: 67
#63
RE: Help Us To Improve the Wiki!

I'm glad it worked.
Thanks for the contribution.

07-22-2011, 03:04 AM
Website Find
Rel Offline
Junior Member

Posts: 21
Threads: 5
Joined: Jul 2011
Reputation: 0
#64
RE: Help Us To Improve the Wiki!

can anyone help me, whats a good site to host images that wont ever get deleted so i can finish my wiki page, i got all i need to finish, just to upload pics
07-22-2011, 04:15 AM
Find
Tanshaydar Offline
From Beyond

Posts: 3,085
Threads: 17
Joined: Mar 2009
Reputation: 67
#65
RE: Help Us To Improve the Wiki!

flickr.com ? I use there.

07-22-2011, 04:34 AM
Website Find
Apjjm Offline
Is easy to say

Posts: 496
Threads: 18
Joined: Apr 2011
Reputation: 52
#66
RE: Help Us To Improve the Wiki!

I was thinking about whether or not it would be worth adding a new category under HPL2 called "resources" - under which we could have a sub-categories, such as scripting resources for libraries of self contained code: e.g. data structure implementation, parsing routines & math function implementations.
08-16-2011, 08:12 PM
Find
Tanshaydar Offline
From Beyond

Posts: 3,085
Threads: 17
Joined: Mar 2009
Reputation: 67
#67
RE: Help Us To Improve the Wiki!

It would be in my humble opinion.
Though, I'm wondering if people checks wiki first as I still see same topics opening over and over.

08-16-2011, 08:23 PM
Website Find
Your Computer Offline
SCAN ME!

Posts: 3,456
Threads: 32
Joined: Jul 2011
Reputation: 235
#68
RE: Help Us To Improve the Wiki!

(08-16-2011, 08:23 PM)Tanshaydar Wrote: Though, I'm wondering if people checks wiki first as I still see same topics opening over and over.
One could argue laziness, but i don't think it's necessarily laziness on their part. If it weren't for this topic, where else could you access or know about the wiki? Other people's signatures? That may be wishful thinking. The wiki needs a place in the header of the Frictional Games website (which would include the forums).

Tutorials: From Noob to Pro
08-17-2011, 01:25 AM
Website Find
Apjjm Offline
Is easy to say

Posts: 496
Threads: 18
Joined: Apr 2011
Reputation: 52
#69
RE: Help Us To Improve the Wiki!

Just wrote up two potential things for the resources part. Note that both of these were formated using the folding regions in the updated notepad++ files i posted.
Spoiler below!

String lists (and hence int and float by reference to localVars) using a delimited string to prevent leaking vars. It might be worth using the wiki page which would contain the implementation to document the functions instead of the code file, because the documentation takes up a massive amount of space and is the main reason i'm using folding regions.
//Begin String List
/* String List Implementation V1.0 *\
\* Written by: Apjjm               */

//+ Constants
//Change the delimiter to suit, it is currently the null character.
const string _STRLPFX = "_!strli!_"; //Prefixed to all stringList var names
const string _STRLDLM = "\0";    //SINGLE CHARACTER Delimiter for items
//-

//Begin List Management
//+ bool stringListCreate(string &in asName)
////////////////////////////////////////////////////////////////
//stringListCreate:                                           //
//      initiates a list with the given name                  //
//asName:                                                     //
//      name for the list                                     //
//returns:                                                    //
//      if the creation was sucessful (fails if list exists)  //
////////////////////////////////////////////////////////////////
bool stringListCreate(string &in asName) {
  string name = _STRLPFX + asName;
  //If Exists alread, don't overwrite
  if(GetLocalVarInt(name + "_exist")==1) return false;
  //Else continue as normal
  SetLocalVarInt(name + "_exist",1); //State list exists
  SetLocalVarInt(name + "_count",0);  //Put a count on the list
  SetLocalVarString(name,"");         //Define list w/ empty string
  return true;
}
//-
//+ bool stringListDestroy(string &in asName)
////////////////////////////////////////////////////////////////
//stringListDestroy:                                          //
//      Clears & destroys a list with the given name          //
//asName:                                                     //
//      name of the list                                      //
//returns:                                                    //
//      destruction was sucessful? (false if invalid list)    //
////////////////////////////////////////////////////////////////
bool stringListDestroy(string &in asName) {
  string name = _STRLPFX + asName;
  //If it doesn't exist - we can't destroy it
  if(GetLocalVarInt(name + "_exist")!=1) return false;
  //Else reduce all vars to min size - mark as not existing
  SetLocalVarInt(name + "_exist",0);  //State list doesn't exist
  SetLocalVarInt(name + "_count",0);  //Change the list count
  SetLocalVarString(name,"");         //Define list w/ empty string
  return true;
}  
//-
//+ bool stringListExists(string &in asName)
////////////////////////////////////////////////////////////////
//stringListExists:                                           //
//      Determines if list with a given name exists           //
//asName:                                                     //
//      name of the list                                      //
//returns:                                                    //
//      if the list exists                                    //
////////////////////////////////////////////////////////////////
bool stringListExists(string &in asName) {
  return (GetLocalVarInt(_STRLPFX + asName + "_exist") == 1);
}
//-
//+ int stringListSize(string &in asName)
////////////////////////////////////////////////////////////////
//stringListSize:                                             //
//      returns the size of a list                            //
//asName:                                                     //
//      name of the list                                      //
//returns:                                                    //
//      list size (0 if empty or non-existant)                //
////////////////////////////////////////////////////////////////
int stringListSize(string &in asName) {
  return (GetLocalVarInt(_STRLPFX + asName + "_count"));
}
//-
//+ void stringListClear(string &in asName)
////////////////////////////////////////////////////////////////
//stringListClear:                                            //
//      initiates a list with the given name                  //
//asName:                                                     //
//      name of the list                                      //
////////////////////////////////////////////////////////////////
void stringListClear(string &in asName) {
  string name = _STRLPFX + asName;
  //Don't do anything if list doesn't exist
  if(GetLocalVarInt(name + "_exist")!=1) return;
  //Else reset list to defaults
  SetLocalVarInt(name + "_count",0);  //Put a count on the list to 0
  SetLocalVarString(name,"");         //Define list w/ empty string
}
//-
//End List Management

//Begin Item Management
//+ string[] stringListItems(string &in asName)
////////////////////////////////////////////////////////////////
//stringListItems                                             //
//                                                            //
//asName:                                                     //
//      name of the list                                      //
//returns:                                                    //
//      Array of all the items in the list                    //
////////////////////////////////////////////////////////////////
string[] stringListItems(string &in asName) {
  string str = GetLocalVarString(_STRLPFX + asName);
  //Output array vars
  string[] output = {};
  int outputIndex = 0;
  //Early-out if string is faulty
  if(!StringContains(str,_STRLDLM)) return output;
  //String matching vars
  uint8 dlm = _STRLDLM[0];
  int last = 0;
  //Loop and add each substring
  for(int i =0; i<str.length(); i++) //For each char
   {
    if(str[i] == dlm) //If char matches delimiter
     {      
      int len = i - last; //Determine length of token to read
      if(len >= 0)
       {
        output.resize(outputIndex+1); //Increase array size
        output[outputIndex] = StringSub(str,last,len); //Get token into array
        outputIndex++; //Location of next token
       }
      last = i+1; //Say token begins at the next char
     }    
   }
  //Return array of substrings
  return output;
}
//-
//+ int stringListAddItem(string &in asName, string &in asItem)
////////////////////////////////////////////////////////////////
//stringListAddItem                                           //
//      Adds specified item to the list                       //
//asName:                                                     //
//      name of the list                                      //
//asItem:                                                     //
//      Item to be added                                      //
//returns:                                                    //
//      Index of the item added (-1 if adding failed)         //
////////////////////////////////////////////////////////////////
int stringListAddItem(string &in asName, string &in asItem) {
  string name = _STRLPFX + asName;
  //Return error value if list doesn't exist
  if(GetLocalVarInt(name + "_exist")!=1) return -1;
  //Add the item with the delimiter, increment count
  int index = GetLocalVarInt(name + "_count");
  AddLocalVarInt(name + "_count",1);
  AddLocalVarString(name,asItem + _STRLDLM);
  return index;
}
//-
//+ void stringListAddItems(string &in asName, string[] asItem)
////////////////////////////////////////////////////////////////
//stringListAddItems                                          //
//      Adds an array of items to the list                    //
//asName:                                                     //
//      name of the list                                      //
//asItem:                                                     //
//      Array of Items to be added                            //
////////////////////////////////////////////////////////////////
void stringListAddItems(string &in asName, string[] asItem) {
  //Doesnt exist / Bad parameter? return.
  string name = _STRLPFX + asName;
  if(GetLocalVarInt(name + "_exist")!=1  || asItem.length()==0) return;
  //Append all items together w/ the delimiter
  string item = "";
  for(int i =0; i<asItem.length(); i++) item += asItem[i] + _STRLDLM;
  //Add this new item string, Increment count
  AddLocalVarString(name,item);
  AddLocalVarInt(name + "_count",asItem.length());
}
//-
//+ string stringListGetItem(string &in asName, int alIndex)
////////////////////////////////////////////////////////////////
//stringListGetItem                                           //
//      Gets item from the list at the specified index        //
//asName:                                                     //
//      name of the list                                      //
//alIndex:                                                    //
//      Index of  the item to retrieve                        //
//returns:                                                    //
//      Item at specified index                               //
////////////////////////////////////////////////////////////////
string stringListGetItem(string &in asName, int alIndex) {
  //This is just an array fetch + grab at index
  string name = _STRLPFX + asName;
  string output = "";
  if(alIndex >= 0 && GetLocalVarInt(name + "_exist") == 1) //Parameters valid enough to progress?
   {
    string[] names = stringListItems(asName); //Get list of items
    if(alIndex < names.length())
     {
      output = names[alIndex]; //Index in bounds: set ouput to item
     }
   }
  return output;
}
//-
//+ int stringListGetLastIndexof(string &in asName, string &in asItem)
////////////////////////////////////////////////////////////////
//stringListLastIndexof                                       //
//      Finds the last index of the specified item in the list//
//asName:                                                     //
//      name of the list                                      //
//asItem:                                                     //
//      Item to be found                                      //
//returns:                                                    //
//      Index of last occurance of asItem in list (-1 if none)//
////////////////////////////////////////////////////////////////
int stringListGetLastIndexof(string &in asName, string &in asItem) {
  //This is a linear search of the list of items
  string name = _STRLPFX + asName;
  int index = -1;
  if(GetLocalVarInt(name + "_exist") == 1)
   {
    string[] items = stringListItems(asName); //Get list of items
    for(int i=0; i<items.length(); i++)
     { if(asItem == items[i]) index = i; } //Search for match. If match set index to index of match.
   }
  return index;
}
//-
//+ int stringListGetFirstIndexof(string &in asName, string &in asItem)
////////////////////////////////////////////////////////////////
//stringListGetFirstIndexof                                   //
//      gets the first index of asItem in the target list     //
//asName:                                                     //
//      name of the list                                      //
//asItem:                                                     //
//      Item to be located                                    //
//returns:                                                    //
//      Index of first occurance of asItem in list(-1 if none)//
////////////////////////////////////////////////////////////////
int stringListGetFirstIndexof(string &in asName, string &in asItem) {
  //This is a linear search of the list of items
  string name = _STRLPFX + asName;
  int index = -1;
  if(GetLocalVarInt(name + "_exist") == 1)
   {
    string[] items = stringListItems(asName); //Get list of items
    for(int i=0; i<items.length(); i++)
     {
      if(asItem == items[i])
        {
         index = i;
         i = items.length();
        }
     }
   }
  return index;
}
//-
//+ bool stringListContains(string &in asName, string &in asItem)
////////////////////////////////////////////////////////////////
//stringListContains                                          //
//      Gets if the list contains asItem                      //
//asName:                                                     //
//      name of the list                                      //
//asItem:                                                     //
//      Item to be found                                      //
//returns:                                                    //
//      If asItem is in the list                              //
////////////////////////////////////////////////////////////////
bool stringListContains(string &in asName, string &in asItem) {
  return stringListGetLastIndexof(asName, asItem)>=0;
}
//-
//+ bool stringListRemoveItemAt(string &in asName, int alIndex)
////////////////////////////////////////////////////////////////
//stringListRemoveItemAt                                      //
//      Removes item at specified index                       //
//asName:                                                     //
//      name of the list                                      //
//alIndex:                                                    //
//      Index to be removed                                   //
//returns:                                                    //
//      True if the item was found and removed                //
////////////////////////////////////////////////////////////////
bool stringListRemoveItemAt(string &in asName, int alIndex) {
    string name = _STRLPFX + asName;
    //List exists?
    if(GetLocalVarInt(name + "_exist")!=1) return false;
    //Get list
    string[] list = stringListItems(asName);
    //Re-add all but deleted item
    string item = "";
    int count = 0;
    bool op = false;
    for(int i =0; i<list.length(); i++)
    {
     if(i != alIndex)
      {
       item += list[i] + _STRLDLM;
       count++;
      }
     else op=true;
    }
    //Set back to the array
    SetLocalVarInt(name + "_count",count);  //Change count
    SetLocalVarString(name,item);           //Redefine list      
    //Return if anything was deleted
    return op;
}
//-
//+ int stringListRemoveItems(string &in asName, string asItem)
////////////////////////////////////////////////////////////////
//stringListRemoveItems                                       //
//      Removes any items matching asItem                     //
//asName:                                                     //
//      name of the list                                      //
//asItem:                                                     //
//      Item to be removed (duplicate items are removed too)  //
//returns:                                                    //
//      Number of occurances of the item removed              //
////////////////////////////////////////////////////////////////
int stringListRemoveItems(string &in asName, string asItem) {
    string name = _STRLPFX + asName;
    //List exists?
    if(GetLocalVarInt(name + "_exist")!=1) return 0;
    //Get list
    string[] list = stringListItems(asName);
    //Re-add all but deleted items
    string item = "";
    int count = 0;
    int delamt = 0;
    for(int i =0; i<list.length(); i++)
    {
     if(asItem != list[i])
      {
       item += list[i] + _STRLDLM;
       count++;
      }
     else delamt++;
    }
    //Set back to the array
    SetLocalVarInt(name + "_count",count);  //Change count
    SetLocalVarString(name,item);           //Redefine list      
    //Return if anything was deleted
    return delamt;
}
//-
//End Item Management

//Begin List Debug
//Draws each item in list specified by asName
void stringListDraw(string &in asName) {
    string[] sli = stringListItems(asName); string o = "";
    for(int i =0; i<sli.length(); i++) o += " | " + i + ": " + sli[i] + " |";
    AddDebugMessage(o,false);
}
//Draws the string of the specified list straight to the screen
//Warning: Will not display correctly - if delimiter isn't defined in the font file!
void stringListDrawRaw(string & in asName) {
  AddDebugMessage(GetLocalVarString(_STRLPFX + asName),false);
}
//End
//End String List

Full set of Parsing functions (Float array, Int array, and UINT), with support for exponents, decimals and signs.
//Begin String Parsing
/* String Parsing functions   V2.0 *\
\* Written by: Apjjm               */
//+ Private Parsing functions
int  _ParseDigit(uint8 digit) {
    int d = digit-48; //48 is ASCII code for 0
    return ((d >= 0)&&(d<=9)) ? d : -1; }
bool _ParseExp(uint8 digit) {
    return (digit == 69) || (digit == 101); //ASCII for e or E
}
bool _ParseSign(uint8 digit) {
    return (digit == 45);  // -sign
}
bool _ParsePoint(uint8 digit) {
    return (digit == 46);
}
bool _ParseExpSpace(uint8 digit) {
    return (digit == 43)||(digit == 32);
}
float _ParseMakeFloat(int n1, int n2, int n3, bool hasD, bool hasE, bool signE, bool signN, int leading) {
  float output = n1;
     if(hasD) {
    int ln=(""+n2).length() + leading; float temp=n2;
    for(int i=0; i<ln; i++) temp /= 10;
    output += signN?-temp:temp;
   } if(hasE) {
    for(int i =0; i<n3; i++)
     output = signE?(output/10):(output*10);
   } return output;
}
int _ParseMakeInt(int n1, int n3, bool hasE, bool signE) {
  int output = n1;
  if(hasE) {
   for(int i =0; i<n3; i++)
     output = signE?(output/10):(output*10);
           } return output;
}
//-

//Parses a given string to an array of floats
float[] parseStringToFloatArray(string &in asString) {
  float[] output={}; int state = 0;
  bool finalise = false; //Need to store number in array?
  bool reading = false; //In the process of reading a number?
  bool numsign = false; //Whether or not number is signed
  bool expsign = false; // " " " " " " " exponent is signed
  bool hasexp = false; //Has an exponent?
  bool hasdec = false; //Has points?
  int numbers = 0; //Temp store for numbers
  int points =0;   //Temp store for decimals
  int expons =0;   //Temp store for exponent
  int leading =0; //Temp for leading 0s on decimals
  for(int i=0; i<asString.length(); i++) { uint8 chr = asString[i];
    int d = _ParseDigit(chr);
    switch(state) {
     case 0:  {  //Looking for: - or digit
        if(d>=0 && d<=9) {
          numbers=numsign?-d:d;
          reading = true; //State we are reading a number
          state = 1;  //Number has begun, jump to number reading stage
         } else if(_ParseSign(chr)) {
          numsign=true; //Read a minus sign. Mark number as possibly signed?
         } else {
          numsign=false; //Didn't read a sign - reset sign state.
         } break;
       }
     case 1:  {  //Read digits until a "." or exponent is found
        if(d>=0 && d<=9) {
          numbers=(numbers * 10) + d; //Add each digit
         } else if(_ParsePoint(chr)) {
          state = 2; //Read a decimal point - jump to decimal reading state
         } else if(_ParseExp(chr)) {
          state = 3; //Read an exponent marker - jump to exponent reading state
         } else { //Nothing matches. Finish.
          reading = false; finalise = true;
         } break;
       }
     case 2:  {  //Read digits until an exponent is found
        if(d>=0 && d<=9) {
          if(d == 0 && points == 0) leading++;
          points = (points * 10) + d;
          hasdec=true;
         } else if(_ParseExp(chr)) {
          state = 3;
         } else { //Nothing matches. Finish.
          reading = false; finalise = true;
         } break;
       }
     case 3:  {  //Looking for: - + or whitespace signs or a digit
        if(d>=0 && d<=9) {
          expons=d; hasexp=true; state =4;
         } else if(_ParseSign(chr)) {
          expsign=true;
         } else if(_ParseExpSpace(chr)) {
          expsign=false;
         } else {
          expsign=false; reading = false; finalise = true;
         } break;
       }
     case 4:  {  //Reading digits for exponent
        if(d>=0 && d<=9) {
          expons = (expons * 10) + d; hasexp=true;
         } else {
          reading = false; finalise = true;
         } break;
       }
                  }
    if(finalise) {
      int index = output.length(); output.resize(index+1); //Resize array, store target index
      output[index] = _ParseMakeFloat(numbers, points, expons, hasdec, hasexp, expsign, numsign, leading); //Store number
      numbers = 0; points = 0; expons = 0; state = 0; leading=0; //Reset vars
      finalise = false; reading = false; hasexp=false; expsign=false; numsign = false; hasdec=false;
                 }
   }
   if(reading) {
     int index = output.length(); output.resize(index+1);
     output[index] = _ParseMakeFloat(numbers, points, expons, hasdec, hasexp, expsign, numsign, leading);
               }
  return output;    
}

//Parses a given string to an array of ints
int[] parseStringToIntArray(string &in asString) {
  int[] output={}; int state = 0;
  bool finalise = false; //Need to store number in array?
  bool reading = false; //In the process of reading a number?
  bool numsign = false; //Whether or not number is signed
  bool expsign = false; // " " " " " " " exponent is signed
  bool hasexp = false; //Has an exponent?
  int numbers = 0; //Temp store for numbers
  int expons =0;   //Temp store for exponent
  for(int i=0; i<asString.length(); i++) { uint8 chr = asString[i];
    int d = _ParseDigit(chr);
    switch(state) {
     case 0:  {  //Looking for: - or digit
        if(d>=0 && d<=9) {
          numbers=numsign?-d:d;
          reading = true; //State we are reading a number
          state = 1;  //Number has begun, jump to number reading stage
         } else if(_ParseSign(chr)) {
          numsign=true; //Read a minus sign. Mark number as possibly signed?
         } else  {
          numsign=false; //Didn't read a sign - reset sign state.
         } break;
       }
     case 1:  {  //Read digits until exponent is found
        if(d>=0 && d<=9) {
          numbers=(numbers * 10) + d; //Add each digit
         } else if(_ParseExp(chr)) {
          state = 3; //Read an exponent marker - jump to exponent reading state
         } else { //Nothing matches. Finish.
          reading = false;
          finalise = true;
         } break;
       }
     case 3:  {  //Looking for: - + or whitespace signs or a digit
        if(d>=0 && d<=9) {
          expons=d; hasexp=true; state =4;
         } else if(_ParseSign(chr)) {
          expsign=true;
         } else if(_ParseExpSpace(chr)) {
         expsign=false;
         } else {
          expsign=false; reading = false; finalise = true;
         } break;
       }
     case 4:  {  //Reading digits for exponent
        if(d>=0 && d<=9)
         {
          expons = (expons * 10) + d; hasexp=true;
         } else {
          reading = false; finalise = true;
         }
       }
                  }
    if(finalise) {
      int index = output.length(); output.resize(index+1);
      output[index] = _ParseMakeInt(numbers, expons, hasexp, expsign);
      numbers = 0; expons = 0; state = 0; finalise = false; reading = false;
      hasexp=false; expsign=false; numsign = false;
                 }
   }
   if(reading) {
     int index = output.length(); output.resize(index+1);
     output[index] = _ParseMakeInt(numbers, expons, hasexp, expsign);
               }
  return output;    
}

//Parses all the digits out of a given string, ignorning sign
uint parseStringUInt(string &in asString) {
    uint output = 0;
    for(uint i=0; i<asString.length(); i++) {
      int digit = _ParseDigit(asString[i]);
      output = (digit > -1)?(10*output+digit):(output); }
    return output;
}
//End

Need more than two potential items before making a new catagory really though.
(This post was last modified: 08-17-2011, 02:29 AM by Apjjm.)
08-17-2011, 02:01 AM
Find
JenniferOrange Offline
Senior Member

Posts: 424
Threads: 43
Joined: Jun 2011
Reputation: 33
#70
RE: Help Us To Improve the Wiki!

Tanshaydar, do you think it could be an idea if I made a whole subcategory on scares? I've seen people ask how to do them.. do you think it's a good idea?

Ba-da bing, ba-da boom.
(This post was last modified: 08-17-2011, 02:05 AM by JenniferOrange.)
08-17-2011, 02:05 AM
Find




Users browsing this thread: 11 Guest(s)