Jump to content
  • Advertisement
Sign in to follow this  
THACO

Scripting

This topic is 4910 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

Ok, I decided I need scripting support, something somewhat simple. My game is like a 2d side scroller. Most characters have the same basic attacks, some sorta of attack forward, up down, etc. The trick comes in their special moves usually 3 each. I want to be able to script them and not hard code them for each character. I have never really done much in scripting before. I figure I would have a text file and just read in and depending on what is at each line take it in. Sample line might be "functionA 5 .25 " this would mean call functionA with parameters of 5 and .25. Its not groundbreaking, I assume it should work for how I need it. Should I also try to expand it for AI needs, and be able to create the script on the fly? I am just trying to think a head because I want this to be easy to modify, because I have around 8 characters and dont't want to hardcode and shouldn't hardcode each characters special powers -THACO

Share this post


Link to post
Share on other sites
Advertisement
I would recommend going with an existing scripting system like Python or Lua instead of trying to roll your own. Especially if you don't have much experience with scripting.

Share this post


Link to post
Share on other sites
That seems to way over the top maybe? For AI I can see the need. For now I just need some way to create and use special moves without hard coding them. By creating a few built in functions then using a file to say which ones are called and in what order to actually complete the move. Learning Lua and interface with C++ seems like it would just be so much extra. I will do some more looking into it. You are a mod for a reason, and I do not know much about scripting especially when it comes to how it should work with games.

-THACO

Share this post


Link to post
Share on other sites
If you use something like LuaBind or ToLua++, the amount of work involved in binding is really rather low. More importantly, you will spend much, much less time going back and adding functionality to your scripting layer.

Share this post


Link to post
Share on other sites
I'll third the suggestion for using an existing implemention such as Lua. It would be over the top to waste a whole bunch of time writing your own lexer, parser, etc... when such things have already been written (and debugged, and thoroughly tested) for you. It's better to go with something that is already done and that has too much power for your (predicted) needs, than to roll your own that is buggy, slow, takes years to develop, and ends up being too limited for something you want to do later on down the road. This is coming from somebody who made the same mistake several years ago, before switching to Lua. [grin]

Share this post


Link to post
Share on other sites
well it seems the mods have it, so ill go in that direction, thanks for all the advice

-THACO

Share this post


Link to post
Share on other sites
If you don't want to use an existing, full-blown scripting language and you don't want to write your own lexer\parser from scratch, you might want to look into YACC and Lex. I'm fairly sure there are Windows ports available.

Share this post


Link to post
Share on other sites
Yacc and lex are far from intuitive unless you have a decent knowledge of language grammar and compiler design. In effect, it's the same as rolling your own - you're just expressing it in BNF rather than C.

Share this post


Link to post
Share on other sites
If you decide to go the Lua route, here's a tutorial at gamedev called An Introduction to Lua.

You'll also want to look at this thread discussing the article.

Also, if memory serves me right, the article refers to an older version of lua, and some of the functions have changed. For instance, the function lua_open() no longer takes any arguments. I think this is all covered in the discussion thread.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

GameDev.net 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!