Game Scripting Problem

classic Classic list List threaded Threaded
6 messages Options
Reply | Threaded
Open this post in threaded view
|

Game Scripting Problem

Daniel Krenn
Hi,

We're new to scripting and are strongly considering using LUA with one
of our upcoming projects. Since our knowledge of scripting in general
is rather limited, we were wondering if someone might be able to offer
us some assistance with the following problem.

If we are wanting to implement simple script functionality such as...

----------------------------
Spawn("Location 1")

do
  GotoLocation("Location 2")
  Wait(2)
  GotoLocation("Location 1")
  Wait(2)
end
----------------------------

...whereby multiple actors can be using a script similar to (but much
more complex than) this example. The actors need to process each line
of the script sequentially, and not continue to the next line of script
until the current line (command) has been successfully completed (obviously
=p)

What would be the best way to have the script operate in this fashion
(while at the same time trying to avoid multi-threading, and
coroutines) ???

I know this kind of problem has probably been addressed at some point
in the past, but we would be extremely appreciative if someone working
with games could throw us a hint or two, or throw us some examples
relating to this issue.

Best Regards,
Daniel.

[hidden email]



pau
Reply | Threaded
Open this post in threaded view
|

Re: Game Scripting Problem

pau
You may want to adopt an event-driven style, and use a timer to trigger
the process of every steps in a event so that you can maintain all
activities of different events in a single thread.

In your Lua script, the GotoLocation("Location 2") actually only
triggers the initiation of a 'Goto' event. If you want subsequent
actions to be taken after GotoLocation("Location 2"), you may pass
them as function callbacks.

Regards,
.paul.

On Sun, Dec 03, 2000 at 12:09:33AM +1000, Daniel Krenn wrote:
> Hi,
> 
> We're new to scripting and are strongly considering using LUA with one
> of our upcoming projects. Since our knowledge of scripting in general
> is rather limited, we were wondering if someone might be able to offer
> us some assistance with the following problem.
> 
> If we are wanting to implement simple script functionality such as...
> 
> ----------------------------
> Spawn("Location 1")
> 
> do
>   GotoLocation("Location 2")
>   Wait(2)
>   GotoLocation("Location 1")
>   Wait(2)
> end
> ----------------------------
> 
> ...whereby multiple actors can be using a script similar to (but much
> more complex than) this example. The actors need to process each line
> of the script sequentially, and not continue to the next line of script
> until the current line (command) has been successfully completed (obviously
> =p)
> 
> What would be the best way to have the script operate in this fashion
> (while at the same time trying to avoid multi-threading, and
> coroutines) ???
> 
> I know this kind of problem has probably been addressed at some point
> in the past, but we would be extremely appreciative if someone working
> with games could throw us a hint or two, or throw us some examples
> relating to this issue.
> 
> Best Regards,
> Daniel.
> 
> [hidden email]
> 
> 

Reply | Threaded
Open this post in threaded view
|

RE: Game Scripting Problem

Vincent Penquerc'h-3
In reply to this post by Daniel Krenn
> ----------------------------
> Spawn("Location 1")
> 
> do
>   GotoLocation("Location 2")
>   Wait(2)
>   GotoLocation("Location 1")
>   Wait(2)
> end
> ----------------------------

As an example, here is how I handle the goto commands:
When I need to go to a particular location, I call a game
routine "FindPathTo", which returns a userdata (a path).
I then call "FollowPath" for the character. This will set
the path as the 'current' path. Every game tick, if the
character has a current path, it progresses through it.
When it reaches the end of the path, the current path is
reset to nothing.
If I want to be notified whenever the character reaches its
target, I set a scope on the location where to go. A scope
is a location or a set of locations which, upon being entered
or left by a character, send a message to the scope creator.
This allows to be notified whenever arriving to destination,
but other things to: a merchant can know whenever someone
enters or leaves its store, etc, etc.
Having a pause instruction in your script will require you
to modify Lua or to have complex housekeeping in your engine.

-- 
Lyrian 


Reply | Threaded
Open this post in threaded view
|

About the Lua wiki

Thomas Praxl
Hi,

----- Original Message -----
From: "John Belmonte" <[hidden email]>
To: <[hidden email]>
>Sent: Tuesday, December 05, 2000 1:12 AM
>Subject: about the Lua wiki
>I have to ask, why are you translating the Lua manual onto the wiki?  I
>don't think that is useful for several reasons.  The Lua manual is an
>official text so it shouldn't be in a malleable form like a wiki.  It will
>take a lot of work to keep the wiki version up to date.  Having all the
>manual text will make wiki searching slower, and all the manual pages will
>distract everyone from the main point of the wiki which is for the
community
>to make its own knowledge base.  I really recommend just making a link to
>tecgraf...

I thought it could be a useful base for links to other topics in the
swiki-pages to have the manual in swiki-syntax.
But the more I work on it, the more I think that you´re right :)
It´s a lot of work...
Perhaps the others could post their position about that.

Bye

Thomas





s
Reply | Threaded
Open this post in threaded view
|

Re: About the Lua wiki

s
>Hi,
>
>----- Original Message -----
>From: "John Belmonte" <[hidden email]>
>To: <[hidden email]>
>>Sent: Tuesday, December 05, 2000 1:12 AM
>>Subject: about the Lua wiki
>>I have to ask, why are you translating the Lua manual onto the wiki?  I
>>don't think that is useful for several reasons.  The Lua manual is an
>>official text so it shouldn't be in a malleable form like a wiki.  It will
>>take a lot of work to keep the wiki version up to date.  Having all the
>>manual text will make wiki searching slower, and all the manual pages will
>>distract everyone from the main point of the wiki which is for the
>community
>>to make its own knowledge base.  I really recommend just making a link to
>>tecgraf...
>
>I thought it could be a useful base for links to other topics in the
>swiki-pages to have the manual in swiki-syntax.
>But the more I work on it, the more I think that you´re right :)
>It´s a lot of work...
>Perhaps the others could post their position about that.
>
>Bye
>
>Thomas

I agree with John.

I've just downloaded Erik's binaries for win.  Initially,
my intention is to be a naive user.  By that I mean to
use Lua Standalone (luaSA?).  I would find a tutorial
on luaSA very useful.  I'm willing to proof-read any
attempt at such a manual.  I'll be able to provide the
perspective of someone who knows C (intermediate level)
but who is new to luaSA.

Such a tutorial is vital to increasing the use of lua;
after all, the intention is that there will be more
end-users (i.e. those using luaSA) than those embedding and
extending it.  Perhaps the wiki will encourage such a 'project'.
I'm happy to help in any way possible.

Also,
I now have a copy of LCC-Win32 and intend to use it from
the command line.  Is anyone able to advise on preparing
a makefile for lua using LCC-Win32 (command line)?

Thanks in advance.

Regards sns
  -- checked out python, perl, icon, REBOL, tcl, Z(apl),
     metacard, vb, awk for scripting.

     Chose lua for:
     simple imperative syntax, tables as the fundamental
     data structure, functions as first-class citizens,
     efficiency (time/space), the virtual machine and bytecode,
     good information hiding via "local var" and tables,
     objects and OO can be programmed very easily in the
     language if I want to - they are NOT pushed down my
     throat, a small but growing library, open source
     pure C implementation, the options to extend and embed
     and most of all SOLID ENGINEERING and DESIGN by people
     who know that less is more.
     
     I'm grateful to the creators and maintainers of lua, the
     creators and maintainers of lua libraries, to all
     the experts who help on this list, and to those who
     provide binaries.

Reply | Threaded
Open this post in threaded view
|

Re: About the Lua wiki

Thomas Praxl
Hi,

ok, i´ll chuck out the swiki-version of the manual..
But please help me building a real good lua-site. Since I´m pretty new to
lua and have to learn a lot more about it, I don´t think that I´m able to
provide own manuals.

Thx

Thomas