I decided to make a simple little scripting engine in c, and i''ve run into a little problem. i havent started to program it yet, because i want to make sure i know what i''m doing first
![](smile.gif)
...
anyway, so far (although its only on paper) it has the capability to read in a command from a ''script'' file, and put it (and it''s paremeters) into a string variable. Now i want it to figure out which command i want to run, and run it using it''s paremeters... i looked through a book of mine, and the command i thought might work the best is sscanf. my question is, will this work:
if (sscanf(command_to_run,"move %s %i %i",playername,xmove,ymove)){
move(playername,xmove,ymove);
}
//just for fun, another one... (hey that rhymes)
if (sscanf(command_to_run,"load_map %s",loadthismap)){
loadmap(loadthismap);
}
|
assuming
command_to_run = "move player1 3 4", i guess this example would move the player named ''player1'' 3 to the right and 4 to the left. It doesnt matter though, i just want to know if this will work,or theres an easier way...