Jump to content

  • Log In with Google      Sign In   
  • Create Account

Scripting Languages ?


Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.

  • You cannot reply to this topic
46 replies to this topic

#21 __ODIN__   Members   -  Reputation: 479

Like
Likes
Like

Posted 20 March 2002 - 03:43 PM

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


Sponsor:

#22 Anonymous Poster_Anonymous Poster_*   Guests   -  Reputation:

Likes

Posted 20 March 2002 - 06:00 PM

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.

#23 King1297   Members   -  Reputation: 127

Like
Likes
Like

Posted 20 March 2002 - 08:01 PM

I am using Fles and Bison, Cygwin tools.

I have tried many others, and these seen the easiest

#24 King1297   Members   -  Reputation: 127

Like
Likes
Like

Posted 20 March 2002 - 08:01 PM

I am using Fles and Bison, Cygwin tools.

I have tried many others, and these seen the easiest

#25 King1297   Members   -  Reputation: 127

Like
Likes
Like

Posted 20 March 2002 - 08:02 PM

I am using Fles and Bison, Cygwin tools.

I have tried many others, and these seen the easiest

#26 Anonymous Poster_Anonymous Poster_*   Guests   -  Reputation:

Likes

Posted 20 March 2002 - 10:05 PM

you don''t have to triple-post

#27 Kylotan   Moderators   -  Reputation: 3338

Like
Likes
Like

Posted 21 March 2002 - 08:08 AM

I''m not using any scripting engine, as such. I wrote a very basic system myself that accommodates if/else blocks, and sleeping for a period of time. But there''s no real variable support, no scoping, no switch/case, no for loops, no whiles or repeat loops, etc.

Each script that runs allocates a new Context object. This is where the current line number and variables are stored. If it needs to sleep for a while, it stops executing but keeps hold of the Context object. When I wake it up, it continues from where it left off by continuing to use that Context object, and frees it when it terminates. There have to be lots of checks in the system as it''s possible that the targets of the variables could become invalid while a script is sleeping.

In the future I might try some sort of Flex/Bison thing, but I will have to see how easily I can incorporate the sleeping/yielding into that.

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

#28 DaTroof   Members   -  Reputation: 162

Like
Likes
Like

Posted 21 March 2002 - 11:43 AM

quote:
Original post by __ODIN__

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 can think of one possible solution. Let''s say you have a GameLoop function that updates ticks, renders, etc. You could write an extension to your scripting language that calls the GameLoop function. Here, I''ll call it DoEvents, since it''s similar to DoEvents in VB:


  
Character.Goto("Home")
Do Until (Character.Location == "Home") {
DoEvents
}
// etc.



Thus, the GameLoop would still be executed while the script waits for the character to get home.

One obvious danger of this method: what if a second script gets triggered for the same character while the first one is still running? If so, you need to determine whether the first script should die or the second should get cancelled. Adding a counter to the Do loop might be a good idea, too, so if the guy doesn''t get home after a few minutes, he quits trying.

Anyway, I just thought I''d throw that idea out there. I suspect it would be a bear to implement, but any solution to this problem is likely to be non-trivial.


#29 Cybertron   Members   -  Reputation: 122

Like
Likes
Like

Posted 21 March 2002 - 12:23 PM

So far all the tutorials I have seen are really crummy!

I made my own, its an interpreted bytecode, and changes the game by passing paramiters through external functions using ''registers''

Each class can run one script synchronosly (so no waste time loops, only timers). There is also a class to tie them all together and support the external interface and timers

I made the assembler and dissasembler in VB too

#30 __ODIN__   Members   -  Reputation: 479

Like
Likes
Like

Posted 21 March 2002 - 02:44 PM

I can think of one possible solution. Let''s say you have a GameLoop function that updates ticks, renders, etc. You could write an extension to your scripting language that calls the GameLoop function. Here, I''ll call it DoEvents, since it''s similar to DoEvents in VB:

Thus, the GameLoop would still be executed while the script waits for the character to get home.

One obvious danger of this method: what if a second script gets triggered for the same character while the first one is still running? If so, you need to determine whether the first script should die or the second should get cancelled. Adding a counter to the Do loop might be a good idea, too, so if the guy doesn''t get home after a few minutes, he quits trying.

[/QUOTE]

This sounds really dangerous, because in most cases you''ll want to have multiple scripts running concurrently. Your technique would either
a) only execute the tick of one of the scripts (freezing all the others).
or
b) Execute all scripts, snaking in and out of different scripts, and probably causing a stack-failure at the end of it..

If you only have one script running (controlling the UI, for example), the system does work, and I''ve used it before.. It''s not pretty, though..

Odin

#31 Medwynd   Members   -  Reputation: 122

Like
Likes
Like

Posted 21 March 2002 - 09:24 PM

I am using Python.

-Todd D. Degani

#32 DaTroof   Members   -  Reputation: 162

Like
Likes
Like

Posted 22 March 2002 - 04:18 AM

quote:
Original post by __ODIN__
This sounds really dangerous, because in most cases you''ll want to have multiple scripts running concurrently. Your technique would either
a) only execute the tick of one of the scripts (freezing all the others).
or
b) Execute all scripts, snaking in and out of different scripts, and probably causing a stack-failure at the end of it..

If you only have one script running (controlling the UI, for example), the system does work, and I''ve used it before.. It''s not pretty, though..

Odin


Yeah, now that I think about it, that method wouldn''t scale well at all. With a couple dozen scripts running concurrently, jumping in and out of the game loop, things could get erratic.

Maybe a queue would work better. You could have, say, a When command that takes a condition and a series of commands:


  
Character.Goto("Home")
When (Character.Location == "Home") {
// Stuff to do

}


The queue would contain structs, whose members would include a condition and a script. In the above example, the script would take the condition Character.Location == "Home" and the script Stuff to do and push them to the front of the queue. Every so often, the game would test conditions in the queue, and if any are true, execute the script.

(I hope I''m not rehashing old kludges here. Since I''m likely to face these same problems in my own scripting engine, I''m curious to see other programmers'' thoughts.)


#33 Dak Lozar   Members   -  Reputation: 122

Like
Likes
Like

Posted 22 March 2002 - 04:31 AM

Hey Guys,
Hangin'' out at GDC and I made the Scripting Language Roundtable (if you were there, I was the one using Simpkin *Grin*) and this was one of the questions the speaker/moderator asked. From what I can tell it seemed that a good number of people were using Java and Python. There were a few using LUA and even mention of Scheme and Small.

Of the people that were using Java and Python, about 50% of them had modified the back-end to meet their requirements.

The follow up question was why are you using an off the shelf scripting language and not writing your own. The responses to this were many and varied. Here''s the synopsis: Documentation for end users was readily available, Time and Money constraints.

There''s a follow-up roundtable on Saturday covering designing you own scripting language which should be interesting.


As for my own experience, I started off using SpiderMonkey (java-script) and quickly discovered that I did not like the method in which you expose your objects to the scripting language. I found Simpkin and have been experimenting with it for a few months. I''m almost at the point where I think that we will have to write our own scripting language... but there are always issues with this...



Dave "Dak Lozar" Loeser

#34 Kylotan   Moderators   -  Reputation: 3338

Like
Likes
Like

Posted 22 March 2002 - 07:26 AM

quote:
Original post by DaTroof
Maybe a queue would work better. You could have, say, a When command that takes a condition and a series of commands

Doing something like this is easy and obvious for your own scripting language - the problem is in trying to find an existing language that lets you do this cleanly. Because you need to jump out of the script at that point, and potentially execute other scripts as well as normal game code while you are waiting to jump back into that first script.



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

#35 DaTroof   Members   -  Reputation: 162

Like
Likes
Like

Posted 22 March 2002 - 08:07 AM

quote:
Original post by Kylotan
Doing something like this is easy and obvious for your own scripting language - the problem is in trying to find an existing language that lets you do this cleanly. Because you need to jump out of the script at that point, and potentially execute other scripts as well as normal game code while you are waiting to jump back into that first script.



The way I pictured it, the queue would actually be part of the game engine, not the script interpreter. The "When" command would add the condition and the code to the queue. The current script would then terminate without waiting for the condition to be met. The engine, once per tick or whatever, would check the conditions in its queue. If a condition is met, the engine sends the corresponding code back to the interpreter for execution.

This would require some careful namespace management to remember local variables and stuff, but it seems cleaner than letting the original script sleep in memory, waiting for something to happen.


#36 Kylotan   Moderators   -  Reputation: 3338

Like
Likes
Like

Posted 22 March 2002 - 04:22 PM

quote:
Original post by DaTroof
The way I pictured it, the queue would actually be part of the game engine, not the script interpreter. The "When" command would add the condition and the code to the queue. The current script would then terminate without waiting for the condition to be met.

Yeah, but what you just described requires still explicit script support for terminating a script. And going back to the subsequent code would require you to build up your symbol table again including various scopes and whatever. Which is pretty much the same as keeping it hanging around. So I don''t see the difference.

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

#37 DaTroof   Members   -  Reputation: 162

Like
Likes
Like

Posted 23 March 2002 - 04:14 AM

quote:
Original post by Kylotan
Yeah, but what you just described requires still explicit script support for terminating a script.



TCL supports this. When you write an extension to the language, its function''s return value determines whether the script should continue running, exit clean, or exit with an error. I haven''t tried to embed any other script interpreters (except VBScript in VB), so I don''t know what other languages can do this or how it would be done.

quote:

And going back to the subsequent code would require you to build up your symbol table again including various scopes and whatever. Which is pretty much the same as keeping it hanging around. So I don''t see the difference.



Hmm, I guess you''re right. I thought it might be easier (in terms of maintenance and debugging) to dump the script''s local variables than try to manage a hundred scripts'' scopes at once. In the end, though, you''ve still got a namespace to rebuild. Six dozen of one, half a dozen of the other.


#38 Kylotan   Moderators   -  Reputation: 3338

Like
Likes
Like

Posted 23 March 2002 - 11:00 AM

Most embeddable scripting languages provide facilities for you to exit the script by calling a certain function. The problem is that you then lose all your symbols as the script is considered terminated. What would be really useful is a function that suspends the script so you can resume it later. I expect there''s a language out there that does this, but I''ve not found it yet. So I think I will have to settle for my own (Flex/Bison-made) solution.

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

#39 LessBread   Moderators   -  Reputation: 1411

Like
Likes
Like

Posted 23 March 2002 - 11:15 AM

quote:
Original post by Kylotan
Most embeddable scripting languages provide facilities for you to exit the script by calling a certain function. The problem is that you then lose all your symbols as the script is considered terminated. What would be really useful is a function that suspends the script so you can resume it later. I expect there''s a language out there that does this, but I''ve not found it yet. So I think I will have to settle for my own (Flex/Bison-made) solution.



Amen! This used to bother me to no end when I was heavily into web pages and java-scripting. Sure there was SetTimeout and SetInterval, but it took a bit of figuring to use them in a more thread like manner.


#40 Greg Rosenblatt   Members   -  Reputation: 219

Like
Likes
Like

Posted 23 March 2002 - 11:54 AM

As you may have seen, I''ve been doing an article series on this subject, and although I''m not quite up to the topic of "script latency" I will eventually get to it, unless I have a freak stroke or something first.

Rolling your own can be a bit of a task, but it''s not impossible.

"Don''t be afraid to dream, for out of such fragile things come miracles."




Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.



PARTNERS