Cuberite Forum
cWindow class - Printable Version

+- Cuberite Forum (https://forum.cuberite.org)
+-- Forum: Cuberite (https://forum.cuberite.org/forum-4.html)
+--- Forum: Development (https://forum.cuberite.org/forum-13.html)
+--- Thread: cWindow class (/thread-1181.html)



cWindow class - fankins - 07-11-2013

How to use a class cWindow. For example, I want to bring up the chest with /window, how can I do this?


RE: cWindow class - xoft - 07-11-2013

You cannot use cWindow directly, it is only a base class from which all windows are inherited. You need to use cLuaWindow. Note that it inherits all cWindow's functions.

For a simple example on showing windows as reactions to commands, see the Debuggers plugin (distributed as built-in with MCServer / https://code.google.com/p/mc-server/source/browse/trunk/MCServer/Plugins/Debuggers/Debuggers.lua ), it has a "/testwnd" command that shows a window filled with custom items and has some processing when the window is closed. You can safely ignore the GCOnTick-related stuff, that's only for internal testing purposes.

In case you are wondering why it is so, why two classes, here's the explanation: It is planned that we'll add a hook that will fire each time a window is opened, closed, or clicked. But MCServer uses different classes than cLuaWindow, so it wouldn't have a cLuaWindow instance to hand to that hook. Instead, we chose to have a common ancestor for all windows, so that all windows can be manipulated the same way. That's the cWindow class.


RE: cWindow class - fankins - 07-11-2013

Thanks for the answer! Using the command /testwnd everything works fine, but if you use after command /reload, the server crashing.


RE: cWindow class - xoft - 07-11-2013

I have just written the documentation for both cWindow and cLuaWindow into the wiki:
http://mc-server.org/wiki/doku.php?id=api:cwindow
http://mc-server.org/wiki/doku.php?id=api:cluawindow
I'll have a look at the crash later on.


RE: cWindow class - fankins - 07-12-2013

Thank you! I would like to know the correct size of windows for Chest,Workbench, etc.


RE: cWindow class - xoft - 07-12-2013

http://wiki.vg/Inventory#Windows