Add initial files for commiting
This commit is contained in:
commit
07d0cae566
1
config.lua
Normal file
1
config.lua
Normal file
@ -0,0 +1 @@
|
||||
enable_item_drop=true
|
4
depends.txt
Normal file
4
depends.txt
Normal file
@ -0,0 +1,4 @@
|
||||
default
|
||||
inventory_plus
|
||||
farming
|
||||
moreores
|
172
externalmodify.lua
Normal file
172
externalmodify.lua
Normal file
@ -0,0 +1,172 @@
|
||||
--Handle node drops to be compatible with the Technic node drops
|
||||
local technic = minetest.get_modpath("technic")
|
||||
local code = "local tool = digger:get_wielded_item():get_name()\n"..
|
||||
"if(tool:find('superheat') ~= nil)then\n"..
|
||||
"output = minetest.get_craft_result({method='cooking', items={name}})\n"..
|
||||
"if(output.item ~= nil)then name = output.item:get_name()end\n"..
|
||||
"end\n"
|
||||
if(technic ~= "" and technic ~= nil) then
|
||||
local readfile = io.open(technic.."/item_drop.lua", "r")
|
||||
local newfile = ""
|
||||
local numlines = 9
|
||||
for line in readfile:lines() do
|
||||
newfile = newfile..line.."\n"
|
||||
if(line:find("minetest.handle_node_drops") ~= nil) then
|
||||
while(numlines > 0) do
|
||||
line = readfile:read("*l")
|
||||
newfile = newfile..line.."\n"
|
||||
numlines = numlines - 1
|
||||
end
|
||||
if(line:find("end") ~= nil) then
|
||||
line = readfile:read("*l")
|
||||
if(line:find("digger:get_wielded_item()") == nil) then
|
||||
newfile = newfile..code
|
||||
end
|
||||
newfile = newfile..line.."\n"
|
||||
end
|
||||
end
|
||||
|
||||
end
|
||||
io.close()
|
||||
local file = io.open(technic.."/item_drop.lua", "w")
|
||||
file:write(newfile)
|
||||
io.flush()
|
||||
io.close()
|
||||
|
||||
else
|
||||
function minetest.handle_node_drops(pos, drops, digger)
|
||||
local itemcount = 0
|
||||
local itemname = ""
|
||||
for _,item in ipairs(drops) do
|
||||
if type(item) == "string" then
|
||||
itemcount = 1
|
||||
itemname = item
|
||||
else
|
||||
itemcount = item:get_count()
|
||||
itemname = item:get_name()
|
||||
end
|
||||
local tool = digger:get_wielded_item():get_name()
|
||||
if(tool:find('superheat') ~= nil)then
|
||||
output = minetest.get_craft_result({method='cooking', items={itemname}})
|
||||
if(output.item ~= nil)then itemname = output.item:get_name()end
|
||||
end
|
||||
if(enable_item_drop) then
|
||||
for i=1,itemcount do
|
||||
local obj = minetest.env:add_item(pos, itemname)
|
||||
if obj ~= nil then
|
||||
obj:get_luaentity().collect = true
|
||||
local x = math.random(1, 5)
|
||||
if math.random(1,2) == 1 then
|
||||
x = -x
|
||||
end
|
||||
local z = math.random(1, 5)
|
||||
if math.random(1,2) == 1 then
|
||||
z = -z
|
||||
end
|
||||
obj:setvelocity({x=1/x, y=obj:getvelocity().y, z=1/z})
|
||||
|
||||
-- FIXME this doesnt work for deactiveted objects
|
||||
if minetest.setting_get("remove_items") and tonumber(minetest.setting_get("remove_items")) then
|
||||
minetest.after(tonumber(minetest.setting_get("remove_items")), function(obj)
|
||||
obj:remove()
|
||||
end, obj)
|
||||
end
|
||||
end
|
||||
end
|
||||
else
|
||||
if(digger:get_player_name() ~= nil and digger:get_player_name() ~= "") then
|
||||
digger:get_inventory():add_item("main", itemname.." "..itemcount)
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
local function create_soil(pos, inv, p)
|
||||
if pos == nil then
|
||||
return false
|
||||
end
|
||||
local node = minetest.env:get_node(pos)
|
||||
local name = node.name
|
||||
local above = minetest.env:get_node({x=pos.x, y=pos.y+1, z=pos.z})
|
||||
if name == "default:dirt" or name == "default:dirt_with_grass" then
|
||||
if above.name == "air" then
|
||||
node.name = "farming:soil"
|
||||
minetest.env:set_node(pos, node)
|
||||
if inv and p and name == "default:dirt_with_grass" then
|
||||
for name,rarity in pairs(farming.seeds) do
|
||||
if math.random(1, rarity-p) == 1 then
|
||||
inv:add_item("main", ItemStack(name))
|
||||
end
|
||||
end
|
||||
end
|
||||
return true
|
||||
end
|
||||
end
|
||||
return false
|
||||
end
|
||||
|
||||
local function nodeIsValid(node)
|
||||
local nums = {"1","2","3","4","5","6","7","8","9"}
|
||||
local lastChar = node.name:sub(#node.name)
|
||||
local isNum = false
|
||||
for _,num in pairs(nums) do
|
||||
if(lastChar == num) then isNum = true end
|
||||
end
|
||||
return (node.name:find("farming") ~= nil) and (node.name:find("soil") == nil) and (not isNum)
|
||||
end
|
||||
|
||||
--Create and store the tools with new additions
|
||||
for name, def in pairs(minetest.registered_tools) do
|
||||
local colonpos = name:find(":")
|
||||
local modname = name:sub(0,colonpos-1)
|
||||
for skill, _ in pairs(specialties.skills) do
|
||||
for _,special in pairs(specialties.skills[skill].specials) do
|
||||
if(specialties.skills[skill].tool ~= "") then
|
||||
if(name:find(specialties.skills[skill].tool) ~= nil and special ~= {}) then
|
||||
local toolname = "specialties"..name:sub(colonpos).."_"..special.name
|
||||
local newdef = def
|
||||
newdef.description = def.description.." "..special.description
|
||||
newdef.inventory_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") then return itemstack end
|
||||
if create_soil(pointed_thing.under, user:get_inventory(), 0) then
|
||||
itemstack:add_wear(65535/specialties.hoewear[name:sub(name:find("_")+1)])
|
||||
return itemstack
|
||||
end
|
||||
local pos = {}
|
||||
pos.x = (pointed_thing.above.x+pointed_thing.under.x)/2
|
||||
pos.y = (pointed_thing.above.y+pointed_thing.under.y)/2
|
||||
pos.z = (pointed_thing.above.z+pointed_thing.under.z)/2
|
||||
pos.y = pos.y-.5
|
||||
local node = minetest.env:get_node(pos)
|
||||
if(nodeIsValid(node)) then
|
||||
minetest.env:dig_node(pos)
|
||||
if(not enable_item_drop) then
|
||||
minetest.handle_node_drops(user:getpos(), minetest.get_node_drops(node.name, toolname), user)
|
||||
end
|
||||
if(node.name:find("weed") == nil) then
|
||||
minetest.env:set_node(pos, {name = node.name.."_1"})
|
||||
end
|
||||
itemstack:add_wear(65535/specialties.hoewear[name:sub(name:find("_")+1)])
|
||||
return itemstack
|
||||
end
|
||||
end
|
||||
end
|
||||
specialties.healAmount[toolname] = specialties.healAmount[name]
|
||||
local uptool = specialties.upgradeTree[name]
|
||||
if(uptool ~= nil) then
|
||||
local upgrade = uptool:sub(uptool:find(":"), #uptool)
|
||||
specialties.upgradeTree[toolname] = "specialties"..upgrade.."_"..special.name
|
||||
end
|
||||
specialties.tools[toolname] = newdef
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
--Register all of the tools
|
||||
for name, def in pairs(specialties.tools) do
|
||||
minetest.register_tool(name, def)
|
||||
end
|
180
init.lua
Normal file
180
init.lua
Normal file
@ -0,0 +1,180 @@
|
||||
--run Files
|
||||
local modpath=minetest.get_modpath("specialties")
|
||||
dofile(modpath.."/config.lua")
|
||||
dofile(modpath.."/tables.lua")
|
||||
dofile(modpath.."/externalmodify.lua")
|
||||
dofile(modpath.."/xp.lua")
|
||||
|
||||
--variable used for time keeping for updating xp
|
||||
time = 0
|
||||
|
||||
local get_specialInfo = function(player, specialty)
|
||||
local formspec = "size[8,8]" -- size of the formspec page
|
||||
.."button[0,0;2,0.5;main;Back]" -- back to main inventory
|
||||
.."button[2,0;2,0.5;miner;Miner]"
|
||||
.."button[2,.75;2,0.5;lumberjack;Lumberjack]"
|
||||
.."button[2,1.5;2,0.5;digger;Digger]"
|
||||
.."button[2,2.25;2,0.5;farmer;Farmer]"
|
||||
.."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[player:get_player_name()][specialty].."]"..specialties.skills[specialty].menu
|
||||
end
|
||||
return formspec
|
||||
end
|
||||
|
||||
minetest.register_on_leaveplayer(function(player)--Called if on a server, if single player than it isn't called
|
||||
specialties.updateXP(player:get_player_name())
|
||||
end)
|
||||
|
||||
--Initial Files Created
|
||||
minetest.register_on_newplayer(function(player)
|
||||
for skill,_ in pairs(specialties.skills) do
|
||||
specialties.writeXP(player:get_player_name(), skill, 0)
|
||||
end
|
||||
end)
|
||||
|
||||
--Initial XP Extraction
|
||||
--optimizes the amount of calls to files
|
||||
minetest.register_on_joinplayer(function(player)
|
||||
inventory_plus.register_button(player,"specialties","Specialties")
|
||||
player:get_inventory():set_size("pick", 1)
|
||||
player:get_inventory():set_size("axe", 1)
|
||||
player:get_inventory():set_size("shovel", 1)
|
||||
player:get_inventory():set_size("hoe", 1)
|
||||
player:get_inventory():set_size("buildrefill", 1)
|
||||
player:get_inventory():set_size("buildtrash", 1)
|
||||
name = player:get_player_name()
|
||||
specialties.players[name] = {}
|
||||
for skill,_ in pairs(specialties.skills) do
|
||||
specialties.players[name][skill] = specialties.readXP(name, skill)
|
||||
end
|
||||
end)
|
||||
|
||||
--Skill Events
|
||||
local function healTool(player, list, specialty, cost)
|
||||
tool = player:get_inventory():get_list(list)[1]
|
||||
if (tool:get_name():find(":"..list) ~= nil and tool:get_wear() ~= 0 and specialties.healAmount[tool:get_name()] ~= nil)then
|
||||
if (specialties.changeXP(player:get_player_name(), specialty, -cost)) then
|
||||
tool:add_wear(-specialties.healAmount[tool:get_name()])
|
||||
player:get_inventory():set_stack(list, 1, tool)
|
||||
end
|
||||
end
|
||||
inventory_plus.set_inventory_formspec(player, get_specialInfo(player, specialty))
|
||||
end
|
||||
local function upgradeTool(player, list, specialty, cost)
|
||||
tool = player:get_inventory():get_list(list)[1]
|
||||
if(tool:get_name():find(":"..list) ~= nil and specialties.upgradeTree[tool:get_name()] ~= nil) then
|
||||
if (specialties.changeXP(player:get_player_name(), specialty, -cost)) then
|
||||
player:get_inventory():set_stack(list, 1, specialties.upgradeTree[tool:get_name()])
|
||||
end
|
||||
end
|
||||
inventory_plus.set_inventory_formspec(player, get_specialInfo(player, specialty))
|
||||
end
|
||||
local function addSpecial2Tool(player, skill, list, specialty, cost)
|
||||
local tool = player:get_inventory():get_list(list)[1]
|
||||
local toolname = tool:get_name()
|
||||
if(toolname:find("_"..skill) ~= nil) then return end
|
||||
if (specialties.changeXP(player:get_player_name(), specialty, -cost)) then
|
||||
local def = tool:get_definition()
|
||||
local colonpos = toolname:find(":")
|
||||
local modname = toolname:sub(0,colonpos-1)
|
||||
if(modname ~= "specialties") then toolname = "specialties"..toolname:sub(colonpos) end
|
||||
local name = toolname.."_"..skill
|
||||
player:get_inventory():set_stack(list, 1, name)
|
||||
end
|
||||
inventory_plus.set_inventory_formspec(player, get_specialInfo(player, specialty))
|
||||
end
|
||||
local function doTransfer(player, list, factor)
|
||||
|
||||
end
|
||||
|
||||
--GUI Events
|
||||
minetest.register_on_player_receive_fields(function(player, formname, fields)
|
||||
if fields.specialties then
|
||||
inventory_plus.set_inventory_formspec(player, get_specialInfo(player, ""))
|
||||
return
|
||||
end
|
||||
|
||||
--MINER
|
||||
if fields.miner then
|
||||
inventory_plus.set_inventory_formspec(player, get_specialInfo(player, "miner"))
|
||||
return
|
||||
end
|
||||
if fields.healpick then healTool(player, "pick", "miner", 100) end
|
||||
if fields.upgradepick then upgradeTool(player, "pick", "miner", 200) end
|
||||
if fields.superheatpick then addSpecial2Tool(player, "superheat", "pick", "miner", 500) end
|
||||
|
||||
--LUMBERJACK
|
||||
if fields.lumberjack then
|
||||
inventory_plus.set_inventory_formspec(player, get_specialInfo(player, "lumberjack"))
|
||||
return
|
||||
end
|
||||
if fields.healaxe then healTool(player, "axe", "lumberjack", 100) end
|
||||
if fields.upgradeaxe then upgradeTool(player, "axe", "lumberjack", 200) end
|
||||
if fields.superheataxe then addSpecial2Tool(player, "superheat", "axe", "lumberjack", 500) end
|
||||
|
||||
--DIGGER
|
||||
if fields.digger then
|
||||
inventory_plus.set_inventory_formspec(player, get_specialInfo(player, "digger"))
|
||||
return
|
||||
end
|
||||
if fields.healshovel then healTool(player, "shovel", "digger", 100) end
|
||||
if fields.upgradeshovel then upgradeTool(player, "shovel", "digger", 200) end
|
||||
if fields.superheatshovel then addSpecial2Tool(player, "superheat", "shovel", "digger", 500) end
|
||||
|
||||
--FARMER
|
||||
if fields.farmer then
|
||||
inventory_plus.set_inventory_formspec(player, get_specialInfo(player, "farmer"))
|
||||
return
|
||||
end
|
||||
if fields.healhoe then healTool(player, "hoe", "farmer", 100) end
|
||||
if fields.upgradehoe then upgradeTool(player, "hoe", "farmer", 200) end
|
||||
if fields.greenthumb then addSpecial2Tool(player, "greenthumb", "hoe", "farmer", 500) end
|
||||
|
||||
--BUILDER
|
||||
if fields.builder then
|
||||
inventory_plus.set_inventory_formspec(player, get_specialInfo(player, "builder"))
|
||||
return
|
||||
end
|
||||
if fields.dorefill then doTransfer(player, "refill", 1) end
|
||||
if fields.dotrash then doTransfer(player, "trash", -1) end
|
||||
end)
|
||||
|
||||
|
||||
--XP Events
|
||||
minetest.register_on_dignode(function(pos, oldnode, digger)
|
||||
if(digger == nil) then
|
||||
return
|
||||
end
|
||||
if(digger:get_wielded_item():is_empty())then
|
||||
return
|
||||
end
|
||||
local tool = digger:get_wielded_item():get_name()
|
||||
local name = digger:get_player_name()
|
||||
if(tool:find("pick") ~= nil)then
|
||||
specialties.changeXP(name, "miner", 1)
|
||||
end
|
||||
if(tool:find("axe") ~= nil)then
|
||||
specialties.changeXP(name, "lumberjack", 1)
|
||||
end
|
||||
if(tool:find("shovel") ~= nil)then
|
||||
specialties.changeXP(name, "digger", 1)
|
||||
end
|
||||
if(oldnode.name:find("farming") ~= nil) then
|
||||
specialties.changeXP(name, "farmer", 5)
|
||||
end
|
||||
end)
|
||||
minetest.register_on_placenode(function(pos, newnode, placer, oldnode)
|
||||
specialties.changeXP(placer:get_player_name(), "builder", 1)
|
||||
end)
|
||||
minetest.register_globalstep(function(dtime)
|
||||
if(time+dtime < 10) then
|
||||
time = time+dtime
|
||||
else
|
||||
time = 0
|
||||
for key in pairs(specialties.players)do
|
||||
specialties.updateXP(key)
|
||||
end
|
||||
end
|
||||
end)
|
132
tables.lua
Normal file
132
tables.lua
Normal file
@ -0,0 +1,132 @@
|
||||
--Other mods can use this table to check player's specialty levels
|
||||
specialties = {}
|
||||
specialties.players = {}
|
||||
specialties.tools = {}
|
||||
|
||||
--The GUI used to display the skills of each specialty
|
||||
specialties.skills = {}
|
||||
specialties.skills["miner"] = {menu="button[4.5,1;3,0.5;healpick;(100)Heal Pick]"..
|
||||
"button[4.5,1.5;3,0.5;upgradepick;(200)Upgrade Pick]"..
|
||||
"button[4.5,2;3,0.5;superheatpick;(500)Super Heat]"..
|
||||
"list[current_player;pick;5.5,0;1,1;]",
|
||||
specials={{name="superheat", description="Super Heat"}}, tool="pick"}
|
||||
specialties.skills["lumberjack"] = {menu="button[4.5,1;3,0.5;healaxe;(100)Heal Axe]"..
|
||||
"button[4.5,1.5;3,0.5;upgradeaxe;(200)Upgrade Axe]"..
|
||||
"button[4.5,2;3,0.5;superheataxe;(500)Super Heat]"..
|
||||
"list[current_player;axe;5.5,0;1,1;]",
|
||||
specials={{name="superheat", description="Super Heat"}}, tool="axe"}
|
||||
specialties.skills["digger"] = {menu="button[4.5,1;3,0.5;healshovel;(100)Heal Shovel]"..
|
||||
"button[4.5,1.5;3,0.5;upgradeshovel;(200)Upgrade Shovel]"..
|
||||
"button[4.5,2;3,0.5;superheatshovel;(500)Super Heat]"..
|
||||
"list[current_player;shovel;5.5,0;1,1;]",
|
||||
specials={{name="superheat", description="Super Heat"}}, tool="shovel"}
|
||||
specialties.skills["builder"] = {menu="list[current_player;buildrefill;4.5,1;1,1;]"..
|
||||
"field[4.875,2.5;1,.5;refillamount;;1]"..
|
||||
"button[4.5,3;1,0.5;dorefill;Refill]"..
|
||||
"list[current_player;buildtrash;6.5,1;1,1;]"..
|
||||
"field[6.875,2.5;1,.5;trashamount;;1]"..
|
||||
"button[6.5,3;1,0.5;dotrash;Trash]",
|
||||
specials={}, tool=""}
|
||||
if(minetest.get_modpath("farming") ~= nil or minetest.get_modpath("farming") ~= "") then
|
||||
specialties.skills["farmer"] = {menu="button[4.5,1;3,0.5;healhoe;(100)Heal Hoe]"..
|
||||
"button[4.5,1.5;3,0.5;upgradehoe;(200)Upgrade Hoe]"..
|
||||
"button[4.5,2;3,0.5;greenthumb;(500)Green Thumb]"..
|
||||
"list[current_player;hoe;5.5,0;1,1;]",
|
||||
specials={{name="greenthumb", description="Green Thumb"}}, tool="hoe"}
|
||||
end
|
||||
|
||||
specialties.hoewear = {}
|
||||
specialties.hoewear["wood"] = 30
|
||||
specialties.hoewear["stone"] = 50
|
||||
specialties.hoewear["steel"] = 80
|
||||
|
||||
--Amount to heal each type of tool
|
||||
--mod support
|
||||
specialties.healAmount = {}
|
||||
specialties.healAmount["default:pick_wood"] = 40000
|
||||
specialties.healAmount["default:pick_stone"] = 30000
|
||||
specialties.healAmount["default:pick_steel"] = 20000
|
||||
specialties.healAmount["default:pick_mese"] = 10000
|
||||
specialties.healAmount["default:axe_wood"] = 30000
|
||||
specialties.healAmount["default:axe_stone"] = 20000
|
||||
specialties.healAmount["default:axe_steel"] = 10000
|
||||
specialties.healAmount["default:shovel_wood"] = 30000
|
||||
specialties.healAmount["default:shovel_stone"] = 20000
|
||||
specialties.healAmount["default:shovel_steel"] = 10000
|
||||
specialties.healAmount["moreores:pick_bronze"] = 20000
|
||||
specialties.healAmount["moreores:pick_silver"] = 32000
|
||||
specialties.healAmount["moreores:pick_gold"] = 40000
|
||||
specialties.healAmount["moreores:pick_mithril"] = 14000
|
||||
specialties.healAmount["moreores:axe_bronze"] = 20000
|
||||
specialties.healAmount["moreores:axe_silver"] = 32000
|
||||
specialties.healAmount["moreores:axe_gold"] = 40000
|
||||
specialties.healAmount["moreores:axe_mithril"] = 14000
|
||||
specialties.healAmount["moreores:shovel_bronze"] = 20000
|
||||
specialties.healAmount["moreores:shovel_silver"] = 32000
|
||||
specialties.healAmount["moreores:shovel_gold"] = 40000
|
||||
specialties.healAmount["moreores:shovel_mithril"] = 14000
|
||||
specialties.healAmount["farming:hoe_wood"] = 40000
|
||||
specialties.healAmount["farming:hoe_stone"] = 30000
|
||||
specialties.healAmount["farming:hoe_steel"] = 20000
|
||||
|
||||
--List of tools that can be upgraded into a better one
|
||||
--mod support
|
||||
specialties.upgradeTree = {}
|
||||
specialties.upgradeTree["default:pick_wood"] = "default:pick_stone"
|
||||
specialties.upgradeTree["default:pick_stone"] = "default:pick_steel"
|
||||
specialties.upgradeTree["default:pick_steel"] = "default:pick_mese"
|
||||
specialties.upgradeTree["default:axe_wood"] = "default:axe_stone"
|
||||
specialties.upgradeTree["default:axe_stone"] = "default:axe_steel"
|
||||
specialties.upgradeTree["default:shovel_wood"] = "default:shovel_stone"
|
||||
specialties.upgradeTree["default:shovel_stone"] = "default:shovel_steel"
|
||||
specialties.upgradeTree["moreores:pick_bronze"] = "moreores:pick_silver"
|
||||
specialties.upgradeTree["moreores:pick_silver"] = "moreores:pick_gold"
|
||||
specialties.upgradeTree["moreores:pick_gold"] = "moreores:pick_mithril"
|
||||
specialties.upgradeTree["moreores:shovel_bronze"] = "moreores:shovel_silver"
|
||||
specialties.upgradeTree["moreores:shovel_silver"] = "moreores:shovel_gold"
|
||||
specialties.upgradeTree["moreores:shovel_gold"] = "moreores:shovel_mithril"
|
||||
specialties.upgradeTree["moreores:axe_bronze"] = "moreores:axe_silver"
|
||||
specialties.upgradeTree["moreores:axe_silver"] = "moreores:axe_gold"
|
||||
specialties.upgradeTree["moreores:axe_gold"] = "moreores:axe_mithril"
|
||||
specialties.upgradeTree["farming:hoe_wood"] = "farming:hoe_stone"
|
||||
specialties.upgradeTree["farming:hoe_stone"] = "farming:hoe_steel"
|
||||
|
||||
--List of amounts used to calculate the xp required for transfer
|
||||
specialties.transferAmount = {}
|
||||
-- Cooking adds 5 for the coal used
|
||||
--specialties.transferAmount[""] =
|
||||
specialties.transferAmount["default:dirt"] = 1
|
||||
specialties.transferAmount["default:cobble"] = 1
|
||||
specialties.transferAmount["default:mossycobble"] = 2
|
||||
specialties.transferAmount["default:stone"] = 6
|
||||
specialties.transferAmount["default:gravel"] = 2
|
||||
specialties.transferAmount["default:sand"] = 2
|
||||
specialties.transferAmount["default:sandstone"] = 8
|
||||
specialties.transferAmount["default:desert_sand"] = 2
|
||||
specialties.transferAmount["default:glass"] = 7
|
||||
specialties.transferAmount["default:papyrus"] = 1
|
||||
specialties.transferAmount["default:paper"] = 3
|
||||
specialties.transferAmount["default:book"] = 9
|
||||
specialties.transferAmount["default:bookshelf"] = 51
|
||||
specialties.transferAmount["default:stick"] = 1
|
||||
specialties.transferAmount["default:fence_wood"] = 3
|
||||
specialties.transferAmount["default:wood"] = 4
|
||||
specialties.transferAmount["default:tree"] = 16
|
||||
specialties.transferAmount["default:torch"] = 2
|
||||
specialties.transferAmount["default:sign_wall"] = 25
|
||||
specialties.transferAmount["default:ladder"] = 7
|
||||
specialties.transferAmount["default:coal_lump"] = 5
|
||||
specialties.transferAmount["default:iron_lump"] = 5
|
||||
specialties.transferAmount["default:steel_ingot"] = 10
|
||||
specialties.transferAmount["default:steelblock"] = 90
|
||||
specialties.transferAmount["default:mese"] = 60
|
||||
specialties.transferAmount["default:clay"] = 36
|
||||
specialties.transferAmount["default:clay_lump"] = 9
|
||||
specialties.transferAmount["default:clay_brick"] = 14
|
||||
specialties.transferAmount["default:brick"] = 56
|
||||
specialties.transferAmount["default:chest"] = 32
|
||||
specialties.transferAmount["default:chest_locked"] = 42
|
||||
specialties.transferAmount["default:furnace"] = 8
|
||||
specialties.transferAmount["default:rail"] = 4
|
||||
specialties.transferAmount["default:apple"] = 3
|
||||
specialties.transferAmount["default:dry_shrub"] = 1
|
BIN
textures/specialties_greenthumb.png
Normal file
BIN
textures/specialties_greenthumb.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 485 B |
BIN
textures/specialties_superheat.png
Normal file
BIN
textures/specialties_superheat.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 703 B |
35
xp.lua
Normal file
35
xp.lua
Normal file
@ -0,0 +1,35 @@
|
||||
--File Manipulating
|
||||
specialties.writeXP = function(player, specialty, amount)
|
||||
local file = io.open(minetest.get_worldpath().."/"..player.."_"..specialty, "w")
|
||||
file:write(tostring(amount))
|
||||
file:close()
|
||||
end
|
||||
specialties.readXP = function(player, specialty)
|
||||
local file = io.open(minetest.get_worldpath().."/"..player.."_"..specialty, "r")
|
||||
if file == nil then
|
||||
specialties.writeXP(player, specialty, 0)
|
||||
return 0
|
||||
end
|
||||
local xp = file:read("*number")
|
||||
file:close()
|
||||
return xp
|
||||
end
|
||||
|
||||
--Table Modification
|
||||
specialties.changeXP = function(player, specialty, amount)
|
||||
local current = specialties.players[player][specialty]
|
||||
if current+amount >= 0 then
|
||||
specialties.players[player][specialty] = current+amount
|
||||
print(specialties.players[player][specialty])
|
||||
return true
|
||||
else
|
||||
return false
|
||||
end
|
||||
end
|
||||
|
||||
--XP Updates
|
||||
specialties.updateXP = function(player)--Called every 10 seconds
|
||||
for skill,_ in pairs(specialties.skills) do
|
||||
specialties.writeXP(player, skill, specialties.players[player][skill])
|
||||
end
|
||||
end
|
Loading…
Reference in New Issue
Block a user