How to spawn a chest? - 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: How to spawn a chest? (/thread-2482.html) |
How to spawn a chest? - newobj - 07-26-2016 Hi folks! This seems like it should be an easy question, but I can't seem to find an answer or example anywhere. How do I spawn a chest? Even trying to construct one doesn't work: local Chest = cChestEntity(Player:GetPosX(), Player:GetPosY(), Player:GetPosZ(), World, E_BLOCK_CHEST) I get: Warning: [3653914e66bad7c|21:58:27] LUA: Plugins/FunMenu/plugin.lua:50: Attempt to call a non-callable object. Even if I can construct one, how do I actually spawn it into the world? Thanks! RE: How to spawn a chest? - newobj - 07-26-2016 Guess I should have search for 1 more minutes... I found this plugin that shows an example: https://github.com/chrobione/GraveChest/blob/master/plugin.lua Victim:GetWorld():SetBlock(Victim:GetPosition().x,(Victim:GetPosition().y +2) , Victim:GetPosition().z, E_BLOCK_CHEST, E_META_CHEST_FACING_ZM) And then "DoWithChestAt"... Cool! RE: How to spawn a chest? - NiLSPACE - 07-26-2016 Try this: World:SetBlock(Player:GetPosX(), Player:GetPosY(), Player:GetPosZ(), E_BLOCK_CHEST) And afterwards if you need to access the chest you can use this: World: DoWithChestAt(Player:GetPosX(), Player:GetPosY(), Player:GetPosZ(), function(chest) -- Do something with the cChestEntity like filling it up end ) RE: How to spawn a chest? - Seadragon91 - 07-26-2016 @NiLSPACE There is a missing param in SetBlock, the meta value. @newobj Add a value from 2 to 5, at the end. Using a value of 0, would make the chest invisible. RE: How to spawn a chest? - NiLSPACE - 07-26-2016 Oh, I thought it was optional, sorry. RE: How to spawn a chest? - Seadragon91 - 07-26-2016 @NiLSPACE thought so, too. The param could be maked optional and a good idea also would be to add a page about the meta value for special blocks like the chest. |