Revert "Remove wield image in item definition"

This reverts commit f43dc80eb5.
This commit is contained in:
Austin Shenk 2013-07-01 18:59:04 -04:00
parent f43dc80eb5
commit 4439a29fb2
3 changed files with 8 additions and 41 deletions

View File

@ -234,6 +234,7 @@ for name, def in pairs(minetest.registered_tools) do
end end
newdef.description = def.description.." "..special.description newdef.description = def.description.." "..special.description
newdef.inventory_image = def.inventory_image.."^specialties_"..special.name..".png" 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 if(name:find(":hoe") ~= nil) then
newdef.on_use = function(itemstack, user, pointed_thing) 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 if pointed_thing.type == "nothing" or pointed_thing.type == "object" or pointed_thing.above == nil then return itemstack end

View File

@ -18,7 +18,7 @@ local get_specialInfo = function(name, specialty)
.."button[2,3;2,0.5;builder;Builder]" .."button[2,3;2,0.5;builder;Builder]"
.."list[current_player;main;0,4;8,4;]" .."list[current_player;main;0,4;8,4;]"
if(specialty ~= "") then 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 end
return formspec return formspec
end end
@ -44,33 +44,7 @@ minetest.register_on_joinplayer(function(player)
player:get_inventory():set_size("buildtrash", 1) player:get_inventory():set_size("buildtrash", 1)
name = player:get_player_name() name = player:get_player_name()
specialties.players[name] = {} specialties.players[name] = {}
specialties.players[name].skills = {} specialties.players[name] = specialties.readXP(name)
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)
end) end)
local function show_formspec(name, specialty) local function show_formspec(name, specialty)
minetest.show_formspec(name, "specialties:spec", get_specialInfo(name, specialty)) minetest.show_formspec(name, "specialties:spec", get_specialInfo(name, specialty))

18
xp.lua
View File

@ -1,8 +1,8 @@
--File Manipulating --File Manipulating
specialties.writeXP = function(name) specialties.writeXP = function(name)
local file = io.open(minetest.get_worldpath().."/"..name.."_XP", "w") local file = io.open(minetest.get_worldpath().."/"..name.."_XP", "w")
for skill,num in pairs(specialties.players[name].skills) do for skill,_ in pairs(specialties.players[name]) do
file:write(skill.." "..tostring(num).."\n") file:write(skill.." "..tostring(specialties.players[name][skill]).."\n")
end end
file:close() file:close()
end end
@ -29,17 +29,9 @@ end
--Table Modification --Table Modification
specialties.changeXP = function(name, specialty, amount) specialties.changeXP = function(name, specialty, amount)
local newAmount = specialties.players[name].skills[specialty]+amount local current = specialties.players[name][specialty]
if newAmount >= 0 then if current+amount >= 0 then
specialties.players[name].skills[specialty] = newAmount specialties.players[name][specialty] = current+amount
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)
return true return true
else else
return false return false