Add a wall sign and disable "monster"
#1
Hi,

I would to know how to add a wallsign ?
The following code doesn't work in my lua script:



Code:
setBlock(UpdateQueue, Player:GetPosX() + 3, Player:GetPosY() + 2, Player:GetPosZ() + 2, E_BLOCK_WALLSIGN, E_META_CHEST_FACING_ZM)

And my other question is how to disable the spawning monster?

Thanks in advance !! ::D
Reply
Thanks given by:
#2
(07-08-2016, 07:29 AM)LeSanglier Wrote: And my other question is how to disable the spawning monster?

HOOK_SPAWNING_MONSTER and cMonster, docs are handy Wink
First add the hook for HOOK_SPAWNING_MONSTER, and in there check what type the mob is (I'm assuming you want to disable hostile mobs) using cMonster:GetMobFamily(). Then if you want to disable the mob from spawning, return true. Otherwise, return false and the mob will spawn.

You can find an example here.
Reply
Thanks given by:
#3
Thank you PureTryOut !!Big Grin


Code:
Then if you want to disable the mob from spawning, return true. Otherwise, return false and the mob will spawn.


It is exactly the good tips !
Reply
Thanks given by:
#4
As for your wallsign, we need a bit more details. What is the UpdateQueue that you're sending as the first parameter? Are you calling SetBlock in the global namespace, without any object?

Normally you need to specify the world on which the function should operate:
-- world is a variable holding a cWorld object that we got elsewhere - in a hook, or in cRoot:Get():GetWorld("worldname"), or player:GetWorld() etc.
world:SetBlock(x, y, z, E_BLOCK_WALLSIGN, E_META_CHEST_FACING_ZM)

That code only works if you're sure that the chunk where you're setting the block is loaded. It's a bit more difficult if you don't have that guarantee - you need to instruct the cWorld to load the chunk, and then set the block:
-- world is a cWorld object
-- blockX, blockY, blockZ are the coords of the block
-- chunkX, chunkZ are the coords of the chunk which has the block
world:ChunkStay({{chunkX, chunkZ}}, nil,  -- Note the double {\'s, ChunkStay expects a table of tables
  function ()  -- this function gets called when the chunk is loaded
    world:SetBlock(blockX, blockY, blockZ, E_BLOCK_WALLSIGN, E_META_CHEST_FACING_ZM)
  end
)
Reply
Thanks given by:
#5
Hi !

This piece of code comes from the DockerCraft project:
https://github.com/docker/dockercraft/bl...r.lua#L144

With your information, I am trying to debug my code.

Thank you xoft for your explanation !Big Grin
Reply
Thanks given by:
#6
The DockerCraft has their own library that implements the setBlock() function (notice the lowercase s), they have some special processing for that. The code that I've given to you should work out of the box.

ref.: https://github.com/docker/dockercraft/bl...e.lua#L106
Reply
Thanks given by:
#7
Hi xoft !!

(Sorry for the delay)


(07-11-2016, 04:44 AM)xoft Wrote: The DockerCraft has their own library that implements the setBlock() function (notice the lowercase s), they have some special processing for that. The code that I've given to you should work out of the box.

ref.: https://github.com/docker/dockercraft/bl...e.lua#L106

It works !!Big Grin

Thank you for your analyse !
Reply
Thanks given by:
#8
Hi,

I have a very strange error with lua code:


Code:
function addSign(Player)
    Player:GetWorld():SetBlock(Player:GetPosX() + 2, y + 1, Player:GetPosZ() + 1, E_BLOCK_WALLSIGN, E_META_CHEST_FACING_ZM)
    line1 = "Server01"
    line2 = "actif"
    line3 = "192.168.156.120"
    line4 = "Player"
    Player:GetWorld():SetSignLines(Player:GetPosX() + 2, y + 1, Player:GetPosZ() + 1, line1, line2, line3, line4)
    return true
end

I have a sign with but no lines.
I must deconnect/connect to the server to have all displayed lines.
Do you have a tip to display correctly the lines?
Thank you.
Reply
Thanks given by:




Users browsing this thread: 1 Guest(s)