Cuberite Forum
cBlockArea - Printable Version

+- Cuberite Forum (https://forum.cuberite.org)
+-- Forum: Plugins (https://forum.cuberite.org/forum-1.html)
+--- Forum: Plugin Discussion (https://forum.cuberite.org/forum-8.html)
+--- Thread: cBlockArea (/thread-569.html)

Pages: 1 2


RE: cBlockArea - NiLSPACE - 08-14-2013

Do you think a
cBlockArea:DoWithEveryBlock(
-- Code here)
function in C++ exported to Lua is faster then
for X=0, BlockAreaWidthX do
   for Y=0, BlockAreaWidthY do
      for Z=0, BlockAreaWidthZ do
         -- Code here
      end
   end
end
in Lua?


RE: cBlockArea - xoft - 08-14-2013

Not sure, would have to be measured. The cost of callbacks is small but not negligible. It might even depend on the "Code here".


RE: cBlockArea - NiLSPACE - 02-09-2014

Back to the callback, I need something that does the opposite of MakeIndex. I need the X, Y and Z position from the blockcount.


RE: cBlockArea - xoft - 02-10-2014

I'm afraid you'll have to code that one yourself, for now.


RE: cBlockArea - NiLSPACE - 08-18-2014

Wow I didn't expect this to work:
function cBlockArea:SetName(a_Name)
  self.Name = a_Name
  return true
end

local Blck = cBlockArea()
Blck:SetName("TestName")
print(Blck.Name)

This is kinda useless, but I didn't think we could have custom functions in the userdata.


RE: cBlockArea - xoft - 08-19-2014

It is possible in Lua; MCS could theoretically prevent this, but why bother. The only problem is that such extra properties (self.Name) won't get carried across some boundaries, such as inter-plugin comm, or callbacks (such as setting such a property in a cPlayer object and then doing ForEachPlayer later on)