[phpBB Debug] PHP Warning: in file [ROOT]/includes/functions.php on line 4866: Undefined array key "database_gc"
FOSS gamedev and creative worlds • View topic - problem: formspec, rightclick and on_receive_fields
Page 1 of 1

problem: formspec, rightclick and on_receive_fields

PostPosted: Sun Jul 29, 2012 16:28
by RealBadAngel
It can b easily made to right click and have input text form for any object. Like sign or teleport pad[mod].
But i do need to call that input function directly, because right click option is already occupied (and there's no shift_right_click)
I want to have on_punch and within it call the input form.
Was foolin around a bit and havent found a solution. Could just dig the source, but maybe someone already knows the straight answer? function name and parameters :)

Edit: i found a solution, is workin, but not so elegant i think....

on_punch = function (pos, node, puncher)
local meta = minetest.env:get_meta(pos);
meta:set_string("formspec", "hack:sign_text_input")
end,

on_receive_fields = function(pos, formname, fields, sender)
local meta = minetest.env:get_meta(pos);
fields.text = fields.text or ""
meta:set_string("text", fields.text)
meta:set_string("infotext", '"'..fields.text..'"')

meta:set_string("formspec",
"invsize[12,9;]"..
"list[current_name;main;0,0;12,4;]"..
"list[current_player;main;0,5;8,4;]")
end,

After a node is punched i change formspec to be sign like. Next right click will pop up input form, and after receive i restore original formspec of the object (chest in this example).

this is how it works:
http://www.youtube.com/watch?v=FN3sbRsOYWo&feature=youtu.be
Anybody with another idea/solution?

PostPosted: Mon Jul 30, 2012 00:11
by cornernote
Cool idea!

Another way to do it would be to use a certain type of item when hitting it.

PostPosted: Mon Jul 30, 2012 07:36
by RealBadAngel
cornernote wrote:Cool idea!

Another way to do it would be to use a certain type of item when hitting it.


That way im using already to mark chests with colors. Hitting them with dye in hand.