🎉 Celebrating 25 Years of GameDev.net! 🎉

Not many can claim 25 years on the Internet! Join us in celebrating this milestone. Learn more about our history, and thank you for being a part of our community!

Scripting Languages ?

Started by
45 comments, last by __ODIN__ 22 years, 3 months ago
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!
Advertisement
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
------------------------------ BOOMZAPTry our latest game, Jewels of Cleopatra
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]
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");
------------------------------ BOOMZAPTry our latest game, Jewels of Cleopatra
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);
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.
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.
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 ]
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

------------------------------ BOOMZAPTry our latest game, Jewels of Cleopatra
Kylotan, which scripting engine are you using? I think I missed that, at least I don''t recall. Thanks.
"I thought what I'd do was, I'd pretend I was one of those deaf-mutes." - the Laughing Man

This topic is closed to new replies.

Advertisement