this is starting to turn into a lesson, so i'm lets post Q&A on the forum... easier for me to follow... and maybe some others might benefit as well (i see a few downloads)...
you're not gonna understand the code right away... it takes me a lil time to understand other people's code when i look at it... THAT IS WHY WE HAVE COMMENTS...
ok... first look at the Main() section... this is where everything is happens...
as you can see, this part is extremely simple... it just calls GetInput()... this is a function, that is coded below, outside of Main()... so, there's really nothing to do here... lets look below and find GetInput()...
this does everything necessary to get the user input, like the name implies... that's all it does... so you really don't need to do anything here either... but if you look at the nottom of the code, you can see this function calls another function... ValidateCmd()... so, lets look up at that function...
look for a comment where the logic looks to check to see if /loc is entered...
when you find it you see that here is where it sets the cmdID to 1... this is the place where you'd want to add checks for other cmds...
use the say format and add
if(strLeft4=="/res")cmdID=2;
now the logic can check for 2 things...
now, if you continue down, you see the comments for each section of code shows that the code is just checking to see what cmd is being entered... if cmdID==0 then no command has been entered and the code will exit the function here..
if cmdID==1 then the command is Locate, and it will trickle down and execute the rest of the commands...
since you want to add more commands, it is gonna be necessary to group this section of code into its own block... this is done by adding an open bracket at the top (end of the if question) and at the end and indenting everything in between (for readability only)... like below...
if(cmdID==1){
// check for first set of valid X coord numbers
int n;
for(n=6; n< iStringLen(Text);n++){
iStringMid(strTest, Text,n,1);
if(strTest==" ") break;
strX+=strTest;
// debug value printout
iObjectTextSet(OBJ_44,strX + "####");
}
// get ready to check for valid Y coord
strTest="";
strY="";
int lastBreak=n;
// check for 2nd set of valid numbers for Y coord
for(n=lastBreak+1; n< iStringLen(Text);n++){
iStringMid(strTest, Text,n,1);
if(strTest==" ") break;
strY+=strTest;
// debug value printout
iObjectTextSet(OBJ_66,strY + "####");
}
// get ready to check for valid Z coord
strTest="";
strZ="";
lastBreak=n;
// check for 3rd set of valid numbers for Z coord
for(n=lastBreak+1; n< iStringLen(Text);n++){
iStringMid(strTest, Text,n,1);
if(strTest==" ") break;
strZ+=strTest;
// debug value printout
iObjectTextSet(OBJ_88,strZ + "####");
}
if(isDone==false){
iStringLeft(Text,Text,iStringLen(Text)-1);
isDone=true;
// place the object at location
iObjectLocationSet(OBJ_110,Vector3(int(iStringVal(strX)), iStringVal(strY), iStringVal(strZ)));
}
}
this should help you make sense of what's going on, and clue you in to what to do next...
you've added a new command... now, what code do you think you need to add and where do you think you need to add it...
--Mike