• Advertisement
Sign in to follow this  

When is best best to use a scripting language?

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

When is best best to use a scripting language API, like lua and python?

EDIT: For a turn-based RPG like Dragon Quest and Final Fantasy. Edited by MadaraEyesOfTruth

Share this post


Link to post
Share on other sites
Advertisement
Now would be a good time to use it. :)
I think you need to be a bit more specific with your question.

Share this post


Link to post
Share on other sites
They are best used where the requirements invites to use them.

So, have you a concrete use case in mind ?

Share this post


Link to post
Share on other sites
Scripting engines are useful if you want to be able to quickly and easily work with content generation like npc behavior or dialog events, etc.

It's a lot of work to embed a scripting engine though, so if your content is going to be static (not changed often) then you may want to weigh the cost vs benefits.

That being said, if your game engine is complete and you get the scripting engine set up correctly you can crank out or change content pretty quick from that point onward, and once it's in place adding or exposing new functionality to the scripting engine is easier than the original embedding process.

There is one danger that some people overlook, so I should mention it. When you expose functionality to a scripting engine you're creating a sort of barrier between high and low level work. If you make this too low-level then your scripting engine will slow down the game, but if you make it too high-level then you're limiting the ways in which you can use the game engine (and you'll end up crapping out tons of new script methods for every new thing you want to do). It takes a lot of thought to place that barrier in just the right place. Edited by Khatharr

Share this post


Link to post
Share on other sites
Those I do understand, scripting languages aren't as fast as compile so I shouldn't do anything time critical like physics with it, but couldn't I do things like dialog events with sqlite3?

Share this post


Link to post
Share on other sites

Those I do understand, scripting languages aren't as fast as compile so I shouldn't do anything time critical like physics with it, but couldn't I do things like dialog events with sqlite3?

Using scripting for dialogs and other similar events is a good use of it. Wheter you're using a sqlite backend or something other depends on your need. However you have to be aware that the execution of your scripts might block the execution of the rest of you game, so having file or db accesses there might slow down your whole program.

Share this post


Link to post
Share on other sites
Uh... I don't know if I'd use SQL for this kind of thing, but I guess whatever floats your boat.

Typically you'd create top-level functions in the code that produce canned effects based on parameters, such as opening a dialog window, playing a sound, showing a character portrait, etc. Then you can expose those to the scripting engine as methods and write a script that calls them with the desired parameters to create your dialog such as:

openDialogWindow(SCREEN_BOTTOM)
pic = loadCharacterPic(GREEN_MAN)
showCharacterPic(pic, BOTTOM_LEFT)
dialogWindowText("Behold, I am Green Man. I have come for your cheese. You have no chance against me. HAHAHAHAHAAAAA!")
waitForKeyPress(CONFIRM_KEY)
closeDialogWindow()
pic = nil
startBattle(BATTLE_32, BOSS_FIGHT)

etc...

Using scripts gives you advantages like simpler syntax (for writing / changing things more easily) and not having to recompile all the time. With some scripting languages you could even change the script on-the-fly if you set it up that way. Edited by Khatharr

Share this post


Link to post
Share on other sites
Using scripts gives you flexibility,Keep your code clean and tidy.smile.png
So if you feel like they will be needed.It's the time to use it.

Share this post


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

  • Advertisement