diff options
| author | Alexander Gavrilov | 2012-08-23 19:27:12 +0400 |
|---|---|---|
| committer | Alexander Gavrilov | 2012-08-23 19:27:28 +0400 |
| commit | c6c5ad56c9b4421e1bf8a5bc2f38323734a9d2eb (patch) | |
| tree | d81ff429044aa2cfd70f901c615c64db48f5ad3e /library/lua | |
| parent | 7046a6abbc157dd0102189e7dd6769183196766f (diff) | |
| download | dfhack-c6c5ad56c9b4421e1bf8a5bc2f38323734a9d2eb.tar.gz dfhack-c6c5ad56c9b4421e1bf8a5bc2f38323734a9d2eb.tar.bz2 dfhack-c6c5ad56c9b4421e1bf8a5bc2f38323734a9d2eb.tar.xz | |
Track lua event listener count, and let the C++ host know.
This allows completely avoiding the call overhead if there
are none. The downside is that the event object now has to
be a userdata with lots of metamethods.
Diffstat (limited to 'library/lua')
| -rw-r--r-- | library/lua/dfhack.lua | 9 |
1 files changed, 3 insertions, 6 deletions
diff --git a/library/lua/dfhack.lua b/library/lua/dfhack.lua index 5ebc9809..5699e8a2 100644 --- a/library/lua/dfhack.lua +++ b/library/lua/dfhack.lua @@ -122,8 +122,9 @@ end -- Misc functions function printall(table) - if type(table) == 'table' or df.isvalid(table) == 'ref' then - for k,v in pairs(table) do + local ok,f,t,k = pcall(pairs,table) + if ok then + for k,v in f,t,k do print(string.format("%-23s\t = %s",tostring(k),tostring(v))) end end @@ -177,10 +178,6 @@ end -- String conversions -function dfhack.event:__tostring() - return "<event>" -end - function dfhack.persistent:__tostring() return "<persistent "..self.entry_id..":"..self.key.."=\"" ..self.value.."\":"..table.concat(self.ints,",")..">" |
