• Announcements

    • khawk

      Download the Game Design and Indie Game Marketing Freebook   07/19/17

      GameDev.net and CRC Press have teamed up to bring a free ebook of content curated from top titles published by CRC Press. The freebook, Practices of Game Design & Indie Game Marketing, includes chapters from The Art of Game Design: A Book of Lenses, A Practical Guide to Indie Game Marketing, and An Architectural Approach to Level Design. The GameDev.net FreeBook is relevant to game designers, developers, and those interested in learning more about the challenges in game development. We know game development can be a tough discipline and business, so we picked several chapters from CRC Press titles that we thought would be of interest to you, the GameDev.net audience, in your journey to design, develop, and market your next game. The free ebook is available through CRC Press by clicking here. The Curated Books The Art of Game Design: A Book of Lenses, Second Edition, by Jesse Schell Presents 100+ sets of questions, or different lenses, for viewing a game’s design, encompassing diverse fields such as psychology, architecture, music, film, software engineering, theme park design, mathematics, anthropology, and more. Written by one of the world's top game designers, this book describes the deepest and most fundamental principles of game design, demonstrating how tactics used in board, card, and athletic games also work in video games. It provides practical instruction on creating world-class games that will be played again and again. View it here. A Practical Guide to Indie Game Marketing, by Joel Dreskin Marketing is an essential but too frequently overlooked or minimized component of the release plan for indie games. A Practical Guide to Indie Game Marketing provides you with the tools needed to build visibility and sell your indie games. With special focus on those developers with small budgets and limited staff and resources, this book is packed with tangible recommendations and techniques that you can put to use immediately. As a seasoned professional of the indie game arena, author Joel Dreskin gives you insight into practical, real-world experiences of marketing numerous successful games and also provides stories of the failures. View it here. An Architectural Approach to Level Design This is one of the first books to integrate architectural and spatial design theory with the field of level design. The book presents architectural techniques and theories for level designers to use in their own work. It connects architecture and level design in different ways that address the practical elements of how designers construct space and the experiential elements of how and why humans interact with this space. Throughout the text, readers learn skills for spatial layout, evoking emotion through gamespaces, and creating better levels through architectural theory. View it here. Learn more and download the ebook by clicking here. Did you know? GameDev.net and CRC Press also recently teamed up to bring GDNet+ Members up to a 20% discount on all CRC Press books. Learn more about this and other benefits here.
Sign in to follow this  
Followers 0
boogyman19946

Processing custom scripts

8 posts in this topic

I'm currently working on a game and I wanted to make the game be more flexible in functionality by adding scripts. At the moment, every time I need to reach for a script, I basically open the file, parse it, and let the code act accordingly to the script. So I was wondering, would it make sense to load those scripts once, save them internally in some format, and then work with the already analyzed scripts, or is it okay if the code keeps parsing the scripts? I did this once before in Java but the scripts were fairly simple and I only ran them when an object in the game was spawned (because the settings for those objects were saved in scripts) and I didn't notice any performance hit. It was a 2D sidescroller back then, now we're attempting an RPG if that changes anything.

If I need to expand on the details, then please say so :)

So, parse once, or parse every time?
0

Share this post


Link to post
Share on other sites
Why not use one of the various scripting languages already out there? Lua, javascript, python, etc.. They all are designed for this purpose and their VMs and interfaces are already coded for you.
1

Share this post


Link to post
Share on other sites
I actually haven't even thought about using another language for scripting. That certainly not a bad idea, but I do eventually want to make a custom scripting system, if for nothing else but practice :) I'll have a look into those languages and see what I can conjure up.
0

Share this post


Link to post
Share on other sites
Most of the ones out there are also open source, so you might be able to get some ideas for your custom scripting language from their code bases.
0

Share this post


Link to post
Share on other sites
[quote name='boogyman19946' timestamp='1323491601' post='4892435']
I'm currently working on a game and I wanted to make the game be more flexible in functionality by adding scripts. At the moment, every time I need to reach for a script, I basically open the file, parse it, and let the code act accordingly to the script. So I was wondering, would it make sense to load those scripts once, save them internally in some format, and then work with the already analyzed scripts, or is it okay if the code keeps parsing the scripts? I did this once before in Java but the scripts were fairly simple and I only ran them when an object in the game was spawned (because the settings for those objects were saved in scripts) and I didn't notice any performance hit. It was a 2D sidescroller back then, now we're attempting an RPG if that changes anything.

If I need to expand on the details, then please say so :)

So, parse once, or parse every time?
[/quote]

In general, loading and reparsing all the time is a bad idea. Most script languages allow you to load/parse a script and then save the binary VM opcodes out in a directly usable manner. I use lua for most of this and have wrapped it up with a couple nice utility items for the purposes you are discussing:

1. Direct load, parse and use of script. This is exactly what you say you are doing and I do use it that way in the cases where this is just initialization script which is used once like a config file. If it becomes a performance issue, I have an offline compiler which takes the source and turns it into .luab files which are the binary compiled versions which load in preference to the .lua files. I.e. when I load the script I look for a luab first and use that if it's time stamp is newer than the raw lua fie.
2. Actual game script is loaded and compiled to binary once and the binary representation is kept around for further use.

At this point it is up to you but generally the reason to use scripting is to speed up development turn around times and as such dynamic hot reloading of scripts is often desired. Using the file event api's for your OS is a good starting point but keep in mind that you will often need to modify multiple scripts before they reload. So, make sure you assign scripts a switch which says auto reload or manual reload. In lua, I simply use a meta table item which tells the engine if it should monitor the script source for changes and auto reload or not. For the non-auto reloads I bind a hot key, usually something complicated like "shift-ctrl-alt-R" just to make sure I don't accidentally activate it. It then proceeds to purge and reload all the scripts are not flagged auto in one shot. This freezes the engine inbetween frames (I heavily multi-thread so this has to be done) and causes a considerable hitch but for this purpose, but it is still better than shutting down and restarting the game.

And as jonbonazza says, I suggest using an existing language also. Making new languages is really silly unless you have a very specific reason for it. You mention practice, that's fine but really isn't the game itself more important? :)
1

Share this post


Link to post
Share on other sites
[quote name='AllEightUp' timestamp='1323555580' post='4892646']
In general, loading and reparsing all the time is a bad idea. Most script languages allow you to load/parse a script and then save the binary VM opcodes out in a directly usable manner. I use lua for most of this and have wrapped it up with a couple nice utility items for the purposes you are discussing:

1. Direct load, parse and use of script. This is exactly what you say you are doing and I do use it that way in the cases where this is just initialization script which is used once like a config file. If it becomes a performance issue, I have an offline compiler which takes the source and turns it into .luab files which are the binary compiled versions which load in preference to the .lua files. I.e. when I load the script I look for a luab first and use that if it's time stamp is newer than the raw lua fie.
2. Actual game script is loaded and compiled to binary once and the binary representation is kept around for further use.

At this point it is up to you but generally the reason to use scripting is to speed up development turn around times and as such dynamic hot reloading of scripts is often desired. Using the file event api's for your OS is a good starting point but keep in mind that you will often need to modify multiple scripts before they reload. So, make sure you assign scripts a switch which says auto reload or manual reload. In lua, I simply use a meta table item which tells the engine if it should monitor the script source for changes and auto reload or not. For the non-auto reloads I bind a hot key, usually something complicated like "shift-ctrl-alt-R" just to make sure I don't accidentally activate it. It then proceeds to purge and reload all the scripts are not flagged auto in one shot. This freezes the engine inbetween frames (I heavily multi-thread so this has to be done) and causes a considerable hitch but for this purpose, but it is still better than shutting down and restarting the game.

And as jonbonazza says, I suggest using an existing language also. Making new languages is really silly unless you have a very specific reason for it. You mention practice, that's fine but really isn't the game itself more important? :)
[/quote]

Well, the script isn't all that complicated. Basically, I have a more or less generic entity class which is initialized with a script file to discern between various entities so for the time being, I only load each file once. I was thinking about being able to define new functionality in scripts with functions and I was wondering if I should define some kind of internal storage. Maybe I'll use a scripting language like Lua, I'll still have to think about it.

As far as practicing, to be honest, right now I don't really care so much for games. Unlike other people, I didn't get into programming because I thought making games was cool. I got into programming because I wanted to know why my computer does things the way it does, and I figured it would be best to learn how it works through learning to control it first :) It just so happened that games are something I can apply my knowledge in. I'm not sure if seeing things this way alters my ability as a games programmer, but I personally like it better that way. I find my goals are far less stretched and I can test what I learn a lot faster before I am even half way through the game. That's not to say I don't like making games because I do :D It's just that when I make them I tend to focus more on things I have yet to learn than to crank out as many games as I can like an assembly line.
0

Share this post


Link to post
Share on other sites
[quote name='boogyman19946' timestamp='1323585742' post='4892723']
[quote name='AllEightUp' timestamp='1323555580' post='4892646']
In general, loading and reparsing all the time is a bad idea. Most script languages allow you to load/parse a script and then save the binary VM opcodes out in a directly usable manner. I use lua for most of this and have wrapped it up with a couple nice utility items for the purposes you are discussing:

1. Direct load, parse and use of script. This is exactly what you say you are doing and I do use it that way in the cases where this is just initialization script which is used once like a config file. If it becomes a performance issue, I have an offline compiler which takes the source and turns it into .luab files which are the binary compiled versions which load in preference to the .lua files. I.e. when I load the script I look for a luab first and use that if it's time stamp is newer than the raw lua fie.
2. Actual game script is loaded and compiled to binary once and the binary representation is kept around for further use.

At this point it is up to you but generally the reason to use scripting is to speed up development turn around times and as such dynamic hot reloading of scripts is often desired. Using the file event api's for your OS is a good starting point but keep in mind that you will often need to modify multiple scripts before they reload. So, make sure you assign scripts a switch which says auto reload or manual reload. In lua, I simply use a meta table item which tells the engine if it should monitor the script source for changes and auto reload or not. For the non-auto reloads I bind a hot key, usually something complicated like "shift-ctrl-alt-R" just to make sure I don't accidentally activate it. It then proceeds to purge and reload all the scripts are not flagged auto in one shot. This freezes the engine inbetween frames (I heavily multi-thread so this has to be done) and causes a considerable hitch but for this purpose, but it is still better than shutting down and restarting the game.

And as jonbonazza says, I suggest using an existing language also. Making new languages is really silly unless you have a very specific reason for it. You mention practice, that's fine but really isn't the game itself more important? :)
[/quote]

Well, the script isn't all that complicated. Basically, I have a more or less generic entity class which is initialized with a script file to discern between various entities so for the time being, I only load each file once. I was thinking about being able to define new functionality in scripts with functions and I was wondering if I should define some kind of internal storage. Maybe I'll use a scripting language like Lua, I'll still have to think about it.

As far as practicing, to be honest, right now I don't really care so much for games. Unlike other people, I didn't get into programming because I thought making games was cool. I got into programming because I wanted to know why my computer does things the way it does, and I figured it would be best to learn how it works through learning to control it first :) It just so happened that games are something I can apply my knowledge in. I'm not sure if seeing things this way alters my ability as a games programmer, but I personally like it better that way. I find my goals are far less stretched and I can test what I learn a lot faster before I am even half way through the game. That's not to say I don't like making games because I do :D It's just that when I make them I tend to focus more on things I have yet to learn than to crank out as many games as I can like an assembly line.
[/quote]

Trust me, I agree with that point of view. I started programming because I wanted to copy a game and make it better, while I never did that (hey I was 12 :)), it started me programming and I've been doing it professionally for a very long time with a couple pitstops in between. But, while I always like to screw around learning new things, I also have a pretty strong desire to finish things to a high quality on the way. It actually annoys me, to a certain degree, when the bosses say: you've taken it far enough, let the junior finish it, we have something else for you... It's like pulling fingernails to walk away sometimes after all the initial architecture and setup work to let someone else fill in the finishing touches.

Long story short, learning as much as you can is a great thing but if you don't apply it to finish something, it is mental masturbation. Unless you finish things you never really know how it would really pan out in usage. I.e. a scripting language can look really cool, then you go to use it in real code and realize just what a mess it is, or at least which bits suck and which don't. I'll never write another scripting language myself, just not worth the time/effort in 90% of the cases. Not to mention new languages means you have to train everyone from scratch, bah....
1

Share this post


Link to post
Share on other sites
Yeah, I think I'm just going to go with Lua at this point. I'll plow through the reference manual and try to set it up. I'll save my parsers for a rainy day ^.^ Thanks guys for all your input!
0

Share this post


Link to post
Share on other sites
[quote name='boogyman19946' timestamp='1323750328' post='4893402']
Yeah, I think I'm just going to go with Lua at this point. I'll plow through the reference manual and try to set it up. I'll save my parsers for a rainy day ^.^ Thanks guys for all your input!
[/quote]

If you need help with Lua, let me know. I've become something of a master in integration details, language wise I'm only partially useful though. :) I've implemented integrations several times, I've never been able to really use it in regards to the integration, not my job. :/
0

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0