Can i change node texture?with node func

Post Reply
owlondrugs
Member
Posts: 35
Joined: Sun Jul 23, 2017 12:53
In-game: Owlondrugs

Can i change node texture?with node func

by owlondrugs » Post

Code: Select all

minetest.register_node("tabaco_mod:Drying_Rack", {
    description = "Drying Rac",
    drawtype = "Normal",
        tiles = {
        "drying_rack_top.png",    -- y+
        "drying_rack_top.png",  -- y-
        "drying_rack.png", -- x+
        "drying_rack.png",  -- x-
        "drying_rack.png",  -- z+
        "drying_rack.png", -- z-
    },
    is_ground_content = false,
    sounds = default.node_sound_wood_defaults(),
    groups = {cracky=3,oddly_breakable_by_hand=3},
    on_construct = function(pos)
    local meta = minetest.get_meta(pos)
    meta:set_string("infotext", "Drying Rack");
    meta:set_string("formspec",
        "size[8,7.5]"..
        "list[context;input;0,0;1,1;]"..
        "list[current_player;main;0,3.5;8,4;]")
    local inv = meta:get_inventory()
    inv:set_size("input",1)
    end,
    --on_rightclick = function(pos, node, name)
    -- local meta = minetest.get_meta(pos)
    --local name = clicker:get_name()
    --minetest.show_formspec(name,meta:get_string("Drying Rack"), meta:get_string("formspec"))
    --end,
    on_receive_fields = function(pos, formname, fields, player)
        local meta = minetest.get_meta(pos)
        local node = minetest.get_node(pos)
        local inv = meta:get_inventory()
        local instack = inv:get_stack("input",1)
        local input = instack:get_name()
        local timer = minetest.get_node_timer(pos)
        if input == "tabaco_mod:Tobaco_Leaf" then
            timer:start(10)
            node:tiles({
        "drying_rack_top.png",    -- y+
        "drying_rack_top.png",  -- y-
        "drying_rack_green_leaf.png", -- x+
        "drying_rack_green_leaf.png",  -- x-
        "drying_rack_green_leaf.png",  -- z+
        "drying_rack_green_leaf.png", -- z-
    })
        elseif input == 0 then
         timer:stop()
        end
    end,
    on_timer = function(pos)
        local meta = minetest.get_meta(pos)
        local inv = meta:get_inventory()
        local instack = inv:get_stack("input",1)
        local input = instack:get_name()
        if input == "tabaco_mod:Tobaco_Leaf" then
            inv:set_stack("input",1,"tabaco_mod:Dryed_leaf")
        end
    end,
})
Attachments
drying_rack_green_leaf.png
drying_rack_green_leaf.png (301 Bytes) Viewed 305 times
drying_rack.png
drying_rack.png (211 Bytes) Viewed 305 times

User avatar
Nathan.S
Member
Posts: 1147
Joined: Wed Sep 24, 2014 17:47
GitHub: NathanSalapat
IRC: NathanS21
In-game: NathanS21
Location: Bigsby Texas
Contact:

Re: Can i change node texture?with node func

by Nathan.S » Post

You can't change the node texture, but you could change the texture of an entity. If you only have two texture variants you could make a second node with the other texture and swap them back and forth. The furnace from MTG does that.
I record Minetest videos, Mod reviews, Modding tutorials, and Lets plays.
Check out my website, and brand new Minetest Modding Course

owlondrugs
Member
Posts: 35
Joined: Sun Jul 23, 2017 12:53
In-game: Owlondrugs

Re: Can i change node texture?with node func

by owlondrugs » Post

Ty...Oh...I had a similar idea, but how do I pass the meta to another block?

Pixet Bits
New member
Posts: 2
Joined: Fri May 15, 2020 20:43
GitHub: PixetBits
IRC: PixetBits
In-game: PixetBits

Re: Can i change node texture?with node func

by Pixet Bits » Post

owlondrugs wrote:
Wed Apr 01, 2020 16:58
Ty...Oh...I had a similar idea, but how do I pass the meta to another block?
Use the minetest.swap_node method to change the node and maintain the metadata

Post Reply

Who is online

Users browsing this forum: No registered users and 12 guests