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

problem: formspec, rightclick and on_receive_fields

User avatar
RealBadAngel
Member
 
Posts: 556
Joined: Wed Jul 18, 2012 16:30

problem: formspec, rightclick and on_receive_fields

by RealBadAngel » Sun Jul 29, 2012 16:28

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?
Last edited by RealBadAngel on Sun Jul 29, 2012 18:53, edited 1 time in total.
 

cornernote
Member
 
Posts: 844
Joined: Wed Jul 11, 2012 15:02

by cornernote » Mon Jul 30, 2012 00:11

Cool idea!

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

User avatar
RealBadAngel
Member
 
Posts: 556
Joined: Wed Jul 18, 2012 16:30

by RealBadAngel » Mon Jul 30, 2012 07:36

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.
 


Return to WIP Mods

Who is online

Users browsing this forum: No registered users and 39 guests

cron