Lua hooks needed!
#21
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 ^_^"
Reply
Thanks given by:
#22
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
Reply
Thanks given by:
#23
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
Reply
Thanks given by:
#24
Yes, Lua has 1...n indexes instead on normal 0...n-1 indexes Smile
And yes, such change will be appretiated.
Reply
Thanks given by:
#25
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
Reply
Thanks given by:
#26
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
Reply
Thanks given by:
#27
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.
Reply
Thanks given by:
#28
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.
Reply
Thanks given by:
#29
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
Reply
Thanks given by:
#30
World param added:
Code:
OnChunkGenerating(cWorld World, int ChunkX, int ChunkZ, cLuaChunk ChunkData)
Reply
Thanks given by:




Users browsing this thread: 2 Guest(s)