As captioned, I want a script to find the name of Weapon type base on Classes' traits.
But have no idea how to do it.
internally, the engine works on ID-numbers and not names. A good part of the names in the editor aren't even stored for the engine because of this.
As a result you have to check the ID-numbers to find the traits you want to identify. You can get those easily from the weapon type list in the editor as the IDs are automatically the numbers counted from the top down.
Is this enough help? If not you need to specify which part gives you the most problems and screenshot what you already have.
But I have no idea how to check the ID from Trait.
I would like to create a weapon treasury base on class. It is ok if the character equip a weapon:
$gameParty.members()[0].equips()[0].wtypeId
But if the character is bare hand, an error occured.
That's why I want to get the ID/name from Trait.
then why don't you do this based on class itself?
that is actually much easier to check than the trait data.
and you as the developer have that correlation "this class has these weapon types" outside of the game data.
Trait data does the same thing as you have. You have to cater for no weapon being equipped:
$gameParty.members()[0].equips()[0] ? $gameSystem.weaponTypes[$gameParty.members()[0].equips()[0].wtypeId] : ""
"If a weapon is equipped, give me its name, otherwise give me an empty string"
Edit: changed to give the name and not just the id.