Page 1 of 1

npc Spawner

PostPosted: Sat Dec 15, 2012 18:38
by jojoa1997
Can someone make a spawner for npc's. this might help. http://minetest.net/forum/viewtopic.php?id=2764

PostPosted: Sat Dec 15, 2012 19:15
by jordan4ibanez
I already made one a while back, i'll make one again in a bit

PostPosted: Sat Dec 15, 2012 19:24
by jojoa1997
i was able to make it by changing the names from animal_vombie:vombie to npc:npc but i could not hit the blocks or the game would crash

PostPosted: Sat Dec 15, 2012 20:24
by jordan4ibanez
jojoa1997 wrote:i was able to make it by changing the names from animal_vombie:vombie to npc:npc but i could not hit the blocks or the game would crash

Here's a simple one
Your phone or window isn't wide enough to display the code box. If it's a phone, try rotating it to landscape mode.
Code: Select all
use_mesecons = false

function npc_spawner(pos)
    minetest.env:add_entity({x=pos.x+math.random(-1,1),y=pos.y+math.random(2,3),z=pos.z+math.random(-1,1)}, "npc:npc")
end
if use_mesecons == true then
    minetest.register_node("npc:npc_spawner", {
        description = "Box 'O NPCs",
        drawtype = "glasslike",
        groups = {snappy=1,choppy=2,oddly_breakable_by_hand=2,flammable=3,wood=1},
        sounds = default.node_sound_wood_defaults(),
        tiles = {"default_glass.png"},
        sunlight_propagates = true,
        param2 = "light",
        mesecons = {effector = {
            action_on = npc_spawner
        }}       
    })
end

if use_mesecons == false then
    minetest.register_node("npc:npc_spawner", {
        description = "Box 'O NPCs",
        drawtype = "glasslike",
        groups = {snappy=1,choppy=2,oddly_breakable_by_hand=2,flammable=3,wood=1},
        sounds = default.node_sound_wood_defaults(),
        tiles = {"default_glass.png"},   
        sunlight_propagates = true,
        param2 = "light",
    })
    minetest.register_abm({
        nodenames = {"npc:npc_spawner"},
        interval = 1.0,
        chance = 20,
        action = function(pos)
            npc_spawner(pos)
        end,
    })
end

PostPosted: Sat Dec 15, 2012 21:46
by jojoa1997
what is with the mesecons

PostPosted: Sat Dec 15, 2012 21:47
by jojoa1997
and where do i put this

PostPosted: Sat Dec 15, 2012 22:43
by jordan4ibanez
jojoa1997 wrote:and where do i put this

at the end of the npc init.lua

PostPosted: Sun Dec 16, 2012 01:09
by jojoa1997
it works great thank you

PostPosted: Fri Dec 21, 2012 02:39
by cornellius
how about the textures of the spawner??

PostPosted: Fri Dec 21, 2012 21:40
by tinoesroho
It appears that the texture is the same as default_glass. I personally use the nyancat texture - with fun results on my home server - but....

PostPosted: Sat Dec 22, 2012 01:44
by jojoa1997
i have a texture but i cant get it to be clear the clear spots are white.

PostPosted: Mon Dec 24, 2012 20:36
by tinoesroho
Use GIMP or another program that can handle PNG transparency (not Paint), select those spots and hit the delete key.

@jordan4ibanez: Thanks!