Conversation
Znote
left a comment
There was a problem hiding this comment.
Beautiful and educational code that works great as a sample on how to metatablify something. :)
|
Thanks @marmichalski, not sure why this pr had so much of weird code, but it was pretty old too. |
I think @nekiro 's thought process deserves an entry in the wiki ;) |
Are you rude??? |
|
This did not work as good as I was hoping for, got time to test it out today: local talkaction = TalkAction("!hello")
function talkaction.onSay(player)
print(player:getName() .. ' executed talkaction: !hello')
tdump("player:getOutfit()", player:getOutfit())
tdump("Outfit(140)", Outfit(140))
tdump("Outfit(140) == Outfit(140) -- Noblewoman == Noblewoman", Outfit(140) == Outfit(140))
tdump("Outfit(140) == player:getOutfit() -- Noblewoman == Noblewoman", Outfit(140) == player:getOutfit())
tdump("Outfit(140) == Outfit(151) -- Noblewoman == Pirate", Outfit(140) == Outfit(151))
tdump("Outfit(140) == Outfit(132) -- Noblewoman == Nobleman", Outfit(140) == Outfit(132))
return true
end
talkaction:register()I think there should be a bit more consistency between
Is there no way to compare "matching set across gender"? I want I find it a bit redundant to first get player outfit, then initialize a new outfit object before I can compare it. local noblewoman = Outfit(140)
if noblewoman ~= Outfit(player:getOutfit().lookType) then
-- Only fancy rich women allowed!
endIt would also be cool to initialize an Outfit by the name. -- Sexy code
if player:getOutfit() == Outfit("Noblewoman") then
-- ...
end |
|
@Znote but an outfit is more than just the looktype, there are colors, addons, gender and more as you shown. How do you want two outfits to equal when the only value that is equal is the looktype? It should read It equals when you do Edit: ah, now I see the problem with the outfit gender. I don't think there's an easy way to fix it, since there's no "gender" to outfits, there are two instances of each. |
|
I argue that since the object is created from lookType, it should be able to match against player:getOutfit(), it doesn't matter which colours you dress, your either wearing noblewomen or your not. I would rather take an extra step in the code if the color mattered, instead of vice versa. But even this: if player:getOutfit().lookType == Outfit("Noblwomen").lookType then
-- ...
endWould be a nice improvement, I doubt everyone remembers what lookType 140 is, but if its initialized as "Noblewomen" (or OUTFIT_NOBLEWOMEN) if we wanna use enums, then its pretty easy to understand what outfit we are working with, what outfit we want the player to have. Yeah I figured the gender match was a stretch, the XML file at least has to be structured differently to accomodate gender groupings of outfits. |
|
@Znote you're mixing something I'd call PlayerOutfit with XmlOutfit. |
|
Maybe call OutfitType metatable instead |

This pr adds Outfit() metatable to use in lua. Helpful in cases when you for example need to get name of outfit from looktype.
Outfit(looktype)
and outfit compare method