lua-users home
lua-l archive

[Date Prev][Date Next][Thread Prev][Thread Next] [Date Index] [Thread Index]


> I'm using Lua for game scripting. I'd like to have the script call a
> command, pause execution until it is finished, then resume at the next
> statement.
>
> For example for an NPC:
> PickupWeapon()
> EquipWeapon()
> MoveTo(40,40)
> GuardLocation()
>
> Obviously I don't want it equipping a weapon before it has picked it up.
> >From studying the documentation I think coroutines and threads are what
> I should be looking into, but I wanted to ask before I head done a
> possibly wrong approach.

There's been a lot of discussion on-and-off on this subject, and there are
several approaches using coroutines that work fairly well. One that I
played with a little bit was a simple scheduler written in Lua that can do
some of this. Check:

  http://lua-users.org/wiki/SituationScheduler

Having said that I should warn you that I am NOT a game developer. I wrote
this as a way of scripting simulations. I *think* it will work well for
games.

   - Tom