Anonymous

Module:Sandbox/GauTest/Township: Difference between revisions

From Melvor Idle
no edit summary
No edit summary
No edit summary
Line 10: Line 10:
p.Township = Township
p.Township = Township


-- Returns the namespace name (eventually we should use an icon)
function p.PLACEHOLDER_NAMESPACE_ICON(namespace)
local namespaces = {
melvorD = 'Demo',
melvorF = 'Full',
melvorTotH = 'TotH'
}
return namespaces[namespace]
end


-- Returns the recipe for the item of a desired skill.
-- Returns the recipe for the item of a desired skill.
Line 128: Line 119:
end
end
local function matchClothing(item)
local function matchClothing(item)
local valid_tiers = {'Leather', 'Hard Leather', 'Dragonhide', 'Elderwood', 'Revenant', 'Carrion'}
return item.id == 'melvorD:Green_Dragonhide' or item.id == 'melvorD:Blue_Dragonhide' or item.id == 'melvorD:Red_Dragonhide' or item.id == 'melvorD:Black_Dragonhide' or item.id == 'melvorF:Elder_Dragonhide'
for _, tier in ipairs(valid_tiers) do
if item.tier == tier then
return true
end
end
return false
end
end


Line 163: Line 148:
for _, item in ipairs(resource.itemConversions) do
for _, item in ipairs(resource.itemConversions) do
item.toTownship = math.max(math.floor(1000/(item.healsFor*10)), 2)
item.toTownship = math.max(math.floor(1000/(item.healsFor*10)), 2)
item.fromTownship = item.healsFor*5*6
item.fromTownship = item.healsFor*5*6*5
end
end
elseif resource.id == 'melvorF:Planks' then
elseif resource.id == 'melvorF:Planks' then
Line 207: Line 192:
table.insert(ret_resource, '\r\n!Item')
table.insert(ret_resource, '\r\n!Item')
table.insert(ret_resource, '\r\n!Name')
table.insert(ret_resource, '\r\n!Name')
table.insert(ret_resource, '\r\n!DLC')
table.insert(ret_resource, '\r\n!Level')
table.insert(ret_resource, '\r\n!Level')
table.insert(ret_resource, '\r\n!Give To')
table.insert(ret_resource, '\r\n!Give To')
Line 251: Line 235:
table.insert(ret_resource, '\r\n|style="text-align:center"|'..Icons.Icon({item.name, type='item', size='50', notext=true}))
table.insert(ret_resource, '\r\n|style="text-align:center"|'..Icons.Icon({item.name, type='item', size='50', notext=true}))
-- Name
-- Name
table.insert(ret_resource, '\r\n|style="text-align:left"|'..Icons.Icon({item.name, type='item', noicon=true}))
table.insert(ret_resource, '\r\n|style="text-align:left"|'..Icons.getExpansionIcon(item.id)..Icons.Icon({item.name, type='item', noicon=true}))
-- DLC
local item_namespace, item_localid = GameData.getLocalID(item.id)
table.insert(ret_resource, '\r\n|style="text-align:center"|'..p.PLACEHOLDER_NAMESPACE_ICON(item_namespace))
-- Level
-- Level
if required_level == nil then
if required_level == nil then
Line 300: Line 281:
['melvorF:Potions'] = {skill = 'melvorD:Herblore'},
['melvorF:Potions'] = {skill = 'melvorD:Herblore'},
['melvorF:Planks'] = {skill = 'melvorD:Woodcutting'},
['melvorF:Planks'] = {skill = 'melvorD:Woodcutting'},
['melvorF:Clothing'] = {skill = 'melvorD:Crafting'}
['melvorF:Clothing'] = {skill = nil}
}
}
function p._GetResourceSkill(id)
function p._GetResourceSkill(id)
Line 405: Line 386:
-- Biomes
-- Biomes
table.insert(ret, '\r\n|-\r\n| <b>Biomes:</b><br><ul>')
table.insert(ret, '\r\n|-\r\n| <b>Biomes:</b><br>')
for _, biomeid in ipairs(building.biomes) do
for _, biomeid in ipairs(building.biomes) do
local biomename = GameData.getEntityByID(Township.biomes, biomeid).name
local biomename = GameData.getEntityByID(Township.biomes, biomeid).name
Line 416: Line 397:
local color = modifier.value < 0 and 'red' or 'green'
local color = modifier.value < 0 and 'red' or 'green'
local modifier_value = Shared.numStrWithSign(modifier.value)
local modifier_value = Shared.numStrWithSign(modifier.value)
table.insert(ret, '<li style="color:'..color..'"><b>'..biomename..' ('..modifier_value..'%)</b></li>')
table.insert(ret, Icons.Icon({biomename, type='biome', notext=true, nolink=true})..' <span style="color:'..color..'"><b>'..biomename..' ('..modifier_value..'%)</b></span>')
else
else
table.insert(ret, '<li>'..biomename..'</li>')
table.insert(ret, Icons.Icon({biomename, type='biome', notext=true, nolink=true})..' <span>'..biomename..'</span>')
end
end
end
end
Line 536: Line 517:
local color = biome.value < 0 and 'red' or 'green'
local color = biome.value < 0 and 'red' or 'green'
local biome_value = Shared.numStrWithSign(biome.value)
local biome_value = Shared.numStrWithSign(biome.value)
table.insert(biomeRet, '<li style="color:'..color..'">'..biomename..' ('..biome_value..'%)</li>')
table.insert(biomeRet, Icons.Icon({biomename, type='biome', notext=true, nolink=true})..' <span style="color:'..color..'">'..biomename..' ('..biome_value..'%)</span>')
end
end
if #biomeRet == 0 then
if #biomeRet == 0 then
return nil
return nil
end
end
return '<ul>'..table.concat(biomeRet)..'</ul>'
return table.concat(biomeRet, '<br>')
end
end


Line 687: Line 668:
biomeModifiersMaster[biome.id] = false
biomeModifiersMaster[biome.id] = false
end
end
-- Put the icons in the second row
table.insert(ret, '\r\n|-')
table.insert(ret, '\r\n!')
for _, biome in ipairs(Township.biomes) do
table.insert(ret, '\r\n!'..Icons.Icon({biome.name, type='biome', notext=true, nolink=true}))
end
for _, _building in ipairs(p._SortedBuildings()) do
for _, _building in ipairs(p._SortedBuildings()) do
-- Fix melvorF:Statues
-- Fix melvorF:Statues
572

edits