Archived

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

__ODIN__

Scripting Languages ?

Recommended Posts

__ODIN__    479
Hi, Guys; Just wanted to know what scripting language people are using for their projects ? Are you using an off-the-shelf tool (such as LUA), or are you rolling your own ? Thanks, Odin

Share this post


Link to post
Share on other sites
LessBread    1415
So far I''ve seen talk of LUA, Java, java-script and Python. And there are two recent articles on rolling your own that garnered some attention as well.

Share this post


Link to post
Share on other sites
__ODIN__    479
I''ve used LUA (3.2) before, both for configuration and some simple runtime evaluations.

The main issue I had with it was the lack of execute-sleep-and -continue functionality (allowing me to run multiple non-threaded and non-blocking LUA scripts, or allowing me to pause a LUA script while waiting for some condition, such as arriving at the end of a path). Reading through the updated news pages on it, 4.1 Work 3 adds a Yield function, but it''s not yet totally stable...

So I''m checking around for alternatives =)

Odin

Share this post


Link to post
Share on other sites
__ODIN__    479
Interesting thread.

So in your own case.. do you use an existing scripting engine (JS ? Java?), or have you made your own.

Also, has anyone had a look at Pike ? It''s got some interesting semantics, and it''s nice and OOP, but the GPL is a turn-off..

Odin

Share this post


Link to post
Share on other sites
Ziphnor    122
quote:

I've seen Ziphnor praise java-script a number of times.



Hehe, i guess i have been, havent i
Anyway, what i like about it, is simply that its so damn uncomplicated to use.
I should point out though that im not passing objects from C++ -> JS or the other way. I send handles(int's) to the java-script which the script can use for calling functions on the native side. (so the script might call makeWindow(blabla) and this method returns a integer handle that can be used to call native functions on the window.
Also, the methods you want to expose to the java-scripts cant be member functions(afaik).
But if these things doesnt frighten you off, i think its a good place to start when looking for a script language. Java itself is properly better and is more powerful(classes can come in handy as templates for different types of scripts) but its also more complicated to use.

[edited by - ziphnor on March 19, 2002 8:00:02 AM]

Share this post


Link to post
Share on other sites
DaTroof    162
I''m using TCL for scripting. So far, I have no complaints about it, although I might try rolling my own language as a learning experience.

Share this post


Link to post
Share on other sites
LessBread    1415
quote:
Original post by __ODIN__
So in your own case.. do you use an existing scripting engine (JS ? Java?), or have you made your own.



In my case, I haven't implemented a scripting engine of any kind. However, when I get to that point, I will use java-script first because I already know how to use java-script.

This brings out another issue, how well known the scripting language is and whether that is a factor in your game at all. Javscript is well known (notice the hyphen that the forum board places in the word and that it's also lower case - that's a caution against unscrupulous posts - I didn't add the hyphen, and I capitalized the word at the start of this sentence too). Anyway...

// but the forum board doesn't check for mispellings
Javscript
java-script - this was J***script
java script


[edited by - lessbread on March 19, 2002 2:30:58 PM]

Share this post


Link to post
Share on other sites
Taulin    100
I remember looking at the Vampire:Masq. stuff. Java script ran the game in a sense. However, I would more like my objects to use java-script and get manipulated by it. Ziphnor said you could not give java-script a callback to a class method?

I am curious, in a high level sense, how people are integrating their chosen scripting engines and making them interact with the rest of their world. I am sure this differs depending on which one you are using (java-script versus Python for example)

Thanks!

Share this post


Link to post
Share on other sites
__ODIN__    479
quote:
Original post by Taulin

I am curious, in a high level sense, how people are integrating their chosen scripting engines and making them interact with the rest of their world. I am sure this differs depending on which one you are using (java-script versus Python for example)




Well..

I''ve rigged up a set of functions inside the LUA script that get called upon certain criteria. These are examples of an AI interface

OnReceiveDamage()
OnDealDamage()
OnSpotAvatar()
OnTick()
OnCreation()
OnDestruction()

OnSpotAvatar, for example, is called when the AI sees the player (comes into the LOS) for the first time.

I also expose a set of stub-functions for the scripts to interract with my C++ dataset. Typical examples would be:

GetPlayer() returns a DWORD pointer to a player
ReduceLife(int Life, DWORD player) decreases the life of player


What I can''t do with this system at present (to my eternal grief) is something like:

function OnSpotAvatar(int Player)
{
Say("Hail, "..GetName(iPlayer));
Say("Follow me to House");
GoTo("Tile_12_1"); -- ERROR : this will take a lot of time
Say("We''re here... ");
}

Because the script is blocking while trying to execute the goto. These type of scripts are pretty necessary for RPGs, though..

In general, LUA is very good, though. I think one solution might be to spin it off on a thread, but that will be a LOT of threads for a big RPG level.. Any suggestions ?

Thanks,
Odin

Share this post


Link to post
Share on other sites
RolandofGilead    100
Is it possible to run more than one script at a time? If it is then I think you'll come up with something.

How about instead of GoTo, you have something like an Update or
better yet, SetDestination, that way when the computer comes back to processing that script, it will see if it is at Destination and if it isn't then it'll figure out which way to go and initiate Move(int Direction)?

[edited by - RolandofGilead on March 20, 2002 1:27:38 AM]

Share this post


Link to post
Share on other sites
__ODIN__    479
Well.. the current system can have multiple VMs running concurrently, but it''s not time-sliced.

It''s of course possible to fake it, by setting a destination, and requesting the system to send you an event at arrival.. The main problem with this system is that you''re going from being a designer driven system, to becomming a programmer driven system.

My designers don''t wanna know about events, exceptions, or deferred execution. They just want to be able to write goto("Home"), and watch the little guy run across the terrain towards the spot marked "Home". For that we essentially need to pause the script until we reach the spot, and then continue execution in a linear manner..

Here''s how an event-based system will look.

function OnSpotPlayer()
say("Hi, come with me");
Goto("Home", -- To spot
"HOME_EVENT"); -- Send event when reached
end

function EventHandler(Event)
if (Event=="HOME_EVENT") then
say("We''re here");

....

end

this gets REALLY messy and hard to manage, compared to this

say("Hi, come with me");
Goto("Home"();
say("We''re here");

Share this post


Link to post
Share on other sites
Guest Anonymous Poster   
Guest Anonymous Poster
Dude, make SetDestination a part of Goto, who said the designers needed to see it?
A script is exactly that. Designers use it.
A script enigne makes scripts run. Programmers make it.
More importantly, if this is an RPG, when things happen they always look like events.
What the hell are you doing for things like cutscenes and initiating conversations(from the game view, to progress the story, not like if a player walks up to somebody randomly and presses the talk button) and animations?
Also, what about other NPC movement, how is it handled, surely there must be other villagers idling about while this little bit of the script is going on?
I think of that programmer/designer focus of a script kind of as how much work do you put into it. You could on one end hard code it and your source would be your script all the way to making a script so natural that a writer could write a book and it would be translated into a game.


You the Programming God write
int Goto(place) {
SetDestination()
and whatever you want
}

The Designer writes
Goto(place);

Share this post


Link to post
Share on other sites
Guest Anonymous Poster   
Guest Anonymous Poster
In other words, make the event handler part of the code, why would that even be in the script?
With the event handler you might be able to do the following,

game loop calls script
script calls code
script calls some more code
script calls event handler which is code
event handler calls script
which shouldn''t cause problems cause ultimately everything in the script appears as a line of code somwhere.

They don''t have to see any part of the script, even when an event is called the event handler itself could call a portion of script which the designers could then write out.

That''s what was talking about with the Move being called within Goto, RPG''s can use things like pathfinding too you know.

Share this post


Link to post
Share on other sites
Guest Anonymous Poster   
Guest Anonymous Poster
why don''t you use the seerc scripting engine? (http://stud.elka.pw.edu.pl/~ppodsiad/seer/). i used it
on my adventure game some time ago (you write the script into
file and the interpreter reads and compiles it. then you can run
it whenever you want. very flexible.

Share this post


Link to post
Share on other sites
Kylotan    10012
I think you people are missing ODIN''s main problem, which is that the script needs to run concurrently with the rest of the program, and perhaps other scripts, as the simple ''OnSpotAvatar'' example he gave would take a long time to execute, as it involves the character travelling a long distance. This is a real problem, and is why I''m not using Lua in my project.

[ MSVC Fixes | STL | SDL | Game AI | Sockets | C++ Faq Lite | Boost ]

Share this post


Link to post
Share on other sites
__ODIN__    479
quote:
Original post by Kylotan
I think you people are missing ODIN''s main problem, which is that the script needs to run concurrently with the rest of the program, and perhaps other scripts, as the simple ''OnSpotAvatar'' example he gave would take a long time to execute, as it involves the character travelling a long distance. This is a real problem, and is why I''m not using Lua in my project.



Thanks, Kylotan;

I''m sorry if I didn''t get the point across. In most cases, the game needs to run multiple concurrent scripts, with the ability to "step out of" the script while executing long-running C functions (Essentially allowing the rest of the program, such as the renderer and the tick loops to run).

I''ll check out http://stud.elka.pw.edu.pl/~ppodsiad/seer; maybe it''s a closer match to what I need... =)

Any other examples of script engines ppl have tried and tested would be usefull as well..

Thanks,
Odin

Share this post


Link to post
Share on other sites
__ODIN__    479
quote:
Original post by Anonymous Poster
why don''t you use the seerc scripting engine? (http://stud.elka.pw.edu.pl/~ppodsiad/seer/). i used it
on my adventure game some time ago (you write the script into
file and the interpreter reads and compiles it. then you can run
it whenever you want. very flexible.



Hi, AA..

how did you find the engine ? It seems to have been discontinued (no new updates since version 0.94a in 99)... Was it stable ? Any problems ?

Odin

Share this post


Link to post
Share on other sites
Guest Anonymous Poster   
Guest Anonymous Poster
i don''t remember how i found it, it was some years ago.
but it works, haven''t found any bugs (yet). you can also precompile the script into file and load it later. this means you can encrypt it if you want so no one can hack your game (if you don''t want)... and it''s free.

Share this post


Link to post
Share on other sites