Looking for code optimizers, please
Posted: Fri Oct 05, 2012 6:22 pm
¨Please don't make fun of me
I have been working on a portable scavenging item (it works really great, I will include it in next release of TLC.)
however, my code looks like this (I am a self taught coder
) :
Is there any way to make it "nicer" or more efficient ? I have many codes like this, I would reproduce a possible optimization, it would be very helpfull. Thanks in advance 

I have been working on a portable scavenging item (it works really great, I will include it in next release of TLC.)
however, my code looks like this (I am a self taught coder

Code: Select all
function scavengehammerCheck(mouseitem,champ,slot)
local objecttoscavenge = mouseitem.name
if string.find(objecttoscavenge,"dagger") ~=nil then scavengehammer("weaponsmith","iron_chunks",3,5,champ,slot)
else if string.find(objecttoscavenge,"cutlass") ~=nil then scavengehammer("weaponsmith","iron_chunks",5,7,champ,slot)
else if string.find(objecttoscavenge,"fist_dagger") ~=nil then scavengehammer("weaponsmith","iron_chunks",3,5,champ,slot)
else if string.find(objecttoscavenge,"flail") ~=nil then scavengehammer("weaponsmith","iron_chunks",3,6,champ,slot)
else if string.find(objecttoscavenge,"great_axe") ~=nil then scavengehammer("weaponsmith","iron_chunks",5,7,champ,slot)
else if string.find(objecttoscavenge,"hand_axe") ~=nil then scavengehammer("weaponsmith","iron_chunks",3,5,champ,slot)
else if string.find(objecttoscavenge,"knife") ~=nil then scavengehammer("weaponsmith","iron_chunks",3,5,champ,slot)
else if string.find(objecttoscavenge,"long_sword") ~=nil then scavengehammer("weaponsmith","iron_chunks",5,7,champ,slot)
else if string.find(objecttoscavenge,"machete") ~=nil then scavengehammer("weaponsmith","iron_chunks",4,6,champ,slot)
else if string.find(objecttoscavenge,"shuriken") ~=nil then scavengehammer("weaponsmith","iron_chunks",3,5,champ,slot)
else if string.find(objecttoscavenge,"throwing_axe") ~=nil then scavengehammer("weaponsmith","iron_chunks",3,5,champ,slot)
else if string.find(objecttoscavenge,"throwing_knife") ~=nil then scavengehammer("weaponsmith","iron_chunks",3,5,champ,slot)
else if string.find(objecttoscavenge,"warhammer") ~=nil then scavengehammer("weaponsmith","iron_chunks",5,7,champ,slot)
else if string.find(objecttoscavenge,"battle_axe") ~=nil then scavengehammer("weaponsmith","iron_chunks",5,7,champ,slot)
else if string.find(objecttoscavenge,"arrow") ~=nil then scavengehammer("woodworker","wood_branch",1,1,champ,slot)
else if string.find(objecttoscavenge,"crossbow") ~=nil then scavengehammer("woodworker","wood_branch",1,2,champ,slot)
else if string.find(objecttoscavenge,"knoffer") ~=nil then scavengehammer("woodworker","wood_branch",1,2,champ,slot)
else if string.find(objecttoscavenge,"short_bow") ~=nil then scavengehammer("woodworker","wood_branch",1,2,champ,slot)
else if string.find(objecttoscavenge,"longbow") ~=nil then scavengehammer("woodworker","wood_branch",1,2,champ,slot)
else if string.find(objecttoscavenge,"quarrel") ~=nil then scavengehammer("woodworker","wood_branch",1,1,champ,slot)
else if string.find(objecttoscavenge,"wooden_box") ~=nil then scavengehammer("woodworker","wood_branch",2,4,champ,slot)
else if string.find(objecttoscavenge,"camp_component") ~=nil then scavengehammer("woodworker","wood_branch",1,1,champ,slot)
else if string.find(objecttoscavenge,"torch") ~=nil then scavengehammer("woodworker","wood_branch",1,1,champ,slot)
else if string.find(objecttoscavenge,"legionary_spear") ~=nil then scavengehammer("woodworker","wood_branch",1,3,champ,slot)
else if string.find(objecttoscavenge,"legionary_shield") ~=nil then scavengehammer("armorsmith","iron_chunks",2,4,champ,slot)
else if string.find(objecttoscavenge,"hide_vest") ~=nil then scavengehammer("leathercraft","leather",2,4,champ,slot)
else if string.find(objecttoscavenge,"huntsman_cloak") ~=nil then scavengehammer("leathercraft","leather",1,1,champ,slot)
else if string.find(objecttoscavenge,"leather_boots") ~=nil then scavengehammer("leathercraft","leather",1,1,champ,slot)
else if string.find(objecttoscavenge,"leather_brigandine") ~=nil then scavengehammer("leathercraft","leather",1,2,champ,slot)
else if string.find(objecttoscavenge,"leather_cap") ~=nil then scavengehammer("leathercraft","leather",1,1,champ,slot)
else if string.find(objecttoscavenge,"leather_gloves") ~=nil then scavengehammer("leathercraft","leather",1,1,champ,slot)
else if string.find(objecttoscavenge,"leather_greaves") ~=nil then scavengehammer("leathercraft","leather",1,1,champ,slot)
else if string.find(objecttoscavenge,"leather_pants") ~=nil then scavengehammer("leathercraft","leather",2,3,champ,slot)
else if string.find(objecttoscavenge,"nomad_boots") ~=nil then scavengehammer("leathercraft","leather",1,1,champ,slot)
else if string.find(objecttoscavenge,"nomad_mittens") ~=nil then scavengehammer("leathercraft","leather",1,1,champ,slot)
else if string.find(objecttoscavenge,"sack") ~=nil then scavengehammer("leathercraft","leather",1,2,champ,slot)
else if string.find(objecttoscavenge,"sling") ~=nil then scavengehammer("leathercraft","leather",1,1,champ,slot)
else if string.find(objecttoscavenge,"round_shield") ~=nil then scavengehammer("armorsmith","iron_chunks",4,6,champ,slot)
else if string.find(objecttoscavenge,"heavy_shield") ~=nil then scavengehammer("armorsmith","iron_chunks",6,8,champ,slot)
else if string.find(objecttoscavenge,"plate_boots") ~=nil then scavengehammer("armorsmith","iron_chunks",4,6,champ,slot)
else if string.find(objecttoscavenge,"plate_greaves") ~=nil then scavengehammer("armorsmith","iron_chunks",5,7,champ,slot)
else if string.find(objecttoscavenge,"plate_cuirass") ~=nil then scavengehammer("armorsmith","iron_chunks",6,8,champ,slot)
else if string.find(objecttoscavenge,"plate_gauntlets") ~=nil then scavengehammer("armorsmith","iron_chunks",4,6,champ,slot)
else if string.find(objecttoscavenge,"ring_mail") ~=nil then scavengehammer("armorsmith","iron_chunks",5,7,champ,slot)
else if string.find(objecttoscavenge,"ring_boots") ~=nil then scavengehammer("armorsmith","iron_chunks",4,6,champ,slot)
else if string.find(objecttoscavenge,"ring_gauntlets") ~=nil then scavengehammer("armorsmith","iron_chunks",3,5,champ,slot)
else if string.find(objecttoscavenge,"ring_greaves") ~=nil then scavengehammer("armorsmith","iron_chunks",4,6,champ,slot)
else if string.find(objecttoscavenge,"full_helmet") ~=nil then scavengehammer("armorsmith","iron_chunks",5,7,champ,slot)
else if string.find(objecttoscavenge,"iron_basinet") ~=nil then scavengehammer("armorsmith","iron_chunks",5,7,champ,slot)
else if string.find(objecttoscavenge,"peasant_breeches") ~=nil then scavengehammer("tailor","silk",1,1,champ,slot)
else if string.find(objecttoscavenge,"peasant_tunic") ~=nil then scavengehammer("tailor","silk",1,2,champ,slot)
else if string.find(objecttoscavenge,"peasant_cap") ~=nil then scavengehammer("tailor","silk",1,1,champ,slot)
else if string.find(objecttoscavenge,"loincloth") ~=nil then scavengehammer("tailor","silk",1,1,champ,slot)
else if string.find(objecttoscavenge,"pointy_shoes") ~=nil then scavengehammer("tailor","silk",1,1,champ,slot)
else if string.find(objecttoscavenge,"silk_sac") ~=nil then scavengehammer("tailor","silk",2,3,champ,slot)
else if string.find(objecttoscavenge,"silk_hose") ~=nil then scavengehammer("tailor","silk",1,1,champ,slot)
else if string.find(objecttoscavenge,"cloak") ~=nil then scavengehammer("tailor","silk",1,2,champ,slot)
else if string.find(objecttoscavenge,"bandages") ~=nil then scavengehammer("tailor","silk",1,2,champ,slot)
else
hudPrint("You cannot scavenge this item.")
end
end end end end end end end end end end end end end end end end end end end end end end end end end
end end end end end end end end end end end end end end end end end end end end end end end end
end end end end end end end
end end
