Advertisement Jump to content


This topic is now archived and is closed to further replies.



This topic is 6514 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

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

//just for fun, another one... (hey that rhymes)

if (sscanf(command_to_run,"load_map %s",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...

Share this post

Link to post
Share on other sites
You should do it like this (if I understand what you want):
/* Declare you variables here */
/* Get stuff in command_to_run now... */
char command_value[50];

if(strcmp(command_value,"move") {
/* %*s means discard the first string */
} else if(strcmp(command_value,"load_map") {
} else {
/* ... */


"Finger to spiritual emptiness underlying everything." -- How a C manual referred to a "pointer to void." --Things People Said
Resist Windows XP''s Invasive Production Activation Technology!

Share this post

Link to post
Share on other sites

  • Advertisement

Important Information

By using, you agree to our community Guidelines, Terms of Use, and Privacy Policy. is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!