Complete.Org: Mailing Lists: Archives: freeciv-dev: July 2006:
[Freeciv-Dev] Re: (PR#18260) Configuration files in LUA
Home

[Freeciv-Dev] Re: (PR#18260) Configuration files in LUA

[Top] [All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index] [Thread Index]
To: freeciv-dev@xxxxxxxxxxx
Subject: [Freeciv-Dev] Re: (PR#18260) Configuration files in LUA
From: Jérôme Plût <Jerome.Plut@xxxxxx>
Date: Sat, 8 Jul 2006 12:06:18 +0200

scripsit Curtis Warren :
> <URL: http://bugs.freeciv.org/Ticket/Display.html?id=18260 >

Thanks to both of you for your replies.

> This is interesting. If this ever gets in, it would be nice to move
> away from the same flat format of the config files and use actual
> trees (via nested structures/dictionaries).

I think that either I do not understand, or this is precisely what
this patch does (look at Paratroopers in units.lua, and it will show
something like:

rules.units.Paratroopers = { 
  -- I'm simplifying this example...
  attack = 3,
  upkeep = { shield = 1, happy = 1 },
  paratroopers = { range = 10 },
}

I still have some points on which I'd like some advice, and
particularly this one:

In this patch, when an object needs to reference another (such as unit
-> obsolete_by, or tech->req[0]), the value fed to LUA is the key of
the referenced entry in its table (such as "Paratroopers" in the above
case -- note that this is not necessarily the same as the
unit/building/tech/... name!).

One could think of another way to do this: namely to say
rules.units.Paratroopers instead of "Paratroopers". This is probably
cleaner, but the Paratroopers unit may not be defined at that time.
This may be worked around by using some metatable coding in LUA
(though you need at least three metamethods to do this and prevent
Paratroopers from being overwritten when it is defined later).

I'm also wondering whether the C function that reads the game data
must be called from C or from LUA (this is a trivial change). I think
that it would make sense to have a significant part of the server main
code written in LUA (and keeping data/network helper functions in C of
course): as it is byte-compiled, the impact on performance would be
light, and this would allow for more user tweaking of the game.



[Prev in Thread] Current Thread [Next in Thread]