Need Help In Mod Development

User avatar
IPushButton2653
Member
 
Posts: 666
Joined: Wed Nov 16, 2011 22:47

Need Help In Mod Development

by IPushButton2653 » Mon Feb 20, 2012 00:38

I am working on a few mods, and I was wondering if there was a way to do some of this:

-----When you dig a chest/furnace, is there a way to make it drop it's contents? Like they appear on the ground where the node was, or it go into your inventory
-----Any GUI modifications for chests/furnaces?
-----Any simple way to make a chest use multiple nodes to work?
-----Any way to restrict a chest/furnace to be opened only by one person at a time?
-----Any way to keep people from looking in a locked chest?

Thanks if you have any answers. I know I could look through the forums, but it takes too much time on my part.

Also, if anyone can help me find my problem in this code, I'd be thankful. (looked in debug and it didn't help)
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
minetest.register_node("obsidiansidian:obsidiansidian_block", {
    tile_images = {"obsidiansidian_block.png"},
    inventory_image =

minetest.inventorycube("obsidiansidian_block.png"),
    is_ground_content = true,
    material = minetest.digprop_glasslike

(5.0), -- obsidiansidian is hard, but brittle
    extra_dug_item = 'craft "obsidiansidian:obsidiansidian_shard" 1',
   

extra_dug_item_rarity = 20,
})

minetest.register_craftitem("obsidiansidian:obsidiansidian_shard", {
    image =

"obsidiansidian_shard.png",
    on_place_on_ground = craftitem_place_item,
})

minetest.register_craft({
    output = 'tool

"obsidiansidian:obsidiansidian_knife"',
    recipe = {
        {'craft "obsidiansidian:obsidiansidian_shard"'},
       

{'craft "default:Stick"'},
    }
})

minetest.register_tool("obsidiansidian:obsidiansidian_knife", {
    image =

"obsidiansidian_knife.png",
    basetime = 1.0,
    dt_weight = 0.5,
    dt_crackiness = 2,
    dt_crumbliness = 4,
   

dt_cuttability = -0.5,
    basedurability = 80,
    dd_weight = 0,
    dd_crackiness = 0,
    dd_crumbliness = 0,
    dd_cuttability =

0,
})

minetest.register_abm(
{nodenames = {"default:lava_source"},
interval = 1.0,
chance = 1,
action = function(pos, node,

active_obsidianject_count, active_obsidianject_count_wider)
    for i=-1,1 do
        for j=-1,1 do
            for k=-

1,1 do
                p = {x=pos.x+i, y=pos.y+j, z=pos.z+k}
                n = minetest.env:get_node(p)
       

        if (n.name=="default:water_flowing") or (n.name == "default:water_source") then
                   

minetest.env:add_node(pos, {name="obsidiansidian:obsidiansidian_block"})
                end
           

end
        end
    end
end
})

minetest.register_abm(
{nodenames = {"default:lava_flowing"},
interval = 1.0,
chance = 1,
action =

function(pos, node, active_obsidianject_count, active_obsidianject_count_wider)
    for i=-1,1 do
        for j=-1,1 do
           

for k=-1,1 do
                p = {x=pos.x+i, y=pos.y+j, z=pos.z+k}
                n =

minetest.env:get_node(p)
                if (n.name=="default:water_flowing") or (n.name ==

"default:water_source") then
                    if (j==-1) then
                       

minetest.env:add_node({x=pos.x, y=pos.y-1, z=pos.z}, {name="cobsidianble"})
                    else
           

            minetest.env:add_node(pos, {name="cobsidianble"})
                    end
           

    end
            end
        end
    end
end
})


-- Crafting

minetest.register_craft({
    output = 'tool "obsidian:obsidian_sword"',
    recipe = {
        {'node "obsidian:obsidian_block"'},
        {'node "obsidian:obsidian_block"'},
        {'craft "default:stick"'},
    }
})
minetest.register_craft({
    output = 'tool "obsidian:obsidian_axe"',
    recipe = {
        {'node "obsidian:obsidian_block"', 'node "obsidian:obsidian_block"'},
        {'node "obsidian:obsidian_block"', 'craft "default:stick"'},
        {'', 'craft "default:stick"'},
    }
})
minetest.register_craft({
    output = 'tool "obsidian:obsidian_shovel"',
    recipe = {
        {'node "obsidian:obsidian_block"'},
        {'craft "default:stick"'},
        {'craft "default:stick"'},
    }
})
minetest.register_craft({
    output = 'tool "obsidian:obsidian_pick"',
    recipe = {
        {'node "obsidian:obsidian_block"', 'node "obsidian:obsidian_block"', 'node "obsidian:obsidian_block"'},
        {'', 'craft "default:stick"', ''},
        {'', 'craft "default:stick"', ''},
    }
})




-- tools
minetest.register_tool("obsidian:obsidian_sword", {
    image = "os.png",
    basetime = 0,
    dt_weight = 3,
    dt_crackiness = 0,
    dt_crumbliness = 1,
    dt_cuttability = -10,
    basedurability = 1000,
    dd_weight = 0,
    dd_crackiness = 0,
    dd_crumbliness = 0,
    dd_cuttability = 0,
})
minetest.register_tool("obsidian:obsidian_shovel", {
    image = "osh.png",
    basetime = 0,
    dt_weight = 0.5,
    dt_crackiness = 2,
    dt_crumbliness = -1.5,
    dt_cuttability = 0.0,
    basedurability = 330,
    dd_weight = 0,
    dd_crackiness = 0,
    dd_crumbliness = 0,
    dd_cuttability = 0,
})
minetest.register_tool("obsidian:obsidian_pick", {
    image = "op.png",
    basetime = 0,
    dt_weight = 0,
    dt_crackiness = -0.5,
    dt_crumbliness = 2,
    dt_cuttability = 0,
    basedurability = 333,
    dd_weight = 0,
    dd_crackiness = 0,
    dd_crumbliness = 0,
    dd_cuttability = 0,
})
minetest.register_tool("obsidian:obsidian_axe", {
    image = "ob.png",
    basetime = 0,
    dt_weight = 3,
    dt_crackiness = 0,
    dt_crumbliness = 1,
    dt_cuttability = -10,
    basedurability = 1000,
    dd_weight = 0,
    dd_crackiness = 0,
    dd_crumbliness = 0,
    dd_cuttability = 0,
})



--        end
--        return false
--    end,
--
Last edited by IPushButton2653 on Mon Feb 20, 2012 00:56, edited 1 time in total.
 

kahrl
Member
 
Posts: 236
Joined: Fri Sep 02, 2011 07:51

by kahrl » Mon Feb 20, 2012 01:27

Regarding the node metadata (chest) stuff, most of it isn't possible. I'm going to rewrite the node metadata system soon, but I'm not sure whether it will be possible to support the things you're asking for:

IPushButton2653 wrote:-----When you dig a chest/furnace, is there a way to make it drop it's contents? Like they appear on the ground where the node was, or it go into your inventory

Not possible currently.

Would this be a good idea at all? I mean, given how the dropped items work in minetest? In minecraft this works because you can just walk over the dropped items and they go into your inventory. In minetest you'd have to click each item.

Directly putting the items into the player's inventory wouldn't work either because it might already be full. And losing the items that don't fit doesn't sound good at all.

IPushButton2653 wrote:-----Any GUI modifications for chests/furnaces?

No, but I will add simple textbox-based forms. What are you looking for specifically?

IPushButton2653 wrote:-----Any simple way to make a chest use multiple nodes to work?

Not sure what you mean by that.

IPushButton2653 wrote:-----Any way to restrict a chest/furnace to be opened only by one person at a time?

No, opening a chest is completely client side, the server (and other players) don't get notified at all. Only when you try to move an item an inventory action request is sent.

IPushButton2653 wrote:-----Any way to keep people from looking in a locked chest?

No. Clients always receive the complete node metadata in any case, so any client side peeking prevention would be pointless (people could just use a modified client). Theoretically the system could be changed so that the inventory is only transferred once the player tries to look at the chest's contents, but that would introduce even more annoying lag.


About the code you posted, without having looked at it, what is actually the error / problem? It also seems you're using pre-itemdef (20120122) syntax, it that intentional? If you want I can update the deprecated things.
Last edited by kahrl on Mon Feb 20, 2012 01:28, edited 1 time in total.
 

User avatar
IPushButton2653
Member
 
Posts: 666
Joined: Wed Nov 16, 2011 22:47

by IPushButton2653 » Mon Feb 20, 2012 01:35

On the GUI, I'm just looking for text/slot formatting. (For sections)

And on the code, I think I know what went wrong. When I posted it in the codepad, I noticed that some of the code got word wrapped. If that doesn't fix it, I'll be back
 

kahrl
Member
 
Posts: 236
Joined: Fri Sep 02, 2011 07:51

by kahrl » Tue Feb 21, 2012 00:38

Depending on what you want to do with the GUI I might be able to make it possible. Can you make a simple mockup?
 


Return to WIP Mods

Who is online

Users browsing this forum: No registered users and 13 guests

cron