diff --git a/externalmodify.lua b/externalmodify.lua index 3666a53..b466296 100644 --- a/externalmodify.lua +++ b/externalmodify.lua @@ -234,6 +234,7 @@ for name, def in pairs(minetest.registered_tools) do end newdef.description = def.description.." "..special.description newdef.inventory_image = def.inventory_image.."^specialties_"..special.name..".png" + newdef.wield_image = def.inventory_image.."^specialties_"..special.name..".png" if(name:find(":hoe") ~= nil) then newdef.on_use = function(itemstack, user, pointed_thing) if pointed_thing.type == "nothing" or pointed_thing.type == "object" or pointed_thing.above == nil then return itemstack end diff --git a/init.lua b/init.lua index 34f076e..6ff0990 100644 --- a/init.lua +++ b/init.lua @@ -18,7 +18,7 @@ local get_specialInfo = function(name, specialty) .."button[2,3;2,0.5;builder;Builder]" .."list[current_player;main;0,4;8,4;]" if(specialty ~= "") then - formspec = formspec.."label[4,0;XP: "..specialties.players[name].skills[specialty].."]"..specialties.skills[specialty].menu + formspec = formspec.."label[4,0;XP: "..specialties.players[name][specialty].."]"..specialties.skills[specialty].menu end return formspec end @@ -44,33 +44,7 @@ minetest.register_on_joinplayer(function(player) player:get_inventory():set_size("buildtrash", 1) name = player:get_player_name() specialties.players[name] = {} - specialties.players[name].skills = {} - specialties.players[name].skills = specialties.readXP(name) - specialties.players[name].menu = {} - minetest.after(0.5, function() - local Yoffset = 0.02 - local y = 0 - for skill,num in pairs(specialties.players[name].skills) do - specialties.players[name].menu[skill] = player:hud_add({ - hud_elem_type = "text", - position = {x=0, y=0.85+y}, - offset = {x=100, y=0}, - alignment = {x=1, y=0}, - number = 0xFFFFFF , - text = tostring(num), - }) - player:hud_add({ - hud_elem_type = "text", - position = {x=0, y=0.85+y}, - offset = {x=10, y=0}, - alignment = {x=1, y=0}, - scale = {x=100, y=50}, - number = 0xFFFFFF , - text = skill, - }) - y = y+Yoffset - end - end) + specialties.players[name] = specialties.readXP(name) end) local function show_formspec(name, specialty) minetest.show_formspec(name, "specialties:spec", get_specialInfo(name, specialty)) diff --git a/xp.lua b/xp.lua index da0b1c5..a149910 100644 --- a/xp.lua +++ b/xp.lua @@ -1,8 +1,8 @@ --File Manipulating specialties.writeXP = function(name) local file = io.open(minetest.get_worldpath().."/"..name.."_XP", "w") - for skill,num in pairs(specialties.players[name].skills) do - file:write(skill.." "..tostring(num).."\n") + for skill,_ in pairs(specialties.players[name]) do + file:write(skill.." "..tostring(specialties.players[name][skill]).."\n") end file:close() end @@ -29,17 +29,9 @@ end --Table Modification specialties.changeXP = function(name, specialty, amount) - local newAmount = specialties.players[name].skills[specialty]+amount - if newAmount >= 0 then - specialties.players[name].skills[specialty] = newAmount - local player = minetest.get_player_by_name(name) - local id = specialties.players[name].menu[specialty] - local hudItem = player:hud_get(id) - hudItem.text = tostring(newAmount) - hudItem.offset = {x=100, y=0} - hudItem.alignment = {x=1, y=0} - player:hud_remove(id) - specialties.players[name].menu[specialty] = player:hud_add(hudItem) + local current = specialties.players[name][specialty] + if current+amount >= 0 then + specialties.players[name][specialty] = current+amount return true else return false