Posts: 5
Threads: 1
Joined: Jul 2016
Thanks: 3
Given 0 thank(s) in 0 post(s)
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
Posts: 166
Threads: 14
Joined: Nov 2015
Thanks: 13
Given 14 thank(s) in 12 post(s)
(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 
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.
Posts: 5
Threads: 1
Joined: Jul 2016
Thanks: 3
Given 0 thank(s) in 0 post(s)
07-08-2016, 08:04 AM
(This post was last modified: 07-08-2016, 08:05 AM by LeSanglier.)
Thank you PureTryOut !!
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 !
Posts: 6,485
Threads: 176
Joined: Jan 2012
Thanks: 131
Given 1081 thank(s) in 853 post(s)
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:
1 2 | 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:
1 2 3 4 5 6 7 8 | world:ChunkStay({{chunkX, chunkZ}}, nil ,
function ()
world:SetBlock(blockX, blockY, blockZ, E_BLOCK_WALLSIGN, E_META_CHEST_FACING_ZM)
end
)
|
Posts: 5
Threads: 1
Joined: Jul 2016
Thanks: 3
Given 0 thank(s) in 0 post(s)
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 !
Posts: 6,485
Threads: 176
Joined: Jan 2012
Thanks: 131
Given 1081 thank(s) in 853 post(s)
07-11-2016, 04:44 AM
(This post was last modified: 07-11-2016, 04:46 AM by xoft.)
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
Posts: 5
Threads: 1
Joined: Jul 2016
Thanks: 3
Given 0 thank(s) in 0 post(s)
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 !!
Thank you for your analyse !
Posts: 5
Threads: 1
Joined: Jul 2016
Thanks: 3
Given 0 thank(s) in 0 post(s)
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.
|