lua-users home
lua-l archive

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


> Input callbacks: on_KeyDown, on_MouseMove, etc.
> This lets objects track user input.  If you have NPCs which can 
> have dialog
> with the user, you'll need some way for the NPC to get input.
> 
> --> Honnestly I would prefer to avoid handling direcly the input of the 
> user... (not yet defined how the dialog will be handled)

About this one, I do think it's way to lowlevel.
I thought I'd add my point here, because I've just worked on a dialog
system using Lua:
The entire dialog is written in C++.
The only hooks to Lua are an "onsay" trigger:
  character:onsay(who_told_me_that,what_that_person_told_me)
which allows the dialog to send what the player typed to the NPC
and a say method:
  say(who_says_that,who_is_told_that,what_is_said)
which is a C routine registered to Lua.
This allows complex dialogs very easily: since the onsay trigger
looks up the what_that_person_told_me word (I use keyword based
conversation) in a table, and the relevant field can be either
a string (the NPC's answer) or a Lua function (which can say
different things based on the game state).

I have more conplicated stuff to allow a NPC to provide predefined
answers to a question (basically yes/no questions, but can be any),
but the main stuff boils down to these two points of contact.
I'd like to hear if you come up with something different.

-- 
Lyrian