How to spawn a chest?
#1
Question 
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!
Reply
Thanks given by:
#2
Guess I should have search for 1 more minutes... Smile

I found this plugin that shows an example:

https://github.com/chrobione/GraveChest/...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!
Reply
Thanks given by:
#3
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
)
Reply
Thanks given by: newobj
#4
@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.
Reply
Thanks given by:
#5
Oh, I thought it was optional, sorry.
Reply
Thanks given by:
#6
@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.
Reply
Thanks given by:




Users browsing this thread: 2 Guest(s)