differences between "normal" lua and dg lua

i would like to create a list of differences between normal lua and demigods lua. so if you find something that doesnt work though it should or the other way around, post it here!

2,479 views 7 replies
Reply #1 Top

I don't know if this is quite what you're looking for, but I think it might be useful.

I found a Lua script for finding global functions at http://www.wowwiki.com/User:Mikk/Scripts. After a few modifications I was able to call it from a Demigod mod and log the results.

Here's the script I used:

Code: javascript
  1. local function getcfunclist()
  2.  local res = {}
  3.  for k,v in pairs(_G) do
  4.   if type(v) == "cfunction" then
  5.    table.insert(res, k);
  6.   end
  7.  end
  8.  table.sort(res);
  9.  local str = table.concat(res, "\n");
  10.  LOG('CFUNCTIONS:  ', str);
  11. end

And the results are at http://www.arguingwithmyself.com/files/demigod%20cfunctions.txt.  Some of the functions listed I've seen in Demigod Lua - like GetArmiesTable in HUD_scoreboard.lua and GetCamera in bman's partyPanel.lua.  Unfortunately since I'm new to Lua I haven't found a way to get each function's parameters so I don't know how to actually call them.  Maybe an experienced Lua coder can figure that out.

Hope this helps.

Reply #2 Top

once you have a function name, use WinGrep to search for that function in all the LUA and you'll usually find some place where it is being used and/or defined and so can infer the functions.  Maybe a LUA expert can give you a better way though :)

One good method I found was repr(anyvariable) which will dump the contents of the variable/table/object whatever.  I suppose you could pass it a function and see what it dumps out about it?

Reply #3 Top

Demigod lua uses '#' for comment. Normal lua uses this character to get length of a table.

'import' statement is not in normal lua too.

Reply #4 Top

Also, Demigod lua supports the continue statement.

Reply #5 Top

^^^ yeah that's one of the ones I noticed.

Reply #6 Top

Use LUADOC console command to get a list of engine functions.

"import" is not a statement, it's a function.

 

Basically, the lua core is LuaPlus, so most of the changes:

  • ~= as well as !=
  • # and -- for comments
  • no need to use an iterator on a table in "for k, v in table do" construct
  • continue

... and all the other 'improvements' provided by LuaPlus. Though it uses lua 5.0 as a base, so there are couple of annoying bugs.
Also, the lua bytecode isn't compatible with any LuaPlus / vanilla lua versions. ( obviously, gpg modified luaplus )

Reply #7 Top

Demigod uses Lua 5.0 as a base?

I thought it used an earlier version :|