Thanks =)
Code:
/* tbh I don't entirely understand what's happening here
with the substr(0,1) thingy. My intentions here are to
create a command line interface to help me edit certain
aspects of the "game" My first project is this SDL tile based
engine, and all I've used is the plain SDL library and have
been able to make map,collision,item,npc saving/loading,
buttons, animations, chat boxes etc. (which I am intending
to use the chatbox as a console during development) this
being my first programming project other than the occasional
bot scripting, my code looks primative, and i know, but it's all i
understand atm. So when I try to figure out how to do something
online, it usually doesn't work out how I expected, and I end up
spending hours trying to figure it out, and when I fail miserably i
post on a forum.
*/
// STR_MESSAGES is the recently typed message into the chatbox
//COM_LINE ="/";
// when I start my sentence with "/" it'll go through this function to // determine what I am telling the program to do.
ANString = STR_MESSAGES[2].substr (0,1);
if (ANString == COM_LINE)
{
int TX_Coord = -1 ;
int TY_Coord = -1 ;
std::stringstream os(STR_MESSAGES[2]); // parses 's'
std::string temporary;
while (os >> temporary) // makes temp a token
std::cout << temporary << endl; //and deletes that token from itself
// this token comment, got it from searching how to do something.
// still dont understand entirely what it means. so i left the // comment.
bool TFSTATE = isInt(temporary);
// determine if the next "word" is just really a number.
// and if it is a number, we are expecting it to be X Y coordinates
// example "/ delete door 25 33"
if ( TFSTATE == true )
{
std::cout << "temp: " << temporary << endl;
if ( TX_Coord == -1) { TX_Coord = atoi (temporary.c_str()); }
// if the X value hasnt changed yet, this is probably what the input meant, so assign it.
else if ( TX_Coord != -1) { TY_Coord = atoi (temporary.c_str()); }
// if it has already changed, assign the next value to Y.
else { MessageBox(NULL,"TX and TY Coord already taken!","Command Line",MB_SETFOREGROUND); }
// if input has more than 2 seperate numbers, was obviously
a user error.
std::cout << "X: " << TX_Coord << "Y: " << TY_Coord << endl;
}
else if ( TFSTATE == false )
{
///////////////////////////////////////////////////////
if (temporary == CREATE) { ACTION = 1; std::cout << "create ";}
else if (temporary == ERASE) { ACTION = 2; std::cout << "erase "; }
else if (temporary == TELEPORT) { ACTION = 3; std::cout << "teleport "; }
///////////////////////////////////////////////////////
if (temporary == NPC) { CLASS = 2; std::cout << "npc "; }
else if (temporary == CONTAINER) { CLASS = 3; std::cout << "container "; }
else if (temporary == DOOR) { CLASS = 4; std::cout << "door "; }
/* this is what I type, and this is what I get.
/ create door 12 34
/ delete npc 54 23
*/
/*
/
create
door
12
34
temp: 34
X: 34 Y: -1
/
delete
npc
54
23
temp: 23
X: 23 Y: -1
*/