Frictional Games Forum (read-only)
Help Us To Improve the Wiki! - Printable Version

+- Frictional Games Forum (read-only) (https://www.frictionalgames.com/forum)
+-- Forum: Amnesia: The Dark Descent (https://www.frictionalgames.com/forum/forum-6.html)
+--- Forum: Custom Stories, TCs & Mods - Development (https://www.frictionalgames.com/forum/forum-38.html)
+--- Thread: Help Us To Improve the Wiki! (/thread-8711.html)

Pages: 1 2 3 4 5 6 7 8 9 10 11 12


RE: Help Us To Improve the Wiki! - JenniferOrange - 07-21-2011

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


RE: Help Us To Improve the Wiki! - plutomaniac - 07-21-2011

Thank you Jennifer for your contribution. Great work! Smile


RE: Help Us To Improve the Wiki! - Tanshaydar - 07-22-2011

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


RE: Help Us To Improve the Wiki! - Rel - 07-22-2011

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



RE: Help Us To Improve the Wiki! - Tanshaydar - 07-22-2011

flickr.com ? I use there.


RE: Help Us To Improve the Wiki! - Apjjm - 08-16-2011

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.


RE: Help Us To Improve the Wiki! - Tanshaydar - 08-16-2011

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.


RE: Help Us To Improve the Wiki! - Your Computer - 08-17-2011

(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).


RE: Help Us To Improve the Wiki! - Apjjm - 08-17-2011

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.
Code:
//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.
Code:
//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.


RE: Help Us To Improve the Wiki! - JenniferOrange - 08-17-2011

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?