Aeronx
Intermediate OT User
- Joined
- Dec 17, 2015
- Messages
- 735
- Solutions
- 9
- Reaction score
- 119
Hello guys!
I've been trying all day long, searched the whole internet, but i have been totally unsuccesfull and i am on my nerves lol
I have this table:
Monsters names have level. So instead of being for example "gang member" name is "gang member [Lv.1]"
Before i could easily use this:
But now it doesnt recognize the name. So to avoid making this table 10000xtimes I wanted to somehow get the monster name
but erase the part [Lv.X] or check the name if contains at least "gang member" on its name.
To try to accomplish this i have used string.find, gsub, and many others that i found here and other forums, but i totally failed.
Any help would be welcome!
This is the whole code in case you need it:
Thanks for your time.
I've been trying all day long, searched the whole internet, but i have been totally unsuccesfull and i am on my nerves lol
I have this table:
Lua:
local config = {
['gang member'] = {amount = 20, storage = 21901, startstorage = 45553, startvalue = 1},
['smuggler'] = {amount = 20, storage = 21902, startstorage = 45553, startvalue = 1},
['orc'] = {amount = 10, storage = 21903, startstorage = 45553, startvalue = 2},
['orc warrior'] = {amount = 10, storage = 21904, startstorage = 45553, startvalue = 2},
['orc berserker'] = {amount = 5, storage = 21905, startstorage = 45553, startvalue = 2},
['orc shaman'] = {amount = 5, storage = 21906, startstorage = 45553, startvalue = 2},
['elf'] = {amount = 20, storage = 21907, startstorage = 45553, startvalue = 3},
['elf scout'] = {amount = 15, storage = 21908, startstorage = 45553, startvalue = 3},
['elf arcanist'] = {amount = 5, storage = 21909, startstorage = 45553, startvalue = 3},
['cyclops'] = {amount = 20, storage = 21910, startstorage = 45553, startvalue = 4},
['cyclops drone'] = {amount = 10, storage = 21911, startstorage = 45553, startvalue = 4},
['cyclops smith'] = {amount = 5, storage = 21912, startstorage = 45553, startvalue = 4},
['lizard sentinel'] = {amount = 30, storage = 21914, startstorage = 45554, startvalue = 2},
['lizard snakecharmer'] = {amount = 30, storage = 21915, startstorage = 45554, startvalue = 2},
['lizard templar'] = {amount = 30, storage = 21916, startstorage = 45554, startvalue = 2},
['dragon'] = {amount = 100, storage = 21917, startstorage = 45554, startvalue = 4},
['yeti'] = {amount = 100, storage = 21919, startstorage = 45555, startvalue = 2},
['frost dragon'] = {amount = 50, storage = 21920, startstorage = 45555, startvalue = 3},
}
Monsters names have level. So instead of being for example "gang member" name is "gang member [Lv.1]"
Before i could easily use this:
Lua:
local monster = config[target:getName():lower()]
but erase the part [Lv.X] or check the name if contains at least "gang member" on its name.
To try to accomplish this i have used string.find, gsub, and many others that i found here and other forums, but i totally failed.
Any help would be welcome!
This is the whole code in case you need it:
Lua:local config = { ['gang member'] = {amount = 20, storage = 21901, startstorage = 45553, startvalue = 1}, ['smuggler'] = {amount = 20, storage = 21902, startstorage = 45553, startvalue = 1}, ['orc'] = {amount = 10, storage = 21903, startstorage = 45553, startvalue = 2}, ['orc warrior'] = {amount = 10, storage = 21904, startstorage = 45553, startvalue = 2}, ['orc berserker'] = {amount = 5, storage = 21905, startstorage = 45553, startvalue = 2}, ['orc shaman'] = {amount = 5, storage = 21906, startstorage = 45553, startvalue = 2}, ['elf'] = {amount = 20, storage = 21907, startstorage = 45553, startvalue = 3}, ['elf scout'] = {amount = 15, storage = 21908, startstorage = 45553, startvalue = 3}, ['elf arcanist'] = {amount = 5, storage = 21909, startstorage = 45553, startvalue = 3}, ['cyclops'] = {amount = 20, storage = 21910, startstorage = 45553, startvalue = 4}, ['cyclops drone'] = {amount = 10, storage = 21911, startstorage = 45553, startvalue = 4}, ['cyclops smith'] = {amount = 5, storage = 21912, startstorage = 45553, startvalue = 4}, ['lizard sentinel'] = {amount = 30, storage = 21914, startstorage = 45554, startvalue = 2}, ['lizard snakecharmer'] = {amount = 30, storage = 21915, startstorage = 45554, startvalue = 2}, ['lizard templar'] = {amount = 30, storage = 21916, startstorage = 45554, startvalue = 2}, ['dragon'] = {amount = 100, storage = 21917, startstorage = 45554, startvalue = 4}, ['yeti'] = {amount = 100, storage = 21919, startstorage = 45555, startvalue = 2}, ['frost dragon'] = {amount = 50, storage = 21920, startstorage = 45555, startvalue = 3}, } function onKill(player, target) --local player, target = Player(player), Creature(target) -- for TFS 1.0, delete this line if you use 1.1 local monster = config[target:getName():lower()] if target:isPlayer() or not monster or target:getMaster() then return true end local stor = player:getStorageValue(monster.storage)+1 if stor < monster.amount and player:getStorageValue(monster.startstorage) >= monster.startvalue then player:setStorageValue(monster.storage, stor) player:sendTextMessage(MESSAGE_STATUS_CONSOLE_ORANGE, 'Task message: '..(stor +1)..' of '..monster.amount..' '..target:getName()..'s killed.') end if (stor +1) == monster.amount then player:sendTextMessage(MESSAGE_INFO_DESCR, 'Congratulations, you have killed '..(stor +1)..' '..target:getName()..'s and completed the '..target:getName()..'s mission.') player:setStorageValue(monster.storage, stor +1) end return true end
Thanks for your time.