Cuberite Forum

Full Version: Lua hooks needed!
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Pages: 1 2 3 4 5 6 7 8 9 10 11 12 13
So, iternal m_Items basically is always 3x3 (or 2x2 in inventory crafting grid case)?
Then x,y iterations are reasonable. I thought it was kind of list ^_^"
Oh by the way, I changed sample code, in that code x and y went from 0 to the width/height, instead of width/height-1

Use this:
Code:
for x=0, Grid:GetWidth()-1 do
    for y=0, Grid:GetHeight()-1 do
        local Item = Grid:GetItem(x, y)
    end
end
Isn't Lua usually 1-based, instead of 0-based? I can change the GetItem() function so that it takes number in the 1..Width, 1..Height range, if it makes it more Lua-customary
Yes, Lua has 1...n indexes instead on normal 0...n-1 indexes Smile
And yes, such change will be appretiated.
hmm, I can't even do that, because the same functions are already called from within C++ and are expected to be 0-based. I guess Lua will have to live with thatTongue
Actually I *think* you can do it by adding lua_State* a_LuaState to the function as the first parameter. Lua will then only call that overload of the function.

I think
so, xoft, new crafting hooks seems to be buggy (at least NO_RECIPE one).

Looks like when plugin get such callback and set recipe output, player can get crafting result, but crafting ingridients won't clear!
Try fixies and you'll get what I mean.
Could I suggest one thing about OnChunkGenerated and OnChunkGenerating, please?
Let's sync them and give cLuaChunk to OnChunkGenerated as parameter and give cWorld to OnChunkGenerating as parameter. This will be helpful.
OnChunkGenerated cannot have a cLuaChunk parameter, because the chunk is already stored in the cWorld and other threads may already be modifying its data.
OnChunkGenerating should probably get the cWorld parameter, because the plugin should care in which world the chunk is generating. I'll take care of that.
Quote:OnChunkGenerated cannot have a cLuaChunk parameter, because the chunk is already stored in the cWorld and other threads may already be modifying its data.
So we generally made the whole idea "let generator generate world and then plugin will add structures/custom ores/cumstom finishers" irrealizable? Sad Sad
I appologize, I forgot about cWorld:SetBlock Smile
World param added:
Code:
OnChunkGenerating(cWorld World, int ChunkX, int ChunkZ, cLuaChunk ChunkData)
Pages: 1 2 3 4 5 6 7 8 9 10 11 12 13