[SOLVED] Bug in cLuaWindow
#1
So I made a quick plugin to mess around with creating windows via cLuaWindow, yet I get an error (which actually seems to be a bug in the lua "glue" of MCServer, I've been reading documentation for a few hours trying to fix this)

Here is my code:
PLUGIN=nil
function Initialize(Plugin)
	Plugin:SetName("WndTest")
	Plugin:SetVersion(1)
	LOG("Initialised " .. Plugin:GetName() .. " v." .. Plugin:GetVersion())
    PLUGIN=Plugin
    return true
end
function OnDisable()
    LOG(PLUGIN:GetName().." v."..PLUGIN:GetVersion().." is shutting down...")
end
function CommandTest(split,Player)
    Wnd=cLuaWindow(0,9,3,"Test")
    Wnd:SetSlot(Player,1,cItem(E_ITEM_DIRT,64))
    Player:OpenWindow(Wnd)
end
cPluginManager.BindCommand("/wndtest","wndtest.use",CommandTest," - Test.")

When I run that, I get this error in the console:
Code:
[18:47:07] LUA: error in function 'new'.          
     argument #2 is 'nil'; '[no object]' expected.
Not sure if it's a bug, if it is then I'll submit it on Github later, but I just want to make sure this is not just me messing up.

edit: before one of my friends comes on here saying he wrote some of it too, he did, but it was mainly comments on the bottom left as a note for me that I omitted :p
Reply
Thanks given by:
#2
That's not a bug in cLuaWindow. If you look at the stacktrace that is presented right after the error message, you'll see that the actual error comes from the cItem constructor. And that would be because there's no such thing as E_ITEM_DIRT. Use E_BLOCK_DIRT instead.

By the way, there is an example for using the cLuaWindow class in the Debuggers plugin, I've just tested it and it still works Smile
Reply
Thanks given by: wolfmitchell
#3
(01-04-2015, 08:20 PM)xoft Wrote: That's not a bug in cLuaWindow. If you look at the stacktrace that is presented right after the error message, you'll see that the actual error comes from the cItem constructor. And that would be because there's no such thing as E_ITEM_DIRT. Use E_BLOCK_DIRT instead.

By the way, there is an example for using the cLuaWindow class in the Debuggers plugin, I've just tested it and it still works Smile

Ah, derp. Thought the error was in Wnd:SetSlot the whole time... Good job me. ThanksBig Grin
Reply
Thanks given by:




Users browsing this thread: 2 Guest(s)