HUDs, hunger, mobs, mapgen, splash, mainmemu etc

This commit is contained in:
4aiman 2015-07-01 12:27:28 +03:00
parent 199791af33
commit a2784b58bf
38 changed files with 554 additions and 394 deletions

View File

@ -42,6 +42,9 @@ local function add_server_formspec(dialogdata)
end end
local function add_server_buttonhandler(this, fields) local function add_server_buttonhandler(this, fields)
core.set_clouds(false)
core.set_background("background",core.formspec_escape(mm_texture.basetexturedir)..'background.png')
core.set_background("header",core.formspec_escape(mm_texture.basetexturedir)..'header.png')
if fields["server_add_cancel"] then if fields["server_add_cancel"] then
this:delete() this:delete()

View File

@ -119,6 +119,9 @@ end
local function handle_buttons(this, fields) local function handle_buttons(this, fields)
core.set_clouds(false)
core.set_background("background",core.formspec_escape(mm_texture.basetexturedir)..'background.png')
core.set_background("header",core.formspec_escape(mm_texture.basetexturedir)..'header.png')
if fields["world_config_modlist"] ~= nil then if fields["world_config_modlist"] ~= nil then
local event = core.explode_textlist_event(fields["world_config_modlist"]) local event = core.explode_textlist_event(fields["world_config_modlist"])

View File

@ -83,6 +83,9 @@ local function create_world_formspec(dialogdata)
end end
local function create_world_buttonhandler(this, fields) local function create_world_buttonhandler(this, fields)
core.set_clouds(false)
core.set_background("background",core.formspec_escape(mm_texture.basetexturedir)..'background.png')
core.set_background("header",core.formspec_escape(mm_texture.basetexturedir)..'header.png')
if fields["world_create_cancel"] then if fields["world_create_cancel"] then
this:delete() this:delete()

View File

@ -35,6 +35,10 @@ end
-------------------------------------------------------------------------------- --------------------------------------------------------------------------------
local function delete_mod_buttonhandler(this, fields) local function delete_mod_buttonhandler(this, fields)
core.set_clouds(false)
core.set_background("background",core.formspec_escape(mm_texture.basetexturedir)..'background.png')
core.set_background("header",core.formspec_escape(mm_texture.basetexturedir)..'header.png')
if fields["dlg_delete_mod_confirm"] ~= nil then if fields["dlg_delete_mod_confirm"] ~= nil then
if this.data.mod.path ~= nil and if this.data.mod.path ~= nil and

View File

@ -31,22 +31,23 @@ local function delete_world_formspec(dialogdata)
end end
local function delete_world_buttonhandler(this, fields) local function delete_world_buttonhandler(this, fields)
core.set_clouds(false)
core.set_background("background",core.formspec_escape(mm_texture.basetexturedir)..'background.png')
core.set_background("header",core.formspec_escape(mm_texture.basetexturedir)..'header.png')
if fields["world_delete_confirm"] then if fields["world_delete_confirm"] then
if this.data.delete_index > 0 and
if this.data.delete_index > 0 and this.data.delete_index <= #menudata.worldlist:get_raw_list() then
this.data.delete_index <= #menudata.worldlist:get_raw_list() then core.delete_world(this.data.delete_index)
core.delete_world(this.data.delete_index) menudata.worldlist:refresh()
menudata.worldlist:refresh() end
end this:delete()
this:delete() return true
return true
end end
if fields["world_delete_cancel"] then if fields["world_delete_cancel"] then
this:delete() this:delete()
return true return true
end end
return false return false
end end

View File

@ -37,6 +37,10 @@ end
-------------------------------------------------------------------------------- --------------------------------------------------------------------------------
local function rename_modpack_buttonhandler(this, fields) local function rename_modpack_buttonhandler(this, fields)
core.set_clouds(false)
core.set_background("background",core.formspec_escape(mm_texture.basetexturedir)..'background.png')
core.set_background("header",core.formspec_escape(mm_texture.basetexturedir)..'header.png')
if fields["dlg_rename_modpack_confirm"] ~= nil then if fields["dlg_rename_modpack_confirm"] ~= nil then
local oldpath = core.get_modpath() .. DIR_DELIM .. this.data.mod.name local oldpath = core.get_modpath() .. DIR_DELIM .. this.data.mod.name
local targetpath = core.get_modpath() .. DIR_DELIM .. fields["te_modpack_name"] local targetpath = core.get_modpath() .. DIR_DELIM .. fields["te_modpack_name"]

View File

@ -79,6 +79,10 @@ end
-------------------------------------------------------------------------------- --------------------------------------------------------------------------------
local function main_button_handler2(tabview, fields, name, tabdata) local function main_button_handler2(tabview, fields, name, tabdata)
core.set_clouds(false)
core.set_background("background",core.formspec_escape(mm_texture.basetexturedir)..'background.png')
core.set_background("header",core.formspec_escape(mm_texture.basetexturedir)..'header.png')
local index = '' local index = ''
if fields["btn_show_singleplayer"] then index = "singleplayer" end if fields["btn_show_singleplayer"] then index = "singleplayer" end
if fields["btn_show_multiplayer"] then index = "multiplayer" end if fields["btn_show_multiplayer"] then index = "multiplayer" end

View File

@ -165,6 +165,10 @@ end
-------------------------------------------------------------------------------- --------------------------------------------------------------------------------
-- @function [parent=#modstore] handle_buttons -- @function [parent=#modstore] handle_buttons
function modstore.handle_buttons(current_tab,fields) function modstore.handle_buttons(current_tab,fields)
core.set_clouds(false)
core.set_background("background",core.formspec_escape(mm_texture.basetexturedir)..'background.png')
core.set_background("header",core.formspec_escape(mm_texture.basetexturedir)..'header.png')
if fields["modstore_tab"] then if fields["modstore_tab"] then
local index = tonumber(fields["modstore_tab"]) local index = tonumber(fields["modstore_tab"])

View File

@ -187,6 +187,10 @@ end
-------------------------------------------------------------------------------- --------------------------------------------------------------------------------
-- @function [parent=#modstore] handle_buttons -- @function [parent=#modstore] handle_buttons
function modstore.handle_buttons(parent, fields, name, data) function modstore.handle_buttons(parent, fields, name, data)
core.set_clouds(false)
core.set_background("background",core.formspec_escape(mm_texture.basetexturedir)..'background.png')
core.set_background("header",core.formspec_escape(mm_texture.basetexturedir)..'header.png')
if fields["btn_modstore_page_up"] then if fields["btn_modstore_page_up"] then
if modstore.current_list ~= nil and modstore.current_list.page > 0 then if modstore.current_list ~= nil and modstore.current_list.page > 0 then

View File

@ -28,8 +28,8 @@ tab_credits = {
"box[-100,-10;200,12;#999999]" .. "box[-100,-10;200,12;#999999]" ..
"image_button[12,9.55;4,0.8;"..core.formspec_escape(mm_texture.basetexturedir).."menu_button.png;btn_cancel;".. fgettext("OK") .. ";true;true;"..core.formspec_escape(mm_texture.basetexturedir).."menu_button_b.png]".. "image_button[12,9.55;4,0.8;"..core.formspec_escape(mm_texture.basetexturedir).."menu_button.png;btn_cancel;".. fgettext("OK") .. ";true;true;"..core.formspec_escape(mm_texture.basetexturedir).."menu_button_b.png]"..
"label[3.5,9.75;Magichet 1.0 (based on FM " .. core.get_version() .. ")]" .. "label[3.5,9.75;Multicraft (" .. core.get_version() .. ")]" ..
"image[0.25,9;2,2;"..core.formspec_escape(logofile).."]".. -- "image[0.25,9;2,2;"..core.formspec_escape(logofile).."]"..
"textlist[0,2.0;15.8,6.25;list_credits;" .. "textlist[0,2.0;15.8,6.25;list_credits;" ..
"#FFFF00" .. fgettext("Core Developers") .."," .. "#FFFF00" .. fgettext("Core Developers") .."," ..
" Perttu Ahola (celeron55) <celeron55@gmail.com>,".. " Perttu Ahola (celeron55) <celeron55@gmail.com>,"..
@ -48,7 +48,7 @@ tab_credits = {
" paramat,".. " paramat,"..
" ...,".. " ...,"..
",".. ","..
"#FFFF00" .. fgettext("Magichet Developers") .. "," .. "#FFFF00" .. fgettext("Multicraft Developers") .. "," ..
" 4aiman Konsorumaniakku <4aiman@inbox.ru>,".. " 4aiman Konsorumaniakku <4aiman@inbox.ru>,"..
" ...,".. " ...,"..
"," .. "," ..
@ -70,6 +70,10 @@ tab_credits = {
";0;true]" ";0;true]"
end, end,
cbf_button_handler = function(tabview, fields, name, tabdata) cbf_button_handler = function(tabview, fields, name, tabdata)
core.set_clouds(false)
core.set_background("background",core.formspec_escape(mm_texture.basetexturedir)..'background.png')
core.set_background("header",core.formspec_escape(mm_texture.basetexturedir)..'header.png')
if fields["btn_cancel"] ~= nil then if fields["btn_cancel"] ~= nil then
tabview:hide() tabview:hide()
tabview.parent:show() tabview.parent:show()

View File

@ -111,6 +111,10 @@ end
-------------------------------------------------------------------------------- --------------------------------------------------------------------------------
local function handle_buttons(tabview, fields, tabname, tabdata) local function handle_buttons(tabview, fields, tabname, tabdata)
core.set_clouds(false)
core.set_background("background",core.formspec_escape(mm_texture.basetexturedir)..'background.png')
core.set_background("header",core.formspec_escape(mm_texture.basetexturedir)..'header.png')
if fields["modlist"] ~= nil then if fields["modlist"] ~= nil then
local event = core.explode_textlist_event(fields["modlist"]) local event = core.explode_textlist_event(fields["modlist"])
tabdata.selected_mod = event.index tabdata.selected_mod = event.index

View File

@ -118,6 +118,10 @@ end
-------------------------------------------------------------------------------- --------------------------------------------------------------------------------
local function main_button_handler(tabview, fields, name, tabdata) local function main_button_handler(tabview, fields, name, tabdata)
core.set_clouds(false)
core.set_background("background",core.formspec_escape(mm_texture.basetexturedir)..'background.png')
core.set_background("header",core.formspec_escape(mm_texture.basetexturedir)..'header.png')
if not tabdata then tabdata = {} end if not tabdata then tabdata = {} end
if fields["add_server"] ~= nil then if fields["add_server"] ~= nil then

View File

@ -77,6 +77,9 @@ end
-------------------------------------------------------------------------------- --------------------------------------------------------------------------------
local function main_button_handler(this, fields, name, tabdata) local function main_button_handler(this, fields, name, tabdata)
core.set_clouds(false)
core.set_background("background",core.formspec_escape(mm_texture.basetexturedir)..'background.png')
core.set_background("header",core.formspec_escape(mm_texture.basetexturedir)..'header.png')
local world_doubleclick = false local world_doubleclick = false
@ -114,7 +117,7 @@ local function main_button_handler(this, fields, name, tabdata)
bool = 'true' bool = 'true'
end end
core.setting_set("enable_damage", bool) core.setting_set("enable_damage", bool)
-- print(bool) minetest.setting_save()
return true return true
end end

View File

@ -81,6 +81,9 @@ local function dlg_confirm_reset_formspec(data)
end end
local function dlg_confirm_reset_btnhandler(this, fields, dialogdata) local function dlg_confirm_reset_btnhandler(this, fields, dialogdata)
core.set_clouds(false)
core.set_background("background",core.formspec_escape(mm_texture.basetexturedir)..'background.png')
core.set_background("header",core.formspec_escape(mm_texture.basetexturedir)..'header.png')
if fields["dlg_reset_singleplayer_confirm"] ~= nil then if fields["dlg_reset_singleplayer_confirm"] ~= nil then
local worldlist = core.get_worlds() local worldlist = core.get_worlds()

View File

@ -34,8 +34,7 @@ local function singleplayer_refresh_gamebar()
for key,value in pairs(fields) do for key,value in pairs(fields) do
for j=1,#gamemgr.games,1 do for j=1,#gamemgr.games,1 do
if ("game_btnbar_" .. gamemgr.games[j].id == key) then if ("game_btnbar_" .. gamemgr.games[j].id == key) then
mm_texture.update("singleplayer", gamemgr.games[j]) -- mm_texture.update("singleplayer", gamemgr.games[j])
--core.set_topleft_text(gamemgr.games[j].name)
core.setting_set("menu_last_game",gamemgr.games[j].id) core.setting_set("menu_last_game",gamemgr.games[j].id)
menudata.worldlist:set_filtercriteria(gamemgr.games[j].id) menudata.worldlist:set_filtercriteria(gamemgr.games[j].id)
return true return true
@ -124,6 +123,9 @@ local function get_formspec(tabview, name, tabdata)
end end
local function main_button_handler(this, fields, name, tabdata) local function main_button_handler(this, fields, name, tabdata)
core.set_clouds(false)
core.set_background("background",core.formspec_escape(mm_texture.basetexturedir)..'background.png')
core.set_background("header",core.formspec_escape(mm_texture.basetexturedir)..'header.png')
--assert(name == "singleplayer") --assert(name == "singleplayer")
@ -155,13 +157,22 @@ local function main_button_handler(this, fields, name, tabdata)
return true return true
end end
if fields["cb_creative_mode"] then if fields["cb_creative_mode"] then
core.setting_set("creative_mode", fields["cb_creative_mode"]) core.setting_set("creative_mode", fields["cb_creative_mode"])
return true local bool = fields["cb_creative_mode"]
end if bool == 'true' then
bool = 'false'
else
bool = 'true'
end
core.setting_set("enable_damage", bool)
minetest.setting_save()
return true
end
if fields["cb_enable_damage"] then if fields["cb_enable_damage"] then
core.setting_set("enable_damage", fields["cb_enable_damage"]) core.setting_set("enable_damage", fields["cb_enable_damage"])
minetest.setting_save()
return true return true
end end
@ -169,7 +180,6 @@ local function main_button_handler(this, fields, name, tabdata)
world_doubleclick or world_doubleclick or
fields["key_enter"] then fields["key_enter"] then
local selected = core.get_textlist_index("sp_worlds") local selected = core.get_textlist_index("sp_worlds")
print(selected)
if selected ~= nil then if selected ~= nil then
gamedata.selected_world = menudata.worldlist:get_raw_index(selected) gamedata.selected_world = menudata.worldlist:get_raw_index(selected)
gamedata.singleplayer = true gamedata.singleplayer = true
@ -184,7 +194,6 @@ local function main_button_handler(this, fields, name, tabdata)
create_world_dlg:set_parent(this) create_world_dlg:set_parent(this)
this:hide() this:hide()
create_world_dlg:show() create_world_dlg:show()
mm_texture.update("singleplayer",current_game())
return true return true
end end
@ -201,7 +210,6 @@ local function main_button_handler(this, fields, name, tabdata)
delete_world_dlg:set_parent(this) delete_world_dlg:set_parent(this)
this:hide() this:hide()
delete_world_dlg:show() delete_world_dlg:show()
mm_texture.update("singleplayer",current_game())
end end
end end
@ -219,7 +227,7 @@ local function main_button_handler(this, fields, name, tabdata)
configdialog:set_parent(this) configdialog:set_parent(this)
this:hide() this:hide()
configdialog:show() configdialog:show()
mm_texture.update("singleplayer",current_game()) --mm_texture.update("singleplayer",current_game())
end end
end end
@ -249,14 +257,14 @@ local function on_change(type, old_tab, new_tab)
if game then if game then
menudata.worldlist:set_filtercriteria(game.id) menudata.worldlist:set_filtercriteria(game.id)
--core.set_topleft_text(game.name) --core.set_topleft_text(game.name)
mm_texture.update("singleplayer",game) -- mm_texture.update("singleplayer",game)
end end
buttonbar:show() buttonbar:show()
else else
menudata.worldlist:set_filtercriteria(nil) menudata.worldlist:set_filtercriteria(nil)
buttonbar:hide() buttonbar:hide()
--core.set_topleft_text("") --core.set_topleft_text("")
mm_texture.update(new_tab,nil) --mm_texture.update(new_tab,nil)
end end
end end

View File

@ -87,6 +87,10 @@ end
-------------------------------------------------------------------------------- --------------------------------------------------------------------------------
local function main_button_handler(tabview, fields, name, tabdata) local function main_button_handler(tabview, fields, name, tabdata)
core.set_clouds(false)
core.set_background("background",core.formspec_escape(mm_texture.basetexturedir)..'background.png')
core.set_background("header",core.formspec_escape(mm_texture.basetexturedir)..'header.png')
if fields["TPs"] ~= nil then if fields["TPs"] ~= nil then
local event = core.explode_textlist_event(fields["TPs"]) local event = core.explode_textlist_event(fields["TPs"])
if event.type == "CHG" or event.type == "DCL" then if event.type == "CHG" or event.type == "DCL" then

View File

@ -34,7 +34,6 @@ function mm_texture.update(tab,gamedetails)
if gamedetails == nil then if gamedetails == nil then
return return
end end
mm_texture.update_game(gamedetails) mm_texture.update_game(gamedetails)
end end

View File

@ -1,9 +1,9 @@
----------------------------- --------------------------------------------------
--- 4hunger mod by 4aiman --- --- 4hunger mod by 4aiman - Multicraft version ---
----------------------------- --------------------------------------------------
--- license: GPLv3 --- --- CC BY-NC-SA ---
----------------------------- --------------------------------------------------
---- ----
---- Many thanks go to fairiestoy, who forced me to understand Lua a little bit more! ---- Many thanks go to fairiestoy, who forced me to understand Lua a little bit more!
@ -16,8 +16,6 @@
-- This mod TRIES too copy MC hunger mechanics as described at wiki -- This mod TRIES too copy MC hunger mechanics as described at wiki
-- here: http://minecraft.gamepedia.com/Hunger#Mechanics and FAILS to do do: -- here: http://minecraft.gamepedia.com/Hunger#Mechanics and FAILS to do do:
-- several things aren't covered due to internal differences of MT and MC. -- several things aren't covered due to internal differences of MT and MC.
-- Those are subject to get added by some other mod(s), creation of which
-- has began allready.
---- ----
---- ----
@ -25,6 +23,7 @@
---- ----
-- Since lua_api documentation sucks (it's of GREAT use nevertheless), -- Since lua_api documentation sucks (it's of GREAT use nevertheless),
-- I got inspired AND "guided" by some other mods that this one: -- I got inspired AND "guided" by some other mods that this one:
--
-- 1. "Farming" from the "Minitest" game by PilzAdam. What hunger if -- 1. "Farming" from the "Minitest" game by PilzAdam. What hunger if
-- there's nothing to eat? -- there's nothing to eat?
-- 2. "HUD & hunger". I make mistakes. Stupid ones too. -- 2. "HUD & hunger". I make mistakes. Stupid ones too.
@ -34,7 +33,6 @@
-- That was when I saw that his "hunger" do NOT depend on taken by a player -- That was when I saw that his "hunger" do NOT depend on taken by a player
-- actions... That was a shame! -- actions... That was a shame!
-- So, I got my lazy butt up and wrote this hunger mod. -- So, I got my lazy butt up and wrote this hunger mod.
-- 3. The "Sprint" mod by I-don't-know-who. Very useful. (The old one.)
-- --
---- ----
@ -63,10 +61,14 @@
-- Update: ported for Multicraft -- Update: ported for Multicraft
-- --
--
-- Update: Merge upstream changes. (License change, food_saturation depletion fixes, respawn==reset hunger feature introduction)
--
max_save_time = 10 max_save_time = 10
save_time = 0 save_time = 0
max_drumsticks = 20 max_drumsticks = 20
foodTickTimerMAX = 10 foodTickTimerMAX = 5
max_exhaustion = 8 max_exhaustion = 8
foodTickTimerMax = {} foodTickTimerMax = {}
food_level = {} food_level = {}
@ -83,8 +85,6 @@ jumped = {}
keypress_track = {} keypress_track = {}
hungerhud = {} hungerhud = {}
hungerhudb = {} hungerhudb = {}
hearthud = {}
hearthudb = {}
need_to_update_ph = {} need_to_update_ph = {}
@ -273,10 +273,8 @@ function multicraft.item_eat(food_points, saturation_points, replace_with_item)
food_saturation[pll]=food_points food_saturation[pll]=food_points
end end
if poisoned then if poisoned then
if poisoned==1 then state[pll] = 7 end if poisoned==1 then state[pll].poison1 = true end
if poisoned==2 then state[pll] = 8 end if poisoned==2 then state[pll].poison2 = true end
else
state[pll] = -1
end end
itemstack:add_item(replace_with_item) itemstack:add_item(replace_with_item)
end end
@ -292,49 +290,60 @@ function distance(pos1,pos2)
return math.sqrt( (pos1.x - pos2.x)^2 + (pos1.y - pos2.y)^2 + (pos1.z - pos2.z)^2 ) return math.sqrt( (pos1.x - pos2.x)^2 + (pos1.y - pos2.y)^2 + (pos1.z - pos2.z)^2 )
end end
function init_hunger(player) local damage_enabled = multicraft.setting_getbool("enable_damage")
function init_hunger(player, force)
if player then if player then
local pll = player:get_player_name() local pll = player:get_player_name()
if not foodTickTimerMax[pll] then foodTickTimerMax[pll]=foodTickTimerMAX end if not foodTickTimerMax[pll] or force then foodTickTimerMax[pll]=foodTickTimerMAX end
if not food_level[pll] then food_level[pll] = max_drumsticks end if not food_level[pll] or force then food_level[pll] = max_drumsticks end
if not death_timer[pll] then death_timer[pll] = 0 end if not death_timer[pll] or force then death_timer[pll] = 0 end
if not food_saturation[pll] then food_saturation[pll]=food_level[pll] end if not food_saturation[pll] or force then food_saturation[pll]=food_level[pll] end
if not timers[pll] then timers[pll] = -1 end if not timers[pll] or force then timers[pll] = -1 end
if not keypress_track[pll] then keypress_track[pll] = {} end if not keypress_track[pll] or force then keypress_track[pll] = {} end
if not state[pll] or type(state[pll])~="table" or force then state[pll] = {} end
multicraft.after(0, function() if damage_enabled then
if not player then return end multicraft.after(0.5, function()
hungerhudb[pll]=player:hud_add({ if not player then return end
hud_elem_type = "statbar", local hhf,hhb = player:hud_get(hungerhud[pll]), player:hud_get(hungerhudb[pll])
position = HUD_HUNGER_POS, if hungerhud[pll] and hhf and hhf.text == "hud_hunger_fg.png" then print('remove FG') player:hud_remove(hungerhud[pll]) end
size = HUD_SB_SIZE, if hungerhudb[pll] and hhf and hhb.text == "hud_hunger_bg.png" then print('remove BG') player:hud_remove(hungerhudb[pll]) end
text = "hud_hunger_bg.png", hungerhudb[pll]=player:hud_add({
number = 20, hud_elem_type = "statbar",
alignment = {x=-1,y=-1}, position = HUD_HUNGER_POS,
offset = HUD_HUNGER_OFFSET, size = HUD_SB_SIZE,
}) text = "hud_hunger_bg.png",
hungerhud[pll]=player:hud_add({ number = 20,
hud_elem_type = "statbar", alignment = {x=-1,y=-1},
position = HUD_HUNGER_POS, offset = HUD_HUNGER_OFFSET,
size = HUD_SB_SIZE, })
text = "hud_hunger_fg.png", hungerhud[pll]=player:hud_add({
number = 20, hud_elem_type = "statbar",
alignment = {x=-1,y=-1}, position = HUD_HUNGER_POS,
offset = HUD_HUNGER_OFFSET, size = HUD_SB_SIZE,
}) text = "hud_hunger_fg.png",
number = 20,
alignment = {x=-1,y=-1},
offset = HUD_HUNGER_OFFSET,
})
local hhf,hhb = player:hud_get(hungerhud[pll]), player:hud_get(hungerhudb[pll])
end) end)
end end
end end
end
multicraft.register_on_joinplayer(function(player) minetest.register_on_joinplayer(function(player)
init_hunger(player) init_hunger(player)
local pll = player:get_player_name()
state[pll] = {}
end) end)
local function get_field(item,field) local function get_field(item,field)
if multicraft.registered_nodes[item] then return multicraft.registered_nodes[item][field] end if minetest.registered_nodes[item] then return minetest.registered_nodes[item][field] end
if multicraft.registered_items[item] then return multicraft.registered_items[item][field] end if minetest.registered_items[item] then return minetest.registered_items[item][field] end
if multicraft.registered_craftitems[item] then return multicraft.registered_craftitems[item][field] end if minetest.registered_craftitems[item] then return minetest.registered_craftitems[item][field] end
if multicraft.registered_tools[item] then return multicraft.registered_tools[item][field] end if minetest.registered_tools[item] then return minetest.registered_tools[item][field] end
return "" return ""
end end
@ -342,173 +351,207 @@ local function get_on_eat(item)
return get_field(item,"on_eat") return get_field(item,"on_eat")
end end
multicraft.after(0, function(dtime) if damage_enabled then
local global_dtime = 0 minetest.after(0, function(dtime)
local doit = false local global_dtime = 0
multicraft.register_globalstep(function(dtime) local doit = false
global_dtime = global_dtime + dtime minetest.register_globalstep(function(dtime)
if global_dtime>1 then global_dtime = global_dtime + dtime
doit = true if global_dtime>1 then
global_dtime = 0 doit = true
end global_dtime = 0
if save_time > max_save_time then end
save_time=0
save_4hunger()
else
save_time=save_time+dtime
end
local players = multicraft.get_connected_players()
for i,player in ipairs(players) do
local pll = player:get_player_name()
local pos = player:getpos()
local hp = player:get_hp()
local control = player:get_player_control()
local wstack = player:get_wielded_item():get_name()
local bar
local addex = 0
if hp==1 and food_level[pll]<=0 and food_saturation[pll]<=0 then
death_timer[pll] = death_timer[pll] + dtime
end
if not food_level[pll] then init_hunger(player) end
if (death_timer[pll] or 0) > max_being_hungry_time then
death_timer[pll] = 0
multicraft.chat_send_all(death_message .. pll)
food_level[pll] = max_drumsticks
food_saturation[pll] = max_drumsticks
food_exhaustion[pll] = 0
player:set_hp(0)
end
if state[pll] == 7 or state[pll] == 8 then if save_time > max_save_time then
if not timers[pll] then save_time=0
timers[pll] = 15 save_4hunger()
player:hud_change(hungerhudb[pll],"text",'hunger_tile_d.png') else
player:hud_change(hungerhud[pll] ,"text",'hunger_tile_c.png') save_time=save_time+dtime
end
local players = minetest.get_connected_players()
for i,player in ipairs(players) do
local pll = player:get_player_name()
local pos = player:getpos()
local hp = player:get_hp()
local control = player:get_player_control()
local wstack = player:get_wielded_item():get_name()
local bar
local addex = 0
if hp==1 and food_level[pll]<=0 and food_saturation[pll]<=0 then
death_timer[pll] = death_timer[pll] + dtime
end
if (death_timer[pll] or 0) > max_being_hungry_time then
death_timer[pll] = 0
minetest.chat_send_all(death_message .. pll)
food_level[pll] = max_drumsticks
food_saturation[pll] = max_drumsticks
food_exhaustion[pll] = 0
player:set_hp(0)
end
if state[pll].poison1 or state[pll].poison2 then
if not timers[pll] then
timers[pll] = 15
player:hud_change(hungerhudb[pll],"text",'hunger_tile_d.png')
player:hud_change(hungerhud[pll] ,"text",'hunger_tile_c.png')
if doit==true and hp>10 then if doit==true and hp>10 then
player:set_hp(hp-1) player:set_hp(hp-1)
hp=hp-1 hp=hp-1
end
end
if state[pll].poison1 then addex = addex + ef1
elseif state[pll].poison2 then addex = addex + ef2 end
end
if timers[pll] then
timers[pll] = timers[pll] - dtime
if timers[pll]<0 then
timers[pll]=nil
local hhf,hhb = player:hud_get(hungerhud[pll]), player:hud_get(hungerhudb[pll])
if hungerhud[pll] and hhf and hhf.text == "hud_hunger_fg.png" then
player:hud_change(hungerhud[pll] ,"text",'hud_hunger_fg.png')
end
if hungerhudb[pll] and hhf and hhb.text == "hud_hunger_bg.png" then
player:hud_change(hungerhudb[pll],"text",'hud_hunger_bg.png')
end
else
if doit==true and hp>10 then
player:set_hp(hp-1)
hp=hp-1
end
end
end
local hp_diff = 0
if oldHPs[pll] and hp then
hp_diff = oldHPs[pll]-hp
end
if hp_diff~=0 then
state[pll].hurt = true
addex = addex + edm
end
oldHPs[pll] = hp
local dist = distance(oldpos[pll],pos)
oldpos[pll] = pos
local node = minetest.get_node({x=pos.x, y=pos.y-1, z=pos.z})
local name = node.name
if not jumped[pll] then
if state[pll].jump then
if not name:find("air") then
state[pll].jump = nil
end
else
if name:find("air") then
state[pll].jump = true
jumped[pll] = true
addex = addex + ejp
end
end
else
if not name:find("air") then
state[pll].jump = nil
jumped[pll] = false
end
end
if dist and dist>0 then
state[pll].walk = true
end
pos.y=pos.y+1
local node = minetest.get_node(pos)
local name = node.name
if minetest.get_item_group(name, "water") ~= 0 then
state[pll].swim = true
end
if food_level[pll]<=0 then food_level[pll] = 0 end
if food_level[pll]==0 or (food_level[pll]>17 and food_level[pll]<=max_drumsticks) then
if foodTickTimer[pll] then
foodTickTimer[pll] = foodTickTimer[pll] + dtime
else
foodTickTimer[pll] = dtime
end end
end end
if state == 7 then addex = addex + ef1
elseif state == 8 then addex = addex + ef2 end
end
if timers[pll] then if foodTickTimer[pll]>foodTickTimerMax[pll] then
timers[pll] = timers[pll] - dtime foodTickTimer[pll] = 0
if timers[pll]<0 then if food_level[pll]>17 and food_level[pll]<=max_drumsticks then
timers[pll]=nil if hp>0 then
player:hud_change(hungerhudb[pll],"text", "hud_hunger_bg.png") player:set_hp(hp+1)
player:hud_change(hungerhud[pll] ,"text", "hud_hunger_fg.png") end
else elseif food_level[pll]==0 then
if doit==true and hp>1 then if hp>10 then
player:set_hp(hp-1) player:set_hp(hp-1)
hp=hp-1 hp = hp-1
end
end
end
local hp_diff = 0
if oldHPs[pll] and hp then
hp_diff = oldHPs[pll]-hp
end
if hp_diff~=0 then
state[pll] = 5
addex = addex + edm
player:hud_change(hearthud[pll],"number",hp)
end
oldHPs[pll] = hp
local dist = distance(oldpos[pll],pos)
if not jumped[pll] then
local node = multicraft.get_node(pos)
local name = node.name
if name:find("air") then
if state[pll] == 1 then
state[pll] = 6
addex = addex + esj
else
state[pll] = 3
addex = addex + ejp
end
jumped[pll] = true
else
if dist and dist>0 then
state[pll] = 0
else
state[pll] = -1
end end
jumped[pll] = false
end
end
pos.y=pos.y+1
local node = multicraft.get_node(pos)
local name = node.name
if multicraft.get_item_group(name, "water") ~= 0 then
state[pll] = 2
end
if food_level[pll]<=0 then food_level[pll] = 0 end
if food_level[pll]==0 or (food_level[pll]>17 and food_level[pll]<=max_drumsticks)
then
if foodTickTimer[pll]
then foodTickTimer[pll] = foodTickTimer[pll] + dtime
else foodTickTimer[pll] = dtime
end end
end end
if foodTickTimer[pll]>foodTickTimerMax[pll] then
if food_level[pll]>17 and food_level[pll]<=max_drumsticks then
if hp>0 then
player:set_hp(hp+1)
end
elseif food_level[pll]==0 then
if hp>1 then
player:set_hp(hp-1)
hp = hp-1
end
end
foodTickTimer[pll] = 0
end
if not walked_distance[pll] then walked_distance[pll] = 0 end
oldpos[pll]=pos
walked_distance[pll] = walked_distance[pll] + dist
if hp_diff<0 and hp>18 then state[pll]=10 end
if not state[pll] then state[pll]=-1 end if not walked_distance[pll] then walked_distance[pll] = 0 end
if state[pll]==-1 then addex=addex+eid
elseif state[pll]==00 then addex=addex+ews*dist oldpos[pll]=pos
elseif state[pll]==01 then addex=addex+esp*dist walked_distance[pll] = walked_distance[pll] + dist
elseif state[pll]==02 then addex=addex+esw*dist
elseif state[pll]==03 then addex=addex+ejp*dist if hp_diff<0 and hp>18 then state[pll].regen = true end
elseif state[pll]==06 then addex=addex+esj*dist local ccc = 0
elseif state[pll]==09 then addex=addex+ebr for k,v in pairs(state[pll]) do
elseif state[pll]==10 then addex=addex+erg*-hp_diff ccc = ccc + 1
end end
if food_exhaustion[pll] then if ccc == 0 then
food_exhaustion[pll]=food_exhaustion[pll]+addex addex=addex+eid
else else
if state[pll].walk then addex=addex+ews*dist end
if state[pll].swim then addex=addex+esw*0.1 end
if state[pll].jump then addex=addex+ejp end
if state[pll].hurt then addex=edm*hp_diff end
if state[pll].poison1 then addex=ef1*dist end
if state[pll].poison2 then addex=ef2*dist end
if state[pll].dig then addex=addex+ebr end
if state[pll].regen then addex=addex+erg*-hp_diff end
end
state[pll] = {}
if food_exhaustion[pll] then
food_exhaustion[pll]=food_exhaustion[pll]+addex
else
food_exhaustion[pll]=addex food_exhaustion[pll]=addex
end end
if food_exhaustion[pll]>max_exhaustion then
if food_saturation[pll] then if food_exhaustion[pll]>max_exhaustion then
food_saturation[pll] = food_saturation[pll]-1 if food_saturation[pll] then
if food_saturation[pll]<0 then food_saturation[pll]=0 end food_saturation[pll] = food_saturation[pll]-1
else if food_saturation[pll]<0 then food_saturation[pll]=0 end
food_saturation[pll] = food_level[pll]-1 else
end food_saturation[pll] = food_level[pll]-1
if food_saturation[pll]==0 then food_level[pll]=food_level[pll]-1 end end
if food_level[pll]<0 then food_level[pll]=0 end if food_saturation[pll]==0 then food_level[pll]=food_level[pll]-1 end
food_exhaustion[pll] = 0 if food_level[pll]<0 then food_level[pll]=0 end
end food_exhaustion[pll] = 0
if hungerhud[pll] and food_level[pll] then end
player:hud_change(hungerhud[pll],"number",food_level[pll])
end if hungerhud[pll] and food_level[pll] then
end player:hud_change(hungerhud[pll],"number",food_level[pll])
doit = false end
end
doit = false
end)
end) end)
end) end
minetest.register_on_dignode(function(pos, oldnode, digger)
multicraft.register_on_dignode(function(pos, oldnode, digger)
if not digger then return end if not digger then return end
local pll = digger:get_player_name() local pll = digger:get_player_name()
state[pll]=9 state[pll].dig = true
if food_exhaustion[pll] then if food_exhaustion[pll] then
food_exhaustion[pll]=food_exhaustion[pll]+ebr food_exhaustion[pll]=food_exhaustion[pll]+ebr
else else
@ -516,21 +559,26 @@ multicraft.register_on_dignode(function(pos, oldnode, digger)
end end
end) end)
multicraft.after(0,function(dtime) minetest.after(0,function(dtime)
for cou,def in pairs(multicraft.registered_items) do for cou,def in pairs(minetest.registered_items) do
if get_points(def['name']) ~= false then if get_points(def['name']) ~= false then
def['on_use'] = multicraft.item_eat(1) def['on_use'] = minetest.item_eat(1)
multicraft.register_item(':' .. def.name, def) minetest.register_item(':' .. def.name, def)
end end
end end
end ) end )
multicraft.register_chatcommand("hunger", { minetest.register_chatcommand("hunger", {
privs = {server = true},
func = function(name, param) func = function(name, param)
food_level[name] = 0 food_level[name] = 0
food_saturation[name] = 0 food_saturation[name] = 0
end end
}) })
minetest.register_on_respawnplayer(function(player)
init_hunger(player, true)
end)
print('[OK] 4hunger (Multicraft version) loaded') print('[OK] 4hunger (Multicraft version) loaded')

View File

@ -1,16 +1,12 @@
if not multicraft.get_modpath("check") then os.exit() end if not multicraft.get_modpath("check") then os.exit() end
if not multicraft.get_modpath("check") then os.exit() end
if not default.multicraft_is_variable_is_a_part_of_multicraft_subgame_and_copying_it_means_you_use_our_code_so_we_become_contributors_of_your_project then exit() end if not default.multicraft_is_variable_is_a_part_of_multicraft_subgame_and_copying_it_means_you_use_our_code_so_we_become_contributors_of_your_project then exit() end
------------------------- -----------------------------------------------
-- adbs mod by 4aiman -- --- adbs mod by 4aiman - Multicraft version ---
------------------------- -----------------------------------------------
-- (Multicraft port) -- --- CC BY-NC-SA ---
------------------------- -----------------------------------------------
-- --
-- Licence:GPLv3 --
-- --
-------------------------
--Update: Merged upstream changes. (License change, less "jumpy" mobs)
math.randomseed(os.time()) math.randomseed(os.time())
@ -496,12 +492,15 @@ adbs.dd = {
end end
end end
local yaw = self.object:getyaw() local yaw = self.object:getyaw() -- jump, if there's something that can be juped on
local x = -math.sin(yaw) local x = -math.sin(yaw)
local z = math.cos(yaw) local z = math.cos(yaw)
local nm = multicraft.get_node(posf).name local nm = minetest.get_node({x = posf.x+x,y = posf.y+1,z = posf.z+z}).name
if multicraft.registered_nodes[nm] local nm2 = minetest.get_node({x = posf.x+x,y = posf.y+2,z = posf.z+z}).name
and multicraft.registered_nodes[nm].walkable if minetest.registered_nodes[nm]
and minetest.registered_nodes[nm].walkable
and minetest.registered_nodes[nm2]
and not minetest.registered_nodes[nm2].walkable
then then
self:jump() self:jump()
end end

View File

@ -26,7 +26,15 @@ multicraft.register_alias("mapgen_stone_with_coal", "default:stone_with_coal")
multicraft.register_alias("mapgen_stone_with_iron", "default:stone_with_iron") multicraft.register_alias("mapgen_stone_with_iron", "default:stone_with_iron")
multicraft.register_alias("mapgen_desert_sand", "default:sand") multicraft.register_alias("mapgen_desert_sand", "default:sand")
multicraft.register_alias("mapgen_desert_stone", "default:sandstone") multicraft.register_alias("mapgen_desert_stone", "default:sandstone")
multicraft.register_alias("mapgen_dirt_with_snow", "default:dirt_with_snow")
multicraft.register_alias("mapgen_snowblock", "default:snowblock")
multicraft.register_alias("mapgen_snow", "default:snow")
multicraft.register_alias("mapgen_ice", "default:ice")
multicraft.register_alias("mapgen_jungletree", "default:jungletree")
multicraft.register_alias("mapgen_jungleleaves", "default:jungleleaves")
multicraft.register_alias("mapgen_junglegrass", "default:junglegrass")
multicraft.register_alias("mapgen_pinetree", "default:pinetree")
multicraft.register_alias("mapgen_pine_needles", "default:pine_needles")
-- --
-- Ore generation -- Ore generation
@ -490,40 +498,20 @@ multicraft.register_on_generated(function(minp, maxp, seed)
local p = {x=x,y=ground_y,z=z} local p = {x=x,y=ground_y,z=z}
-- Check if the node can be replaced -- Check if the node can be replaced
if #(multicraft.find_nodes_in_area({x=x-5,y=ground_y-2,z=z-5}, {x=x+5,y=ground_y+2,z=z+5}, {"group:grass", "group:flower"}))>7 then if #(multicraft.find_nodes_in_area({x=x-5,y=ground_y-2,z=z-5}, {x=x+5,y=ground_y+2,z=z+5}, {"group:grass", "group:flower"}))>7 then
for i=1,pr:next(1,4) do local fruit = {"farming:pumpkin_face", "farming:melon", "farming:carrot", "farming:potato"}
local ground_y = nil local choice = fruit[pr:next(1,#fruit)]
for y=30,0,-1 do if pr:next() < 2500 then -- the "proper" alternative
if multicraft.get_node({x=x,y=y,z=z}).name ~= "air" local xx = pr:next(1,i+1)
and not multicraft.get_node({x=x,y=y,z=z}).name:find("water") then local zz = pr:next(1,i+1)
ground_y = y local nname = multicraft.get_node({x=p.x+xx,z=p.z+zz,y=ground_y}).name
break if nname ~="air"
end and (multicraft.registered_nodes[nname] and not multicraft.registered_nodes[nname].buildable_to)
then
multicraft.set_node({x=p.x+xx,z=p.z+zz,y=ground_y+1},{name=choice})
end end
local fruit = {"farming:pumpkin_face", "farming:melon", "farming:carrot", "farming:potato"}
local choice = fruit[pr:next(1,#fruit)]
--print(choice)
if pr:next() < 2500 then -- the "proper" alternative
for i = 1, pr:next(1,3) do
local xx = pr:next(1,i+1)
local zz = pr:next(1,i+1)
local nname = multicraft.get_node({x=p.x+xx,z=p.z+zz,y=ground_y}).name
if nname ~="air"
and (multicraft.registered_nodes[nname] and not multicraft.registered_nodes[nname].buildable_to)
then
multicraft.set_node({x=p.x+xx,z=p.z+zz,y=ground_y+1},{name=choice})
end
end
end
end end
end end
end end
end end
end end
end end

View File

@ -3,6 +3,73 @@
-- --
-- Node definitions -- Node definitions
-- --
multicraft.register_node("default:dirt_with_snow", {
description = "Dirt with Snow",
tiles = {"default_snow.png", "default_dirt.png", "default_dirt.png^default_snow_side.png"},
groups = {crumbly=3,soil=1},
drop = 'default:dirt',
sounds = default.node_sound_dirt_defaults(),
})
multicraft.register_node("default:snow", {
description = "Snow",
tiles = {"default_snow.png"},
inventory_image = "default_snowball.png",
wield_image = "default_snowball.png",
paramtype = "light",
buildable_to = true,
drawtype = "nodebox",
node_box = {
type = "fixed",
fixed = {
{-0.5, -0.5, -0.5, 0.5, -0.5+2/16, 0.5},
},
},
groups = {crumbly=3,falling_node=1},
sounds = default.node_sound_dirt_defaults(),
on_construct = function(pos)
pos.y = pos.y - 1
if multicraft.get_node(pos).name == "default:dirt_with_grass" then
multicraft.set_node(pos, {name="default:dirt_with_snow"})
end
end,
})
multicraft.register_node("default:snowblock", {
description = "Snow Block",
tiles = {"default_snow.png"},
groups = {crumbly=3},
sounds = default.node_sound_dirt_defaults(),
})
multicraft.register_node("default:ice", {
description = "Ice",
tiles = {"default_ice.png"},
is_ground_content = false,
paramtype = "light",
groups = {cracky=3},
sounds = default.node_sound_glass_defaults(),
})
multicraft.register_node("default:pinetree", {
description = "Pine Tree",
tiles = {"default_pinetree_top.png", "default_pinetree_top.png", "default_pinetree.png"},
paramtype2 = "facedir",
groups = {tree=1,choppy=2,oddly_breakable_by_hand=1,flammable=2},
sounds = default.node_sound_wood_defaults(),
})
multicraft.register_node("default:pine_needles",{
description = "Pine Needles",
drawtype = "allfaces_optional",
visual_scale = 1.3,
tiles = {"default_pine_needles.png"},
waving = 1,
paramtype = "light",
groups = {snappy=3, leafdecay=3, flammable=2, leaves=1},
sounds = default.node_sound_leaves_defaults(),
})
multicraft.register_node("default:stone", { multicraft.register_node("default:stone", {
description = "Stone", description = "Stone",

Binary file not shown.

After

Width:  |  Height:  |  Size: 203 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 280 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 574 B

View File

@ -183,7 +183,6 @@ local function add_hud_item(player, name, def)
end end
multicraft.register_on_joinplayer(function(player) multicraft.register_on_joinplayer(function(player)
-- first: hide the default statbars -- first: hide the default statbars
local hud_flags = player:hud_get_flags() local hud_flags = player:hud_get_flags()
hud_flags.healthbar = false hud_flags.healthbar = false

View File

@ -1,7 +1,7 @@
HUD_IW_MAX = 8 HUD_IW_MAX = 8
HUD_IW_TICK = 0.4 HUD_IW_TICK = 0.4
if multicraft.is_singleplayer() == true then if multicraft.is_singleplayer() == true then
HUD_IW_TICK = 0.2 HUD_IW_TICK = 0.1
end end
HUD_SB_SIZE = {x = 24, y = 24} HUD_SB_SIZE = {x = 24, y = 24}
@ -50,6 +50,7 @@ if damage_enabled then
text = "hud_heart_fg.png", text = "hud_heart_fg.png",
number = 20, number = 20,
alignment = {x = -1, y = -1}, alignment = {x = -1, y = -1},
autohide_bg = false,
offset = HUD_HEALTH_OFFSET, offset = HUD_HEALTH_OFFSET,
background = "hud_heart_bg.png", background = "hud_heart_bg.png",
events = { events = {
@ -97,7 +98,6 @@ if damage_enabled then
autohide_bg = false, autohide_bg = false,
max = 20, max = 20,
}) })
else else
hud.show_armor = false hud.show_armor = false
end end

View File

@ -282,11 +282,11 @@ public:
Check if a node is pointable Check if a node is pointable
*/ */
inline bool isPointableNode(const MapNode &n, inline bool isPointableNode(const MapNode &n,
Client *client, bool liquids_pointable) Client *client, bool liquids_pointable)
{ {
const ContentFeatures &features = client->getNodeDefManager()->get(n); const ContentFeatures &features = client->getNodeDefManager()->get(n);
return features.pointable || return features.pointable ||
(liquids_pointable && features.isLiquid()); (liquids_pointable && features.isLiquid());
} }
/* /*
@ -321,8 +321,8 @@ PointedThing getPointedThing(Client *client, v3f player_position,
v3f pos = selected_object->getPosition(); v3f pos = selected_object->getPosition();
hilightboxes.push_back(aabb3f( hilightboxes.push_back(aabb3f(
selection_box->MinEdge + pos - intToFloat(camera_offset, BS), selection_box->MinEdge + pos - intToFloat(camera_offset, BS),
selection_box->MaxEdge + pos - intToFloat(camera_offset, BS))); selection_box->MaxEdge + pos - intToFloat(camera_offset, BS)));
} }
mindistance = (selected_object->getPosition() - camera_position).getLength(); mindistance = (selected_object->getPosition() - camera_position).getLength();
@ -902,8 +902,8 @@ bool nodePlacementPrediction(Client &client,
if (prediction != "" && !nodedef->get(node).rightclickable) { if (prediction != "" && !nodedef->get(node).rightclickable) {
verbosestream << "Node placement prediction for " verbosestream << "Node placement prediction for "
<< playeritem_def.name << " is " << playeritem_def.name << " is "
<< prediction << std::endl; << prediction << std::endl;
v3s16 p = neighbourpos; v3s16 p = neighbourpos;
// Place inside node itself if buildable_to // Place inside node itself if buildable_to
@ -925,9 +925,9 @@ bool nodePlacementPrediction(Client &client,
if (!found) { if (!found) {
errorstream << "Node placement prediction failed for " errorstream << "Node placement prediction failed for "
<< playeritem_def.name << " (places " << playeritem_def.name << " (places "
<< prediction << prediction
<< ") - Name not known" << std::endl; << ") - Name not known" << std::endl;
return false; return false;
} }
@ -1000,9 +1000,9 @@ bool nodePlacementPrediction(Client &client,
} }
} catch (InvalidPositionException &e) { } catch (InvalidPositionException &e) {
errorstream << "Node placement prediction failed for " errorstream << "Node placement prediction failed for "
<< playeritem_def.name << " (places " << playeritem_def.name << " (places "
<< prediction << prediction
<< ") - Position not loaded" << std::endl; << ") - Position not loaded" << std::endl;
} }
} }
@ -1017,7 +1017,7 @@ static inline void create_formspec_menu(GUIFormSpecMenu **cur_formspec,
if (*cur_formspec == 0) { if (*cur_formspec == 0) {
*cur_formspec = new GUIFormSpecMenu(device, guiroot, -1, &g_menumgr, *cur_formspec = new GUIFormSpecMenu(device, guiroot, -1, &g_menumgr,
invmgr, gamedef, tsrc, fs_src, txt_dest, client); invmgr, gamedef, tsrc, fs_src, txt_dest, client);
(*cur_formspec)->doPause = false; (*cur_formspec)->doPause = false;
/* /*
@ -1035,13 +1035,13 @@ static inline void create_formspec_menu(GUIFormSpecMenu **cur_formspec,
} }
#ifdef __ANDROID__ #ifdef __ANDROID__
# define SIZE_TAG "size[11,5.5]" # define SIZE_TAG "size[11,5.5]"
# define PAUSE_MENU_SIZE_TAG "size[6,3.5]" # define PAUSE_MENU_SIZE_TAG "size[6,3.5]"
# define PAUSE_MENU_BUTTON_LEFT 1.5 # define PAUSE_MENU_BUTTON_LEFT 1.5
#else #else
# define SIZE_TAG "size[11,5.5,true]" // Fixed size on desktop # define SIZE_TAG "size[11,5.5,true]" // Fixed size on desktop
# define PAUSE_MENU_SIZE_TAG "size[11,5.5,true]" // Fixed size on desktop # define PAUSE_MENU_SIZE_TAG "size[11,5.5,true]" // Fixed size on desktop
# define PAUSE_MENU_BUTTON_LEFT 4 # define PAUSE_MENU_BUTTON_LEFT 4
#endif #endif
static void show_chat_menu(GUIFormSpecMenu **cur_formspec, static void show_chat_menu(GUIFormSpecMenu **cur_formspec,
@ -1093,19 +1093,19 @@ static void show_pause_menu(GUIFormSpecMenu **cur_formspec,
bool singleplayermode) bool singleplayermode)
{ {
#ifdef __ANDROID__ #ifdef __ANDROID__
// std::string control_text = wide_to_narrow(wstrgettext("Default Controls:\n" // std::string control_text = wide_to_narrow(wstrgettext("Default Controls:\n"
// "No menu visible:\n" // "No menu visible:\n"
// "- single tap: button activate\n" // "- single tap: button activate\n"
// "- double tap: place/use\n" // "- double tap: place/use\n"
// "- slide finger: look around\n" // "- slide finger: look around\n"
// "Menu/Inventory visible:\n" // "Menu/Inventory visible:\n"
// "- double tap (outside):\n" // "- double tap (outside):\n"
// " -->close\n" // " -->close\n"
// "- touch stack, touch slot:\n" // "- touch stack, touch slot:\n"
// " --> move stack\n" // " --> move stack\n"
// "- touch&drag, tap 2nd finger\n" // "- touch&drag, tap 2nd finger\n"
// " --> place single item to slot\n" // " --> place single item to slot\n"
// )); // ));
#else #else
std::string control_text = wide_to_narrow(wstrgettext("Default Controls:\n" std::string control_text = wide_to_narrow(wstrgettext("Default Controls:\n"
"- WASD: move\n" "- WASD: move\n"
@ -1118,7 +1118,7 @@ static void show_pause_menu(GUIFormSpecMenu **cur_formspec,
"- Mouse right: place/use\n" "- Mouse right: place/use\n"
"- Mouse wheel: select item\n" "- Mouse wheel: select item\n"
"- T: chat\n" "- T: chat\n"
)); ));
#endif #endif
float ypos = singleplayermode ? 0.5 : 0.1; float ypos = singleplayermode ? 0.5 : 0.1;
@ -1134,14 +1134,14 @@ static void show_pause_menu(GUIFormSpecMenu **cur_formspec,
} }
#ifndef __ANDROID__ #ifndef __ANDROID__
os << "button_exit[" << PAUSE_MENU_BUTTON_LEFT << "," << (ypos++) << ";3,0.5;btn_sound;" os << "button_exit[" << PAUSE_MENU_BUTTON_LEFT << "," << (ypos++) << ";3,0.5;btn_sound;"
<< wide_to_narrow(wstrgettext("Sound Volume")) << "]"; << wide_to_narrow(wstrgettext("Sound Volume")) << "]";
os << "button_exit[" << PAUSE_MENU_BUTTON_LEFT << "," << (ypos++) << ";3,0.5;btn_key_config;" os << "button_exit[" << PAUSE_MENU_BUTTON_LEFT << "," << (ypos++) << ";3,0.5;btn_key_config;"
<< wide_to_narrow(wstrgettext("Change Keys")) << "]"; << wide_to_narrow(wstrgettext("Change Keys")) << "]";
#endif #endif
os << "button_exit[" << PAUSE_MENU_BUTTON_LEFT << "," << (ypos++) << ";3,0.5;btn_exit_menu;" os << "button_exit[" << PAUSE_MENU_BUTTON_LEFT << "," << (ypos++) << ";3,0.5;btn_exit_menu;"
<< wide_to_narrow(wstrgettext("Exit to Menu")) << "]"; << wide_to_narrow(wstrgettext("Exit to Menu")) << "]";
os << "button_exit[" << PAUSE_MENU_BUTTON_LEFT << "," << (ypos++) << ";3,0.5;btn_exit_os;" os << "button_exit[" << PAUSE_MENU_BUTTON_LEFT << "," << (ypos++) << ";3,0.5;btn_exit_os;"
<< wide_to_narrow(wstrgettext("Exit to OS")) << "]" << wide_to_narrow(wstrgettext("Exit to OS")) << "]"
#ifndef __ANDROID__ #ifndef __ANDROID__
<< "textarea[7.5,0.25;3.9,6.25;;" << control_text << ";]" << "textarea[7.5,0.25;3.9,6.25;;" << control_text << ";]"
@ -1200,13 +1200,13 @@ static void updateChat(Client &client, f32 dtime, bool show_debug,
// first pass to calculate height of text to be set // first pass to calculate height of text to be set
s32 width = std::min(g_fontengine->getTextWidth(recent_chat) + 10, s32 width = std::min(g_fontengine->getTextWidth(recent_chat) + 10,
porting::getWindowSize().X - 20); porting::getWindowSize().X - 20);
core::rect<s32> rect(10, chat_y, width, chat_y + porting::getWindowSize().Y); core::rect<s32> rect(10, chat_y, width, chat_y + porting::getWindowSize().Y);
guitext_chat->setRelativePosition(rect); guitext_chat->setRelativePosition(rect);
//now use real height of text and adjust rect according to this size //now use real height of text and adjust rect according to this size
rect = core::rect<s32>(10, chat_y, width, rect = core::rect<s32>(10, chat_y, width,
chat_y + guitext_chat->getTextHeight()); chat_y + guitext_chat->getTextHeight());
guitext_chat->setRelativePosition(rect); guitext_chat->setRelativePosition(rect);
@ -1574,7 +1574,7 @@ private:
GUIChatConsole *gui_chat_console; // Free using ->Drop() GUIChatConsole *gui_chat_console; // Free using ->Drop()
MapDrawControl *draw_control; MapDrawControl *draw_control;
Camera *camera; Camera *camera;
Clouds *clouds; // Free using ->Drop() Clouds *clouds; // Free using ->Drop()
Sky *sky; // Free using ->Drop() Sky *sky; // Free using ->Drop()
Inventory *local_inventory; Inventory *local_inventory;
Hud *hud; Hud *hud;
@ -1605,7 +1605,7 @@ private:
gui::IGUIStaticText *guitext2; // Second line of debug text gui::IGUIStaticText *guitext2; // Second line of debug text
gui::IGUIStaticText *guitext_info; // At the middle of the screen gui::IGUIStaticText *guitext_info; // At the middle of the screen
gui::IGUIStaticText *guitext_status; gui::IGUIStaticText *guitext_status;
gui::IGUIStaticText *guitext_chat; // Chat text gui::IGUIStaticText *guitext_chat; // Chat text
gui::IGUIStaticText *guitext_profiler; // Profiler text gui::IGUIStaticText *guitext_profiler; // Profiler text
std::wstring infotext; std::wstring infotext;
@ -1671,7 +1671,7 @@ Game::Game() :
m_cache_mouse_sensitivity = rangelim(m_cache_mouse_sensitivity, 0.001, 100.0); m_cache_mouse_sensitivity = rangelim(m_cache_mouse_sensitivity, 0.001, 100.0);
#ifdef __ANDROID__ #ifdef __ANDROID__
m_cache_hold_aux1 = false; // This is initialised properly later m_cache_hold_aux1 = false; // This is initialised properly later
#endif #endif
} }
@ -1973,7 +1973,7 @@ bool Game::createSingleplayerServer(const std::string map_dir,
} }
server = new Server(map_dir, gamespec, simple_singleplayer_mode, server = new Server(map_dir, gamespec, simple_singleplayer_mode,
bind_addr.isIPv6()); bind_addr.isIPv6());
server->start(bind_addr); server->start(bind_addr);
@ -2036,7 +2036,7 @@ bool Game::createClient(const std::string &playername,
/* Skybox /* Skybox
*/ */
sky = new Sky(smgr->getRootSceneNode(), smgr, -1, texture_src); sky = new Sky(smgr->getRootSceneNode(), smgr, -1, texture_src);
skybox = NULL; // This is used/set later on in the main run loop skybox = NULL; // This is used/set later on in the main run loop
local_inventory = new Inventory(itemdef_manager); local_inventory = new Inventory(itemdef_manager);
@ -2152,7 +2152,7 @@ bool Game::connectToServer(const std::string &playername,
const std::string &password, std::string *address, u16 port, const std::string &password, std::string *address, u16 port,
bool *connect_ok, bool *aborted) bool *connect_ok, bool *aborted)
{ {
*connect_ok = false; // Let's not be overly optimistic *connect_ok = false; // Let's not be overly optimistic
*aborted = false; *aborted = false;
bool local_server_mode = false; bool local_server_mode = false;
@ -2197,7 +2197,7 @@ bool Game::connectToServer(const std::string &playername,
if (!client) if (!client)
return false; return false;
gamedef = client; // Client acts as our GameDef gamedef = client; // Client acts as our GameDef
infostream << "Connecting to server at "; infostream << "Connecting to server at ";
connect_address.print(&infostream); connect_address.print(&infostream);
@ -2397,19 +2397,19 @@ inline bool Game::handleCallbacks()
if (g_gamecallback->changepassword_requested) { if (g_gamecallback->changepassword_requested) {
(new GUIPasswordChange(guienv, guiroot, -1, (new GUIPasswordChange(guienv, guiroot, -1,
&g_menumgr, client))->drop(); &g_menumgr, client))->drop();
g_gamecallback->changepassword_requested = false; g_gamecallback->changepassword_requested = false;
} }
if (g_gamecallback->changevolume_requested) { if (g_gamecallback->changevolume_requested) {
(new GUIVolumeChange(guienv, guiroot, -1, (new GUIVolumeChange(guienv, guiroot, -1,
&g_menumgr, client))->drop(); &g_menumgr, client))->drop();
g_gamecallback->changevolume_requested = false; g_gamecallback->changevolume_requested = false;
} }
if (g_gamecallback->keyconfig_requested) { if (g_gamecallback->keyconfig_requested) {
(new GUIKeyChangeMenu(guienv, guiroot, -1, (new GUIKeyChangeMenu(guienv, guiroot, -1,
&g_menumgr))->drop(); &g_menumgr))->drop();
g_gamecallback->keyconfig_requested = false; g_gamecallback->keyconfig_requested = false;
} }
@ -2643,10 +2643,10 @@ void Game::processKeyboardInput(VolatileRunFlags *flags,
else if (input->wasKeyDown(keycache.key[KeyCache::KEYMAP_ID_DEBUG_STACKS])) { else if (input->wasKeyDown(keycache.key[KeyCache::KEYMAP_ID_DEBUG_STACKS])) {
// Print debug stacks // Print debug stacks
dstream << "-----------------------------------------" dstream << "-----------------------------------------"
<< std::endl; << std::endl;
dstream << DTIME << "Printing debug stacks:" << std::endl; dstream << DTIME << "Printing debug stacks:" << std::endl;
dstream << "-----------------------------------------" dstream << "-----------------------------------------"
<< std::endl; << std::endl;
debug_stacks_print(); debug_stacks_print();
} }
@ -2675,7 +2675,7 @@ void Game::processItemSelection(u16 *new_playeritem)
s32 wheel = input->getMouseWheel(); s32 wheel = input->getMouseWheel();
u16 max_item = MYMIN(PLAYER_INVENTORY_SIZE - 1, u16 max_item = MYMIN(PLAYER_INVENTORY_SIZE - 1,
player->hud_hotbar_itemcount - 1); player->hud_hotbar_itemcount - 1);
if (wheel < 0) if (wheel < 0)
*new_playeritem = *new_playeritem < max_item ? *new_playeritem + 1 : 0; *new_playeritem = *new_playeritem < max_item ? *new_playeritem + 1 : 0;
@ -2894,7 +2894,7 @@ void Game::toggleProfiler(float *statustext_time, u32 *profiler_current_page,
if (*profiler_current_page != 0) { if (*profiler_current_page != 0) {
std::wstringstream sstr; std::wstringstream sstr;
sstr << "Profiler shown (page " << *profiler_current_page sstr << "Profiler shown (page " << *profiler_current_page
<< " of " << profiler_max_page << ")"; << " of " << profiler_max_page << ")";
statustext = sstr.str(); statustext = sstr.str();
} else { } else {
statustext = L"Profiler hidden"; statustext = L"Profiler hidden";
@ -3061,7 +3061,7 @@ inline void Game::step(f32 *dtime)
bool can_be_and_is_paused = bool can_be_and_is_paused =
(simple_singleplayer_mode && g_menumgr.pausesGame()); (simple_singleplayer_mode && g_menumgr.pausesGame());
if (can_be_and_is_paused) { // This is for a singleplayer server if (can_be_and_is_paused) { // This is for a singleplayer server
*dtime = 0; // No time passes *dtime = 0; // No time passes
} else { } else {
if (server != NULL) { if (server != NULL) {
@ -3104,7 +3104,7 @@ void Game::processClientEvents(CameraOrientation *cam, float *damage_flash)
show_deathscreen(&current_formspec, client, gamedef, texture_src, show_deathscreen(&current_formspec, client, gamedef, texture_src,
device, client); device, client);
chat_backend->addMessage(L"", L"You died."); // chat_backend->addMessage(L"", L"You died.");
/* Handle visualization */ /* Handle visualization */
*damage_flash = 0; *damage_flash = 0;
@ -3118,7 +3118,7 @@ void Game::processClientEvents(CameraOrientation *cam, float *damage_flash)
new TextDestPlayerInventory(client, *(event.show_formspec.formname)); new TextDestPlayerInventory(client, *(event.show_formspec.formname));
create_formspec_menu(&current_formspec, client, gamedef, create_formspec_menu(&current_formspec, client, gamedef,
texture_src, device, fs_src, txt_dst, client); texture_src, device, fs_src, txt_dst, client);
delete(event.show_formspec.formspec); delete(event.show_formspec.formspec);
delete(event.show_formspec.formname); delete(event.show_formspec.formname);
@ -3322,7 +3322,7 @@ void Game::updateCamera(VolatileRunFlags *flags, u32 busy_time,
tool_reload_ratio = MYMIN(tool_reload_ratio, 1.0); tool_reload_ratio = MYMIN(tool_reload_ratio, 1.0);
camera->update(player, dtime, busy_time / 1000.0f, tool_reload_ratio, camera->update(player, dtime, busy_time / 1000.0f, tool_reload_ratio,
client->getEnv()); client->getEnv());
camera->step(dtime); camera->step(dtime);
v3f camera_position = camera->getPosition(); v3f camera_position = camera->getPosition();
@ -3352,13 +3352,13 @@ void Game::updateSound(f32 dtime)
// Update sound listener // Update sound listener
v3s16 camera_offset = camera->getOffset(); v3s16 camera_offset = camera->getOffset();
sound->updateListener(camera->getCameraNode()->getPosition() + intToFloat(camera_offset, BS), sound->updateListener(camera->getCameraNode()->getPosition() + intToFloat(camera_offset, BS),
v3f(0, 0, 0), // velocity v3f(0, 0, 0), // velocity
camera->getDirection(), camera->getDirection(),
camera->getCameraNode()->getUpVector()); camera->getCameraNode()->getUpVector());
sound->setListenerGain(g_settings->getFloat("sound_volume")); sound->setListenerGain(g_settings->getFloat("sound_volume"));
// Update sound maker // Update sound maker
soundmaker->step(dtime); soundmaker->step(dtime);
LocalPlayer *player = client->getEnv().getLocalPlayer(); LocalPlayer *player = client->getEnv().getLocalPlayer();
@ -3411,7 +3411,7 @@ void Game::processPlayerInteraction(std::vector<aabb3f> &highlight_boxes,
camera_position + camera_direction * BS * (d + 1)); camera_position + camera_direction * BS * (d + 1));
} else { } else {
// prevent player pointing anything in front-view // prevent player pointing anything in front-view
if (camera->getCameraMode() == CAMERA_MODE_THIRD_FRONT) if (camera->getCameraMode() == CAMERA_MODE_THIRD_FRONT)
shootline = core::line3d<f32>(0, 0, 0, 0, 0, 0); shootline = core::line3d<f32>(0, 0, 0, 0, 0, 0);
} }
@ -3457,7 +3457,7 @@ void Game::processPlayerInteraction(std::vector<aabb3f> &highlight_boxes,
if (runData->digging) { if (runData->digging) {
if (input->getLeftReleased()) { if (input->getLeftReleased()) {
infostream << "Left button released" infostream << "Left button released"
<< " (stopped digging)" << std::endl; << " (stopped digging)" << std::endl;
runData->digging = false; runData->digging = false;
} else if (pointed != runData->pointed_old) { } else if (pointed != runData->pointed_old) {
if (pointed.type == POINTEDTHING_NODE if (pointed.type == POINTEDTHING_NODE
@ -3468,7 +3468,7 @@ void Game::processPlayerInteraction(std::vector<aabb3f> &highlight_boxes,
// Don't reset. // Don't reset.
} else { } else {
infostream << "Pointing away from node" infostream << "Pointing away from node"
<< " (stopped digging)" << std::endl; << " (stopped digging)" << std::endl;
runData->digging = false; runData->digging = false;
} }
} }
@ -3584,7 +3584,7 @@ void Game::handlePointingAtNode(GameRunData *runData,
TextDest *txt_dst = new TextDestNodeMetadata(nodepos, client); TextDest *txt_dst = new TextDestNodeMetadata(nodepos, client);
create_formspec_menu(&current_formspec, client, gamedef, create_formspec_menu(&current_formspec, client, gamedef,
texture_src, device, fs_src, txt_dst, client); texture_src, device, fs_src, txt_dst, client);
current_formspec->setFormSpec(meta->getString("formspec"), inventoryloc); current_formspec->setFormSpec(meta->getString("formspec"), inventoryloc);
} else { } else {
@ -3829,7 +3829,7 @@ void Game::updateFrame(std::vector<aabb3f> &highlight_boxes,
direct_brightness = client->getEnv().getClientMap() direct_brightness = client->getEnv().getClientMap()
.getBackgroundBrightness(MYMIN(runData->fog_range * 1.2, 60 * BS), .getBackgroundBrightness(MYMIN(runData->fog_range * 1.2, 60 * BS),
daynight_ratio, (int)(old_brightness * 255.5), &sunlight_seen) daynight_ratio, (int)(old_brightness * 255.5), &sunlight_seen)
/ 255.0; / 255.0;
} }
float time_of_day = runData->time_of_day; float time_of_day = runData->time_of_day;
@ -3868,7 +3868,7 @@ void Game::updateFrame(std::vector<aabb3f> &highlight_boxes,
clouds->setVisible(true); clouds->setVisible(true);
clouds->step(dtime); clouds->step(dtime);
clouds->update(v2f(player_position.X, player_position.Z), clouds->update(v2f(player_position.X, player_position.Z),
sky->getCloudColor()); sky->getCloudColor());
} else { } else {
clouds->setVisible(false); clouds->setVisible(false);
} }
@ -4264,20 +4264,20 @@ void Game::extendedResourceCleanup()
// Extended resource accounting // Extended resource accounting
infostream << "Irrlicht resources after cleanup:" << std::endl; infostream << "Irrlicht resources after cleanup:" << std::endl;
infostream << "\tRemaining meshes : " infostream << "\tRemaining meshes : "
<< device->getSceneManager()->getMeshCache()->getMeshCount() << std::endl; << device->getSceneManager()->getMeshCache()->getMeshCount() << std::endl;
infostream << "\tRemaining textures : " infostream << "\tRemaining textures : "
<< driver->getTextureCount() << std::endl; << driver->getTextureCount() << std::endl;
for (unsigned int i = 0; i < driver->getTextureCount(); i++) { for (unsigned int i = 0; i < driver->getTextureCount(); i++) {
irr::video::ITexture *texture = driver->getTextureByIndex(i); irr::video::ITexture *texture = driver->getTextureByIndex(i);
infostream << "\t\t" << i << ":" << texture->getName().getPath().c_str() infostream << "\t\t" << i << ":" << texture->getName().getPath().c_str()
<< std::endl; << std::endl;
} }
clearTextureNameCache(); clearTextureNameCache();
infostream << "\tRemaining materials: " infostream << "\tRemaining materials: "
<< driver-> getMaterialRendererCount() << driver-> getMaterialRendererCount()
<< " (note: irrlicht doesn't support removing renderers)" << std::endl; << " (note: irrlicht doesn't support removing renderers)" << std::endl;
} }

Binary file not shown.

Before

Width:  |  Height:  |  Size: 14 KiB

After

Width:  |  Height:  |  Size: 22 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 31 KiB

After

Width:  |  Height:  |  Size: 35 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 28 KiB

After

Width:  |  Height:  |  Size: 49 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 17 KiB

After

Width:  |  Height:  |  Size: 27 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 12 KiB

After

Width:  |  Height:  |  Size: 19 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 19 KiB

After

Width:  |  Height:  |  Size: 30 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 24 KiB

After

Width:  |  Height:  |  Size: 37 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 24 KiB

After

Width:  |  Height:  |  Size: 38 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 20 KiB

After

Width:  |  Height:  |  Size: 31 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 17 KiB

After

Width:  |  Height:  |  Size: 27 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 22 KiB

After

Width:  |  Height:  |  Size: 47 KiB