Defining classes in Lua?
FocusedWolf
Join Date: 2005-01-09 Member: 34258Members
How does one create a custom class, <u>with overloaded operators</u>, in ns2 lua?
I'm guessing, since i can't get it to work, that it's not like luabind anymore? <a href="http://www.rasterbar.com/products/luabind/docs.html#overloading-operators" target="_blank">http://www.rasterbar.com/products/luabind/...ading-operators</a>
I'm guessing, since i can't get it to work, that it's not like luabind anymore? <a href="http://www.rasterbar.com/products/luabind/docs.html#overloading-operators" target="_blank">http://www.rasterbar.com/products/luabind/...ading-operators</a>
Comments
<!--c1--><div class='codetop'>CODE</div><div class='codemain'><!--ec1-->local mt = {
__add = function(self, right)
return self.somefield+right.somefield
end
__sub = function(self, right)
return self.somefield-right.somefield
end
}
//Normally you would just do setmetatable(OurObject, mt) for non class() stuff.
//For stuff declared with class() the object created with mytype() call is a userdata object so we need modify its existing
//metatable we need todo this just once on our created object
local objectmt = debug.getmetatable(OurObject)
for name,value in pairs(mt) do
objectmt[name] = value
end<!--c2--></div><!--ec2-->
i really loved the code navigation in eclipse for the most languages, but unfortunately its not working
in lua-eclipse.
has someone a suggestion?
You can try Decoda, which was developed by UWE. I haven't really tried it but I'm pretty sure I've seen it included in the tools that come with NS2. I'm not much of a programmer, but I hope that's what you might be looking for. You mentioned ease of code navigation -- I'm not sure of all the perks Decoda has. It says it's an IDE and not just a debugger, so I assume you can use it like any editor.
Otherwise I've downloaded Notepad++ and use that to make up any quick code or just to mess around. I like light and simple stuff.
<a href="http://i.imgur.com/HmkWb.png" target="_blank">http://i.imgur.com/HmkWb.png</a>
Also a warning. You can't just install UltraEdit and achieve an awesome state. You need to remove many toolbars + configure a bunch of options + install a .uew lua language word file so it can understand lua (i'm using a custom one that i had to make just to get functions to fold correctly). Also UltraEdit sucks! at syntax coloring so i had to get a third party tool "UltraEdit Color Scheme Manager" Just to get some half decent syntax coloring. Yes it was worth it. It works very good now :P
browsing through files, browse through collapseable object lists, which shows you all those informations and enables you to jump to their definitions. maybe i just want to much :D
or i have to write my own plugin for eclipse, but then... i prefer simply using what I already have.
nevertheless, functionality like call hirarchy or simple code navigation (Ctrl+left mbutton -> jump to definition) would be really nice. i really like the comfort
to see in a fast and simple way (without searching for it) who calls "me", what happens before and afterwards.
IntelliJ-IDEA IDE: <a href="http://www.jetbrains.com/idea/download/" target="_blank">http://www.jetbrains.com/idea/download/</a>
Lua-for-IDEA plugin: <a href="https://bitbucket.org/sylvanaar2/lua-for-idea/wiki/Home" target="_blank">https://bitbucket.org/sylvanaar2/lua-for-idea/wiki/Home</a>
I haven't looked in on the project in about 6 months, but AFAIK he's still actively working on it. If you wish to speak to sylvanaar directly, he can usually be found on the #wowace channel on freenode.net irc.
<img src="https://bitbucket.org/sylvanaar2/lua-for-idea/wiki/9-13-2010-9-22-40.png" border="0" class="linked-image" />
i will try it, thanks :)
It looks like it would be helpful for someone who is mainly muddling through Lua by dipping into someone else's code.
Decode I tried just once, its not bad (better than most other editors out there) but its not starting anymore in win7 64-bit, so its currently anyway no option (at least for me) I have also seen that there are multiple eclipse plugins already out there for lua, so I will try them aswell before, and if they are any good I'll let you know