Show Posts

This section allows you to view all posts made by this member. Note that you can only see posts made in areas you currently have access to.


Messages - Malice

Pages: [1]
1
Programming / Re: Adding Scripting language to your game(C++)
« on: April 07, 2015, 11:14:17 PM »
Some languages have particularly straightforward ways to do the automation stage, for example Cython does this kind of thing pretty cleanly if you want to script with python.
I'll look into Cython. Python is nice language. I've just never coupled two languages to create code that will work(other than simple hello, world), and given how my program works, it looked like I'd have to run everything from scripting lanugage(because the only thing that gets called in main is Game.Run()).

@Xecutor - I'm not, I gave QT as an example of what I'm doing. All the libs so far are SDL.

2
Programming / Re: Adding Scripting language to your game(C++)
« on: April 07, 2015, 03:54:43 PM »
Then why do you even need C++ or other languages? Just script everything with Lisp and it'll be fine.
I'm doing this as University project. Normally I'd try with Common Lisp, but it looks like for most folks in there, Lisp is something exotic.

My main concern is about how to wrap all these together. I'm using kind of state machine for my game. There's main game engine(something like QT's "app", I guess). Each state implements HandleEvents, Update and Draw.If I wanted to call any code from Common Lisp, I'd have to write wrapper for whole game in Lisp. I just don't have any idea about how to get these two to work together.

3
Programming / Adding Scripting language to your game(C++)
« on: April 06, 2015, 10:14:57 PM »
Hello!
First of all, I'd like to say hi - It's my first post in here. Hi! :)

Now let's cut to the chase - I'm writing some simple rougelike in C++. I'm using SDL for graphics. It's not even started properly, but I'd like to make some decisions about scripting.
I'd like to add some things like AI or quests as external source that will be read on fly - either at the beginning of game, at startup, or later. I don't know yet. In some prototype I've wrote before, I used xml for items and NPC lines. It worked nicely, now I'd probably use json, but it turned out ok. It could stay that way.
However, I have no idea how to implement scripting for, let's say, quests. I want to give quest - "If you kill 10 rats, quest is finished.". How to do it? I can't call function from C++ that way, I can't just paste the code, because by the time it's already compiled(in Lisp it wouldn't be that hard, eh?* :)).

I don't want to write wrapper for everything, it would be too much work. I want to have some ability to nicely work with code from outside. Is there some easy way to do it? I'd be grateful for sharing your experience or pieces of code(preferably C++, but can be some different language if there isn't much language-related magic going on). I've tried searching on my own, but people mostly write some general statements("Use scripting for X") or write too simple examples("hello world" in Lua isn't helping). I've completed some Lua tutorial, so I kind-of have some idea about how to use Lua with C++, but I have no idea about how to use Lua with C++ with OOP, and get all this to work together nicely without making my code look like some tasty, tangled spaghetti.

Thanks in advance!

*Yes. I like Lisp. Great language!

Pages: [1]