Page 3 of 169

Posted: Sat Feb 09, 2013 16:19
by Topywo
pandaro wrote:someone has already done an anvil? I find in that mod?
sda97:

http://forum.minetest.net/viewtopic.php ... 981#p35981

Posted: Sun Feb 10, 2013 13:22
by Casimir
Can you make an entity emit light?

Posted: Mon Feb 11, 2013 15:55
by Likwid H-Craft
How do I change the sun, and the moon? since I am building a texture pack.

Posted: Mon Feb 11, 2013 17:50
by VanessaE
You can't. Those are not currently texturable.

Posted: Mon Feb 11, 2013 17:50
by lkjoel
VanessaE wrote:You can't. Those are not currently texturable.
Wouldn't it be about time to send a pull request then?

Posted: Mon Feb 11, 2013 18:05
by Likwid H-Craft
Oh why they not then how come, they box looking but texture zero.
Yeah what have a pull request.

Posted: Mon Feb 11, 2013 18:07
by lkjoel
Likwid H-Craft wrote:Oh why they not then how come, they box looking but texture zero.
Yeah what have a pull request.
I'm not sure what you are talking about, but if you are wondering how minetest does it, it's a hardcoded rendering.

Posted: Mon Feb 11, 2013 18:09
by Likwid H-Craft
Well, I hope on 0.4.5 we have the rights to change the moon and, sun and have add something minecraft don't have.

Posted: Mon Feb 11, 2013 18:10
by lkjoel
Likwid H-Craft wrote:Well, I hope on 0.4.5 we have the rights to change the moon and, sun and have add something minecraft don't have.
Maybe you could file an issue (under the "enhancement" tag) to the minetest github page?

Posted: Mon Feb 11, 2013 18:24
by Likwid H-Craft

Posted: Mon Feb 11, 2013 18:49
by VanessaE
A texturable sun/moon would be nice, and has been discussed before. The result of that discussion was that it would be somewhat non-trivial to do, namely because of the color-shifting that would need to be applied to the two as they rise/set.

Posted: Mon Feb 11, 2013 20:43
by pandaro
I can understand the other functions but not this:
on_blast = func(pos, intensity),
^ intensity: 1.0 = mid range of regular TNT
^ If defined, called when an explosion touches the node, instead of
removing the node
--how to a block NOT explode?
-how to calibrate the power of a explosion
I use TNT PilzAdam, I would like:
-a block does not explode,
-one explode if the explosion occurs at a short distance (1)
-and another block if the distance is greater, however, explodes (2 blocks away)

when I call this function what it does exactly?
where it needs to be made for it to work properly?

Posted: Thu Feb 14, 2013 15:27
by pandaro

Code: Select all

local print_hello=function()
  print("hello")
end
local dtime=10.0
minetest.register_globalstep(function(dtime)
  hello()
end)
Seeking a way to update a formspec.
I will not clog up the engine by calling a function every 0.5sec or less.
Is there a way to enlarge dtime? what I posted does not seem to run.

Posted: Thu Feb 14, 2013 15:40
by Casimir
Just a guess, there might be a better solution.

Code: Select all

minetest.register_globalstep(function(dtime)
   ifnot time then time = dtime end
   if time >= 10 then
      hello()
      time = 0
   end
   time = time + dtime
end

Posted: Thu Feb 14, 2013 17:35
by pandaro
Casimir wrote:Just a guess, there might be a better solution.

Code: Select all

minetest.register_globalstep(function(dtime)
   ifnot time then time = dtime end
   if time >= 10 then
      hello()
      time = 0
   end
   time = time + dtime
end
it works, thanks

Posted: Fri Feb 15, 2013 02:26
by Evergreen
I have a question about stairs and slabs. I'm making a birch tree mod, and I need to make stairs and slabs from it. Here is the code I used to add stairs and slabs:

Code: Select all

stairs.register_stair_and_slab("birch", "birch:wood",
        {cracky=3},
        {"birch_wood.png"},
        "Birch Wood stair",
        "Birch Wood slab")
But I get a run error. How do I fix?

Posted: Fri Feb 15, 2013 02:29
by 0gb.us
Evergreen wrote:I have a question about stairs and slabs. I'm making a birch tree mod, and I need to make stairs and slabs from it. Here is the code I used to add stairs and slabs:

Code: Select all

stairs.register_stair_and_slab("birch", "birch:wood",
        {cracky=3},
        {"birch_wood.png"},
        "Birch Wood stair",
        "Birch Wood slab")
But I get a run error. How do I fix?
The error is caused by a bug in the stable version of stairs. Copy the code in stars and change the prefix "Stairs:" to the prefix for your plugin.

Posted: Fri Feb 15, 2013 12:38
by Evergreen
0gb.us wrote:
Evergreen wrote:I have a question about stairs and slabs. I'm making a birch tree mod, and I need to make stairs and slabs from it. Here is the code I used to add stairs and slabs:

Code: Select all

stairs.register_stair_and_slab("birch", "birch:wood",
        {cracky=3},
        {"birch_wood.png"},
        "Birch Wood stair",
        "Birch Wood slab")
But I get a run error. How do I fix?
The error is caused by a bug in the stable version of stairs. Copy the code in stars and change the prefix "Stairs:" to the prefix for your plugin.
Thanks 0gb.us! :D

Posted: Fri Feb 15, 2013 13:41
by Evergreen
Still get a ModError.

I stuck this code inside the same init.lua

Code: Select all

stairs = {}

function birch.register_stair(subname, recipeitem, groups, images, description)
    minetest.register_node("stairs:stair_" .. subname, {
        description = description,
        drawtype = "nodebox",
        tiles = images,
        paramtype = "light",
        paramtype2 = "facedir",
        is_ground_content = true,
        groups = groups,
        node_box = {
            type = "fixed",
            fixed = {
                {-0.5, -0.5, -0.5, 0.5, 0, 0.5},
                {-0.5, 0, 0, 0.5, 0.5, 0.5},
            },
        },
    })

    minetest.register_craft({
        output = 'stairs:stair_' .. subname .. ' 4',
        recipe = {
            {recipeitem, "", ""},
            {recipeitem, recipeitem, ""},
            {recipeitem, recipeitem, recipeitem},
        },
    })

    -- Flipped recipe for the silly minecrafters
    minetest.register_craft({
        output = 'stairs:stair_' .. subname .. ' 4',
        recipe = {
            {"", "", recipeitem},
            {"", recipeitem, recipeitem},
            {recipeitem, recipeitem, recipeitem},
        },
    })
end

-- Node will be called stairs:slab_<subname>
function birch.register_slab(subname, recipeitem, groups, images, description)
    minetest.register_node("stairs:slab_" .. subname, {
        description = description,
        drawtype = "nodebox",
        tiles = images,
        paramtype = "light",
        is_ground_content = true,
        groups = groups,
        node_box = {
            type = "fixed",
            fixed = {-0.5, -0.5, -0.5, 0.5, 0, 0.5},
        },
        selection_box = {
            type = "fixed",
            fixed = {-0.5, -0.5, -0.5, 0.5, 0, 0.5},
        },
        on_place = function(itemstack, placer, pointed_thing)
            if pointed_thing.type ~= "node" then
                return itemstack
            end

            -- If it's being placed on an another similar one, replace it with
            -- a full block
            local slabpos = nil
            local slabnode = nil
            local p0 = pointed_thing.under
            local p1 = pointed_thing.above
            local n0 = minetest.env:get_node(p0)
            if n0.name == "stairs:slab_" .. subname and
                    p0.y+1 == p1.y then
                slabpos = p0
                slabnode = n0
            end
            if slabpos then
                -- Remove the slab at slabpos
                minetest.env:remove_node(slabpos)
                -- Make a fake stack of a single item and try to place it
                local fakestack = ItemStack(recipeitem)
                pointed_thing.above = slabpos
                fakestack = minetest.item_place(fakestack, placer, pointed_thing)
                -- If the item was taken from the fake stack, decrement original
                if not fakestack or fakestack:is_empty() then
                    itemstack:take_item(1)
                -- Else put old node back
                else
                    minetest.env:set_node(slabpos, slabnode)
                end
                return itemstack
            end
            
            -- Otherwise place regularly
            return minetest.item_place(itemstack, placer, pointed_thing)
        end,
    })

    minetest.register_craft({
        output = 'stairs:slab_' .. subname .. ' 3',
        recipe = {
            {recipeitem, recipeitem, recipeitem},
        },
    })
end

-- Nodes will be called stairs:{stair,slab}_<subname>
function birch.register_stair_and_slab(subname, recipeitem, groups, images, desc_stair, desc_slab)
    birch.register_stair(subname, recipeitem, groups, images, desc_stair)
    birch.register_slab(subname, recipeitem, groups, images, desc_slab)
end

birch.register_stair_and_slab("birch", "birch:wood",
        {snappy=2,choppy=2,oddly_breakable_by_hand=2},
        {"birch_wood.png"},
        "Birch Wood stair",
        "Birch Wood slab")
What am I doing wrong?

Posted: Fri Feb 15, 2013 20:48
by pandaro
there a way(automatic) to update (refresh) an opened formspec?(without pressing buttons)

Posted: Fri Feb 15, 2013 21:06
by stu
Is there any way to catch when a player takes a hit, either from an entity or from another player?

Something like: entity.on_punch = function(self, puncher) ... but for players.

Posted: Fri Feb 15, 2013 21:42
by Evergreen
Evergreen wrote:Still get a ModError.

I stuck this code inside the same init.lua

Code: Select all

stairs = {}

function birch.register_stair(subname, recipeitem, groups, images, description)
    minetest.register_node("stairs:stair_" .. subname, {
        description = description,
        drawtype = "nodebox",
        tiles = images,
        paramtype = "light",
        paramtype2 = "facedir",
        is_ground_content = true,
        groups = groups,
        node_box = {
            type = "fixed",
            fixed = {
                {-0.5, -0.5, -0.5, 0.5, 0, 0.5},
                {-0.5, 0, 0, 0.5, 0.5, 0.5},
            },
        },
    })

    minetest.register_craft({
        output = 'stairs:stair_' .. subname .. ' 4',
        recipe = {
            {recipeitem, "", ""},
            {recipeitem, recipeitem, ""},
            {recipeitem, recipeitem, recipeitem},
        },
    })

    -- Flipped recipe for the silly minecrafters
    minetest.register_craft({
        output = 'stairs:stair_' .. subname .. ' 4',
        recipe = {
            {"", "", recipeitem},
            {"", recipeitem, recipeitem},
            {recipeitem, recipeitem, recipeitem},
        },
    })
end

-- Node will be called stairs:slab_<subname>
function birch.register_slab(subname, recipeitem, groups, images, description)
    minetest.register_node("stairs:slab_" .. subname, {
        description = description,
        drawtype = "nodebox",
        tiles = images,
        paramtype = "light",
        is_ground_content = true,
        groups = groups,
        node_box = {
            type = "fixed",
            fixed = {-0.5, -0.5, -0.5, 0.5, 0, 0.5},
        },
        selection_box = {
            type = "fixed",
            fixed = {-0.5, -0.5, -0.5, 0.5, 0, 0.5},
        },
        on_place = function(itemstack, placer, pointed_thing)
            if pointed_thing.type ~= "node" then
                return itemstack
            end

            -- If it's being placed on an another similar one, replace it with
            -- a full block
            local slabpos = nil
            local slabnode = nil
            local p0 = pointed_thing.under
            local p1 = pointed_thing.above
            local n0 = minetest.env:get_node(p0)
            if n0.name == "stairs:slab_" .. subname and
                    p0.y+1 == p1.y then
                slabpos = p0
                slabnode = n0
            end
            if slabpos then
                -- Remove the slab at slabpos
                minetest.env:remove_node(slabpos)
                -- Make a fake stack of a single item and try to place it
                local fakestack = ItemStack(recipeitem)
                pointed_thing.above = slabpos
                fakestack = minetest.item_place(fakestack, placer, pointed_thing)
                -- If the item was taken from the fake stack, decrement original
                if not fakestack or fakestack:is_empty() then
                    itemstack:take_item(1)
                -- Else put old node back
                else
                    minetest.env:set_node(slabpos, slabnode)
                end
                return itemstack
            end
            
            -- Otherwise place regularly
            return minetest.item_place(itemstack, placer, pointed_thing)
        end,
    })

    minetest.register_craft({
        output = 'stairs:slab_' .. subname .. ' 3',
        recipe = {
            {recipeitem, recipeitem, recipeitem},
        },
    })
end

-- Nodes will be called stairs:{stair,slab}_<subname>
function birch.register_stair_and_slab(subname, recipeitem, groups, images, desc_stair, desc_slab)
    birch.register_stair(subname, recipeitem, groups, images, desc_stair)
    birch.register_slab(subname, recipeitem, groups, images, desc_slab)
end

birch.register_stair_and_slab("birch", "birch:wood",
        {snappy=2,choppy=2,oddly_breakable_by_hand=2},
        {"birch_wood.png"},
        "Birch Wood stair",
        "Birch Wood slab")
What am I doing wrong?
Nvm, I fixed it.

Posted: Sat Feb 16, 2013 11:36
by Evergreen
Now I have another question. Is the function math.random part of minetest?

Posted: Sat Feb 16, 2013 11:43
by PilzAdam
Evergreen wrote:Now I have another question. Is the function math.random part of minetest?
No, its part of Lua.

Posted: Sat Feb 16, 2013 12:15
by Evergreen
PilzAdam wrote:
Evergreen wrote:Now I have another question. Is the function math.random part of minetest?
No, its part of Lua.
Thanks