Hello . I have this :
minetest.show_formspec(name,"beds:sleep_time","size[4,3]" ..
"label[0,0;Sleep time:]" ..
"button_exit[0,1;1,1;name;1]" ..
"button_exit[1,1;1,1;name;2]" ..
"button_exit[2,1;1,1;name;3]" ..
"button_exit[3,1;1,1;name;4]" ..
"button_exit[0,2;1,1;name;5]" ..
"button_exit[1,2;1,1;name;6]" ..
"button_exit[2,2;1,1;name;7]" ..
"button_exit[3,2;1,1;name;8]" )
end
And
minetest.register_on_player_receive_fields(function(player, formname, fields)
if forname ~= "beds:sleep_time" then
minetest.chat_send_player(player:get_player_name(), "Formname: " .. formname)
return false
end
day_time = minetest.get_timeofday() * 24000
if fields.name == "1" then
day_time = day_time+1000
elseif fields.name == "2" then
day_time = day_time+2000
elseif fields.name == "3" then
day_time = day_time+3000
elseif fields.name == "4" then
day_time = day_time+4000
elseif fields.name == "5" then
day_time = day_time+5000
elseif fields.name == "6" then
day_time = day_time+6000
elseif fields.name == "7" then
day_time = day_time+7000
elseif fields.name == "8" then
day_time = day_time+8000
else
minetest.chat_send_player(player:get_player_name(),"Guess I am not going to sleep now ..")
beds.kick_players()
return true
end
day_time = day_time / 24000
if day_time > 1.0 then
day_time = 0.2
end
-- skip the night and let all players stand up
if check_in_beds() then
minetest.after(2, function()
if not is_sp then
update_formspecs(is_night_skip_enabled())
end
if is_night_skip_enabled() then
beds.set_time(day_time)
beds.kick_players()
end
end)
end
return true
end)
The problem is with the check if the formname is equal to the defined one . When the check is run it prints out the correct name declared but this shoud be printed when its not equal