Page 1 of 1

Sign questions

PostPosted: Mon Mar 19, 2012 20:33
by Gatharoth
Alright, so I'm trying to update my AND gate for mesecon, to allow the player to set the amount of connections needed to power it. So in order to do this, I was thinking about adding in that text input window you get when you rightclick a sign, and use that for playing to input a number.

Alright so is there a way to get that text input window to pop up without setting the metadata name to sign?

I was looking at the default init.lua and say these two pieces of code.

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
allows_text_input()
set_allow_text_input(bool)


So with a combination of these and others, is it possible to make the text input window to come up?

PostPosted: Mon Mar 19, 2012 22:25
by randomproof
only if metadata_name = "sign" in the node def

PostPosted: Mon Mar 19, 2012 22:34
by Gatharoth
Hmm... So no way to make it a one time usage?

PostPosted: Mon Mar 19, 2012 23:01
by randomproof
Could you do something like cycling the number each time it is punched?

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_on_punchnode(function(pos, node, puncher)
    if node.name == "node_name" then
        -- Check to see if hit by hand (not sure if this works)
        if puncher:get_wielded_item():get_tool_capabilities().groupcaps[oddly_breakable_by_hand] == nil then
            return
        end

        local meta = minetest.env:get_meta(pos)
        local connections_needed_distance = tonumber(meta:get_string("connections_needed"))
        if connections_needed < max_connections then
            connections_needed = connections_needed + 1
        else
            connections_needed = min_connections
        end

        -- Do any updates related to change in connections here
    end
end)

PostPosted: Mon Mar 19, 2012 23:10
by Gatharoth
randomproof wrote:Could you do something like cycling the number each time it is punched?

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_on_punchnode(function(pos, node, puncher)
    if node.name == "node_name" then
        -- Check to see if hit by hand (not sure if this works)
        if puncher:get_wielded_item():get_tool_capabilities().groupcaps[oddly_breakable_by_hand] == nil then
            return
        end

        local meta = minetest.env:get_meta(pos)
        local connections_needed_distance = tonumber(meta:get_string("connections_needed"))
        if connections_needed < max_connections then
            connections_needed = connections_needed + 1
        else
            connections_needed = min_connections
        end

        -- Do any updates related to change in connections here
    end
end)


Yeah I guess I could just do that >.< XD didn't think of that lol. Will probably use this, and set the info_text to the current number of connections needed.