Sign questions

Gatharoth
Member
 
Posts: 196
Joined: Thu Dec 22, 2011 02:54

Sign questions

by Gatharoth » Mon Mar 19, 2012 20:33

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?
 

randomproof
Member
 
Posts: 214
Joined: Thu Nov 17, 2011 06:31

by randomproof » Mon Mar 19, 2012 22:25

only if metadata_name = "sign" in the node def
 

Gatharoth
Member
 
Posts: 196
Joined: Thu Dec 22, 2011 02:54

by Gatharoth » Mon Mar 19, 2012 22:34

Hmm... So no way to make it a one time usage?
 

randomproof
Member
 
Posts: 214
Joined: Thu Nov 17, 2011 06:31

by randomproof » Mon Mar 19, 2012 23:01

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)
 

Gatharoth
Member
 
Posts: 196
Joined: Thu Dec 22, 2011 02:54

by Gatharoth » Mon Mar 19, 2012 23:10

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.
 


Return to WIP Mods

Who is online

Users browsing this forum: No registered users and 14 guests