Difference between revisions of "Lua makes info files obsolete"

From RogueBasin
Jump to navigation Jump to search
m
m
Line 4: Line 4:


1:Tree,
1:Tree,
2:green,#
2:green,#
3:block_los,block_pathfind
3:block_los,block_pathfind


Line 11: Line 13:
when extending the game with LUA, it's as simple as "dofile"ing the following code:
when extending the game with LUA, it's as simple as "dofile"ing the following code:
(data.prototype_objects is where you store your basic item information.  Simple.)
(data.prototype_objects is where you store your basic item information.  Simple.)
----------------------------------------------------
----------------------------------------------------
data.prototype_objects.tree = { --table constructor
data.prototype_objects.tree = { --table constructor
name = "tree",
name = "tree",
symbol = "#",
symbol = "#",
color = "green",
color = "green",
block_lineofsight=true,
block_lineofsight=true,
block_pathfind = true,
block_pathfind = true,
} --finished the table
} --finished the table
-------------------------------------------------------
-------------------------------------------------------



Revision as of 21:18, 25 December 2011

In Lua, any .lua code file can be executed by your software with a call to dofile("filename")

Hence, there's no reason to write

1:Tree,

2:green,#

3:block_los,block_pathfind

and load that into your data structure with code that parses it and knows what to do, in it's own sort of "code". That's way to complex and with LUA there is no need for that.

when extending the game with LUA, it's as simple as "dofile"ing the following code: (data.prototype_objects is where you store your basic item information. Simple.)


data.prototype_objects.tree = { --table constructor

name = "tree",

symbol = "#",

color = "green",

block_lineofsight=true,

block_pathfind = true,

} --finished the table


--This is only one example form your data can take...

But as you can see, the code is highly readable and easy enough to mod if you have other example code to work from. There's no reason to make a complicated "info file" system if your objects can be contained in .lua files that are easily edited with a text editor and the code is fairly obvious and readable and only requires a minimum familiarity with LUA programming.

-Russell Ackerman Rustle