The following warnings occurred:
Warning [2] count(): Parameter must be an array or an object that implements Countable - Line: 906 - File: showthread.php PHP 7.2.24-0ubuntu0.18.04.17 (Linux)
File Line Function
/showthread.php 906 errorHandler->error



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


Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Custom function freezes the game.
Fearlessagent Offline
Junior Member

Posts: 12
Threads: 2
Joined: Jul 2012
Reputation: 1
#1
Custom function freezes the game.

So, in the custom story that I'm creating, I name things I need to interact with in the code quite precisely. Usually it takes the form of: ROOMNAME_ITEMNAME_TYPE

So for example, a note might be labled: lab_chemDiscovery_note

I wanted an easy function to extract the middle word, in the above case this would be "chemDiscovery". However, whenever the function is called, the game just locks up. Can anyone see what I might be doing wrong?

PHP Code: (Select All)
string getProperName(string &in var){
    
int chr 0;             //character number in string
    
string newString "";   //where the new string will be stored
    
string letter "";      //where the current letter being tested is stored
    
int l 0;               //how many underscores we've found
    
while(2){ //we can stop evaluating after finding 2 underscores
        //using StringSub(string,int,int) to return a partial string between two positions in the string.
        
letter StringSub(var, chrchr+1);
        
AddDebugMessage("Analyzing Letter: " letter,false);
        
//Only append a letter to the new string if its not an underscore and we've already found an underscore.
        
if ((letter != "_") && (== 1)){newString newString letter;}
        
//increase underscore count when finding one
        
else if (letter == "_"){l++;}
        
//increase character count 
        
chr++;
        
AddDebugMessage("New String: " newString,false);
    }
    return 
newString;


I'm thinking I should be able to call this function as:
PHP Code: (Select All)
getProperName("lab_chemDiscovery_note"); 
or even through passing a callback variable to it (the intention).
(This post was last modified: 07-07-2012, 08:29 AM by Fearlessagent.)
07-07-2012, 04:59 AM
Find


Messages In This Thread
Custom function freezes the game. - by Fearlessagent - 07-07-2012, 04:59 AM



Users browsing this thread: 1 Guest(s)