Єϰтɛи∂ɛ∂ Ѳʋтғιт LIB
rev 0.7
rev 0.7
Well, this is a complete library of functions which allow you to obtain the ID or name of any outfit that you have in your OT. The library has been specially made with many tests to avoid errors in your console, though if you find one you can post it here to fix it. You can use this on a NPC, a player or a monster. There are error warnings that will show up in case there is a conflict in any function.
I want to thank Mock for fixing the LuaXML functions and Swij for the names list.
-FUNCTIONS:
Lua:
isOutfit(lookType)
getOutfitNameById(id)
getOutfitNameByLookType(lookType)
getCreatureOutfitId(cid)
getCreatureOutfitName(cid)
getOutfitIdByName(name)
getOutfitIdByLookType(lookType)
getOutfitLookTypeByName(name)
doCreatureChangeOutfitByName(cid, name)
-SETUP:
Create this script @ data/lib/099-outfits.lua
Lua:
--[[ / / / / / / / / / / / / / / / / / / / / / /
OutfitLIB 0.7
Cybermaster && Mock The Bear
Outfits updated until 8.54
OTLand.net
isOutfit(lookType)
getOutfitNameById(id)
getOutfitNameByLookType(lookType)
getCreatureOutfitId(cid)
getCreatureOutfitName(cid)
getOutfitIdByName(name)
getOutfitIdByLookType(lookType)
getOutfitLookTypeByName(name)
doCreatureChangeOutfitByName(cid, name)
/ / / / / / / / / / / / / / / / / / / / / / ]]--
local setup = {
XML = '';
null = {0,1,135},
range = {161,191},
other = {302,266,75,255,254,253,160,159,12},
idMin = 1,
idMax = 35
}
local error = {
[1] = '[Warning - Error::OutfitLIB] Outfit ID is not valid.',
[2] = '[Warning - Error::OutfitLIB] Outfit looktype is not valid.',
[3] = '[Warning - Error::OutfitLIB] Creature not found.',
[4] = '[Warning - Error::OutfitLIB] Outfit ID is not at range. ('..setup.idMin..'~'..setup.idMax..')',
[5] = '[Warning - Error::OutfitLIB] Outfit name does not match.'
}
local list = {
[2]='Orc Warlord',[3]='War Wolf',[4]='Orc Rider',[5]='Orc',[6]='Orc Shaman',
[7]='Orc Warrior',[8]='Orc Berserker',[9]='Necromancer',[10]='Yellow Butterfly',
[11]='Water Elemental',[13]='Black Sheep',[14]='Sheep',[15]='Troll',
[16]='Bear',[17]='Beholder',[18]='Ghoul',[19]='Slime',[20] ='Quara Predator',[21]='Rat',
[22]='Cyclops',[23]='Minotaur Mage',[24]='Minotaur Archer',[25]='Minotaur',[26]='Rotworm',
[27]='Wolf',[28]='Snake',[29]='Minotaur Guard',[30]='Spider',[31]='Deer',[32]='Dog',
[33]='Skeleton',[34]='Dragon',[35]='Demon',[36]='Poison Spider',[37]='Demon Skeleton',
[38]='Giant Spider',[39]='Dragon Lord',[40]='Fire Devil',[41]='Lion',[42]='Polar Bear',
[43]='Scorpion',[44]='Wasp',[45]='Bug',[46]='Quara Constrictor',[47]='Quara Hydromancer',
[48]='Ghost',[49]='Fire Elemental',[50]='Orc Spearman',[51]='Green Djinn',[52]='Winter Wolf',
[53]='Frost Troll',[54]='Witch',[55]='Behemoth',[56]='Cave Rat',[57]='Monk',[58]='Priestess',
[59]='Orc Leader',[60]='Pig',[61]='Goblin',[62]='Elf',[63]='Elf Arcanist',[64]='Elf Scout',
[65]='Mummy',[66]='Dwarf Geomancer',[67]='Stone Golem',[68]='Vampire',[69]='Dwarf',
[70]='Dwarf Guard',[71]='Dwarf Soldier',[72]='Quara Mantassin',[73]='Hero',[74]='Rabbit',
[76]='Swamp Troll',[77]='Quara Pincher',[78]='Banshee',[79]='Ancient Scarab',
[80]='Blue Djinn',[81]='Cobra',[82]='Larva',[83]='Scarab',[84]='Ormuc',[85]='Morguthis',
[86]='Thalas',[87]='Dipthrah',[88]='Arkhothep',[89]='Mahrdis',[90]='Vashresamun',
[91]='Ashmunrah',[92]='Mimic',[93]='Pirate Marauder',[94]='Hyaena',[95]='Gargoyle',
[96]='Pirate Cutthroat',[97]='Pirate Buccaneer',[98]='Pirate Corsair',[99]='Lich',
[100]='Crypt Shambler',[101]='Bone Beast',[102]='Deathslicer',[103]='Efreet',[104]='Marid',
[105]='Badger',[106]='Skunk',[107]='Demon',[108]='Elder Beholder',[109]='Gazer',[110]='Yeti',
[111]='Chicken',[112]='Crab',[113]='Lizard Templar',[114]='Lizard Sentinel',
[115]='Lizard Snakecharmer',[116]='Kongra',[117]='Merlkin',[118]='Sibang',[119]='Crocodile',
[120]='Carniphila',[121]='Hydra',[122]='Bat',[123]='Panda',[124]='Centipede',[125]='Tiger',
[126]='Old Woman',[127]='Old Man',[192]='Carrion Worm',[193]='Enlightened Of The Cult',
[194]='Adept Of The Cult',[195]='Pirate Skeleton',[196]='Pirate Ghost',[197]='Tortoise',
[198]='Thornback Tortoise',[199]='Mammoth',[200]='Blood Crab',[201]='Demon',
[202]='Minotaur Guard',[203]='Elf Arcanist',[204]='Dragon Lord',[205]='Stone Golem',
[206]='Monk',[207]='Minotaur Guard',[208]='Giant Spider',[209]='Necromancer',
[210]='Elder Beholder',[211]='Elephant',[212]='Flamingo',[213]='Purple Butterfly',
[214]='Dworc Voodoomaster',[215]='Dworc Fleshhunter',[216]='Dworc Venomsniper',
[217]='Parrot',[218]='Terror Bird',[219]='Tarantula',[220]='Serpent Spawn',
[221]='Spit Nettle',[222]='Toad',[223]='Seagull',[224]='Green Frog',[225]='Monk',
[226]='Frog',[227]='Blue Butterfly',[228]='Red Butterfly',[229]='Ferumbras',
[230]='Hand Of Cursed Fate',[231]='Undead Dragon',[232]='Lost Soul',[233]='Betrayed Wraith',
[234]='Dark Torturer',[235]='Spectre',[236]='Destroyer',[237]='Diabolic Imp',
[238]='Defiler',[239]='Wyvern',[240]='Hellhound',[241]='Phantasm',
[242]='Blistering Fire Elemental',[243]='Hellfire Fighter',[244]='Juggernaut',
[245]='Nightmare',[246]='Blightwalker',[247]='Plaguesmith',[248]='Frost Dragon',
[249]='Chakoya Tribewarden',[250]='Penguin',[256]='Braindeath',[257]='Frost Giant',
[258]='Husky',[259]='Chakoya Toolshaper',[260]='Chakoya Windcaller',[261]='Ice Golem',
[262]='Silver Rabbit',[263]='Crystal Spider',[264]='Barbarian Brutetamer',
[265]='Frost Giantess',[267]='Swimsuit',[271]='Dragon Hatchling',
[272]='Dragon Lord Hatchling',[274]='Squirrel',[275]='Sea Serpent',[276]='Cat',
[277]='Cyclops Smith',[280]='Cyclops Drone',[281]='Troll Champion',
[282]='Island Troll',[283]='Frost Dragon Hatchling',[284]='Cockroach',
[285]='Massive Earth Elemental',[286]='Water Elemental',[287]='Vampire Overlord',
[290]='Massive Energy Elemental',[291]='Wyrm',[292]='Mutated Pumpkin',
[293]='Energy Elemental',[294]='Wisp',[295]='Rotworm Queen',[296]='Goblin Assassin',
[297]='Goblin Scavenger',[298]='Skeleton Warrior',[299]='Bog Raider',[300]='Grim Reaper',
[301]='Earth Elemental',[303]='Undead Tortoise',[304]='Worker Golem',[305]='Mutated Rat',
[306]='Undead Gladiator',[307]='Mutated Bat',[308]='Werewolf',[309]='Yalahari',
[310]='Haunted Treeling',[311]='Zombie',[312]='Vampire Bride',[313]='Gozzler',
[314]='Acid Blob',[315]='Death Blob',[316]='Mercury Blob',[317]='Young Sea Serpent',
[318]='Mutated Tiger',[319]='Haunted Spirit',[320]='Nightstalker',[321]='Nightmare Scion',
[322]='Hellspawn',[323]='Mutated Human',[326]='War Golem',[327]='Wedding',[330]='Medusa',
[331]='Queen Eloise',[332]='King Tibianus',[333]='Medusa Stone',[334]='Draken Warmaster',
[337]='Lizard High Guard',[338]='Lizard Legionnaire',[339]='Lizard Dragon Priest',
[340]='Draken Spellweaver',[341]='Gnarlhound',[342]='Orc Marauder',[343]='Lizard Zaogun',
[344]='Lizard Chosen',[345]='Eternal Guardian',[346]='Terramite',[347]='Wailing Widow',
[348]='Lancer Beetle',[349]='Insect Swarm',[350]='Sandcrawler',[351]='Ghastly Dragon',
}
function string.fix(s)
return s:gsub("(%a)([%w_']*)", function(first, rest) return first:upper()..rest:lower() end)
end
function isBetweenRange(value, from, to)
return from <= value and value <= to
end
function isOutfit(lookType)
return tonumber(lookType) and not tostring(lookType) and not isInArray(setup.null,lookType) and not isBetweenRange(lookType, setup.range[1], setup.range[2]) and isInArray(setup.other,lookType) or isInArray(maleOutfits,lookType) or isInArray(femaleOutfits,lookType) or list[lookType]
end
function getOutfitNameById(id)
return tonumber(id) == nil and error[1] or isBetweenRange(tonumber(id), setup.idMin, setup.idMax) and (setup.XML:match('<outfit%s*id="'..tonumber(id)..'".->(.-)</outfit>') or ''):match('name="(.-)"') or error[1]
end
function getOutfitNameByLookType(lookType)
t, lookType = '', tonumber(lookType)
if not isOutfit(lookType) then
return error[2]
end
for i, j in pairs(list) do
if lookType == i then
t = j
break
else
t = setup.XML:match('lookType="'..lookType..'"%s*name="(.-)"/>')
end
end
return not tostring(t) and error[2] or t
end
function getCreatureOutfitId(cid)
if not isCreature(cid) then
return error[3]
end
local t = ''
for id, v in setup.XML:gmatch('<outfit.-id="(%d+)".->(.-)</outfit>') do
if v:match('lookType="'..getCreatureOutfit(cid).lookType..'"') then
t = id
break
end
end
return tonumber(t) or error[4]
end
function getCreatureOutfitName(cid)
return not isCreature(cid) and error[3] or list[getCreatureOutfit(cid).lookType] and list[getCreatureOutfit(cid).lookType] or setup.XML:match('lookType="'..getCreatureOutfit(cid).lookType..'"%s*name="(.-)"/>')
end
function getOutfitIdByName(name)
t, name = '', string.fix(name)
if type(name) ~= 'string' then
return error[5]
end
for id, v in setup.XML:gmatch('<outfit.-id="(%d+)".->(.-)</outfit>') do
if v:match('name="'..name..'"') then
t = tonumber(id)
break
end
end
return not tonumber(t) and error[4] or t
end
function getOutfitIdByLookType(lookType)
t, lookType = '', tonumber(lookType)
if not isOutfit(lookType) then
return error[2]
end
for id, v in setup.XML:gmatch('<outfit.-id="(%d+)".->(.-)</outfit>') do
if v:match('lookType="'..lookType..'"%s*name="(.-)"/>') then
t = tonumber(id)
break
end
end
return not tonumber(t) and error[4] or t
end
function getOutfitLookTypeByName(name)
t, name = '', string.fix(name)
if type(name) ~= 'string' then
return error[5]
end
for i, j in pairs(list) do
if name == j then
t = i
break
else
t = setup.XML:match('lookType="(%d+)"%s*name="'..name..'"/>')
end
end
return not tonumber(t) and error[5] or t
end
function doCreatureChangeOutfitByName(cid, name)
return isOutfit(getOutfitLookTypeByName(name)) and doCreatureChangeOutfit(cid, {lookType = getOutfitLookTypeByName(name)})
end
do
local o = io.open('data/XML/outfits.xml','r')
setup.XML = o:read('*a')
o:close()
end
Last edited: