[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Re: returning a list of pairs
- From: Roger Durañona Vargas <luo_hei@...>
- Date: Fri, 09 Jan 2009 08:58:31 -0500
David Ludwig escribió:
> On Wed, Jan 7, 2009 at 8:41 AM, Roger Durañona Vargas <luo_hei@yahoo.es> wrote:
>> I need a Lua script to return an array of value pairs to the C host
>> application. I have been checking the docs, but I cant find the correct
>> syntax to define a table with such structure.
>> I tried table[index].member, but that was incorrect. Can somebody
>> suggest me a way to do this?
>
> There are a lot of different ways to do this. Assuming that you need
> an ordered list, and that each pair contains values of unknown types,
> some of which may include duplicates, you could define the structure
> statically like so:
>
Well, this is an first draft of the script:
-- @param q Npc line number
local dialog = {}
if (q=="root") then
--we insert all answers
table.insert(dialog,{"Yes sir, Im ready!","yes"})
table.insert(dialog,{"I really dont like you giving me
orders","no"})
table.insert(dialog,{"I wouldnt call it a skirmish. Was a really
bloodbath if you ask me.","middle"})
--this is the npc line
line="You are one of those rookies that survived yesterday's
skirmish. I have a mission for you, are you ready for more action?"
count=3 -- how many choices we have
return line, count, ta
elseif (q=="no") then
line="I really wasn't asking you. Go see the smith and get a
decent armor and sword. Then come back to me"
end
(it is unfineshed of course).
Basically, what I dont know now is how to get the table in the host app.
I have checked get_table documentation but cant clearly underestand how
to read all those values.
--
Roger D. Vargas
Gentoo Linux 2008.0
http://gpnfn.blogspot.com, The news for game programming newbies
______________________________________________
LLama Gratis a cualquier PC del Mundo.
Llamadas a fijos y móviles desde 1 céntimo por minuto.
http://es.voice.yahoo.com