Cuberite Forum

Full Version: cBlockArea
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Pages: 1 2
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?
Not sure, would have to be measured. The cost of callbacks is small but not negligible. It might even depend on the "Code here".
Back to the callback, I need something that does the opposite of MakeIndex. I need the X, Y and Z position from the blockcount.
I'm afraid you'll have to code that one yourself, for now.
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.
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)
Pages: 1 2