Archived

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

SloppyJoe

Simple Scripting

Recommended Posts

I need help with scripting in C\C++ using fstream classes or FILE structures. I want to create a small and simple scripting engine simpler than the one in Joseph "Ironblayde" Farell''s Game Programming Genesis. Please post some code for loading and translating commands like ShowText and MsgBox. SloppyJoe

Share this post


Link to post
Share on other sites
quote:
Original post by SloppyJoe
Please post some code for loading and translating commands like ShowText and MsgBox.

No.

You can''t make me!

I wont!

Get the picture? You haven''t even tried (or shown us that you''ve tried), so why should we provide you with a full solution? Besides, your question is incomplete. Translate "ShowText" to what? (I''ll assume Win32 API calls) Well, what parameters does ShowText take? Not all of use read tutorials, you know...

Here''s a hint, though: tokenize your input (get a line and break it up into tokens either using the C library strtok() function or using C++ string and its find_*_of() methods), then convert each token to an opcode which you can use as an index in a look up table to the appropriate API call.

Good luck. You''ll need it.




I wanna work for Microsoft!

Share this post


Link to post
Share on other sites
Guest Anonymous Poster
No.

Code, no!

Advice, yes!

1) Decide what you want your scripting engine to do (MsgBox, ShowText, etc).
2) Tokenize your input (from te script file).
3) Go through the tokens, checking for the patterns that will do something ("MsgBox" followed by "(" followed by "''Your Message Here'' followed by ")" ). When you find these, have it do whatever it is supposed to do (create a message box and opo up the message).
4) Unless you can write your scripts without making any errors, add in error checking (if a token does not match any defined patterns it is an error).
5) When you do this and it doesn''t work, ask a specific question on this forum.

Share this post


Link to post
Share on other sites