Jump to content

Mose

Member
  • Posts

    6
  • Joined

  • Last visited

Profile Information

  • Gender
    Not Telling

Mose's Achievements

  1. Mose

    Wearing Containers

    I am still working on something similar to this. I would like to go through the player's inventory and compare the modData of each item to something. If possible I'd like to do something like this for each item in the inventory if item.getModData().foo = foo then return true;endHow would I go about it?
  2. Mose

    Wearing Containers

    Does "java.lang.ClassCastException: zombie.inventory.types.InventoryContainer cannot be cast to zombie.inventory.types.Clothing" mean it's currently impossible? There is no such thing as impossible in coding. "Impossible" is a term used to describe a situation where "something takes more effort and time than it's worth". Your error means the item type "Clothing" is the only 'java object class' that can be equiped on the torso etc in the way your code currently works. I was just curious if that particular error that was caused by something I can't modify through lua. The only reason I thought that might be the case is that the game became unresponsive while repeatedly giving that error. So far I've only had minor non-game-crashing bugs.
  3. Mose

    Wearing Containers

    When I finally got a container item into the torso slot, I got this error repeatedly. Does "java.lang.ClassCastException: zombie.inventory.types.InventoryContainer cannot be cast to zombie.inventory.types.Clothing" mean it's currently impossible?
  4. Mose

    Wearing Containers

    Okay. First of all, testItem shouldn't be at line 330, line 330 is a different function that doesn't have that variable. it should be at line 140. Sorry! They are actually at different places in the file. I just pasted in what I added to those files so I wasn't pasting hundreds of lines of code. If you end up looking in the files I attached, I added "--TacticalClothing" before the lines I added so they can easily be found.
  5. Mose

    Wearing Containers

    Well, it might be usefull to explain what it is that does go wrong, and in what way it isn't working. Error, crash, not doing anything, only working sometimes, it's not showing x on y, etc. If it gives an error, show us what error is in your log. Right sorry. With what I've done so far, I think the TacticalVest should have the context menu option "Wear" but it doesn't. I didn't receive any errors though.
  6. Mose

    Wearing Containers

    Can someone check this for me? I'm not sure what I'm doing wrong. I don't actually know much about coding. I'm attempting to make "tactical clothing" or "cargo clothing." I basically want to make it so the clothing I add has storage. To do this I attempted to give containers with "CanBeEquipped = Top" the ability to be right clicked for the Wear context menu option. I tried to base it off of the back equipable items but make it so they get equipped to the clothing slots instead of the back slot. So far here is what I've done. I've also attached the files if that makes things easier. module Test{ item TacticalVest { Palettes = Vest_Black, BodyLocation = Top, PalettesStart = Vest_, Type = Container, Temperature = 5, SpriteName = Vest, DisplayName = Tactical Vest, Icon = Vest, Capacity = 10, WeightReduction = 75, CanBeEquipped = Top, } }I've modified "ISInventoryPaneContextMenu.lua" (around line 330) if instanceof(testItem, "InventoryContainer") and testItem:canBeEquipped() == "Top" then canBeEquippedTop = true; end if instanceof(testItem, "InventoryContainer") and testItem:canBeEquipped() == "Bottoms" then canBeEquippedBottom = true; end if canBeEquippedTop and not unequip and not getSpecificPlayer(player):getClothingItem_Torso() then context:addOption(getText("ContextMenu_Wear"), items, ISInventoryPaneContextMenu.onWearItems, player); end if canBeEquippedBottom and not unequip and not getSpecificPlayer(player):getClothingItem_Legs() then context:addOption(getText("ContextMenu_Wear"), items, ISInventoryPaneContextMenu.onWearItems, player); endThen changed "ISWearClothing.lua" (around line 27) function ISWearClothing:perform() self.item:getContainer():setDrawDirty(true); self.item:setJobDelta(0.0); if instanceof(self.item, "InventoryContainer") and self.item:canBeEquipped() == "Back" then self.character:setClothingItem_Back(self.item); getPlayerData(self.character:getPlayerNum()).playerInventory:refreshBackpacks(); elseif instanceof(self.item, "InventoryContainer") and self.item:canBeEquipped() == "Top" then self.character:setClothingItem_Torso(self.item); getPlayerData(self.character:getPlayerNum()).playerInventory:refreshBackpacks(); elseif instanceof(self.item, "InventoryContainer") and self.item:canBeEquipped() == "Bottoms" then self.character:setClothingItem_Legs(self.item); getPlayerData(self.character:getPlayerNum()).playerInventory:refreshBackpacks(); else if self.item:getBodyLocation() == ClothingBodyLocation.Top then self.character:setClothingItem_Torso(self.item); elseif self.item:getBodyLocation() == ClothingBodyLocation.Shoes then self.character:setClothingItem_Feet(self.item); elseif self.item:getBodyLocation() == ClothingBodyLocation.Bottoms then self.character:setClothingItem_Legs(self.item); end end self.character:initSpritePartsEmpty(); triggerEvent("OnClothingUpdated", self.character)--~ self.character:SetClothing(self.item:getBodyLocation(), self.item:getSpriteName(), self.item:getPalette()); -- needed to remove from queue / start next. ISBaseTimedAction.perform(self);endTacticalClothing.zip
×
×
  • Create New...