-- function hides ALL peasant weapons function HideAllPeasantWeapons(self) local objList1 = RetrievePeasantObjects("draftWeapons") local objList2 = RetrievePeasantObjects("normalWeapons") HideAllSubObjects(self,objList1) HideAllSubObjects(self,objList2) end
-- PEASANT FUNCTIONS -- aka. chris' "fun with lua" day function RetrievePeasantObjects(category) -- Initialize table and keys because BFME's lua is a mess local objects = {} local a = "wearables" local b = "headParts" local c = "helmets" local d = "draftWeapons" local e = "normalWeapons" local f = "tools" local g = "draftedHeadParts" -- Assign values to each key objects[a] = {"CLOAK1","CLOAK2","CAP1","CAP2","HOOD"} objects[b] = {"BARE_HAIR","BARE_NBEARD","HELM_NBEARD","HELM_HAIR"} objects[c] = {"DHELM1","DHELM2","DHELM3","DHELM4","DHELM5"} objects[d] = {"SPEAR","NICESWORD","AXE1","AXE2"} objects[e] = {"PITCHFORK","SCYTHE","STAFF","ROUGHSWORD","CLEAVER","SICKLE","ROUGHAXE1","ROUGHAXE2"} objects[f] = {"HAMMER1","HAMMER2","LARGEHAMMER"} objects[g] = {"DBARE_HAIR","DBARE_NBEARD","DHELM_NBEARD","DHELM_HAIR"} -- Return wanted values return objects[category] end -- This function hides a set of subobjects -- -------------------------------------------------- -- # Inputs: self: an instance of the object -- # subObjectTable: a table containing strings naming all the subobjects to be hidden function HideAllSubObjects(self,subObjectTable) -- for all objects in the subObjectTable local length = getn(subObjectTable) for i=1,length do -- hide the subobject. ObjectHideSubObjectPermanently( self, subObjectTable[i], true ) end end
I've found another way to do what I want (I think), so this isn't relevant anymore. However, I would still like to know what's going wrong...