Jump to content

Anything like an OnPlayerEquipBag?


mads232

Recommended Posts

Hello, I checked out various modding tutorials and the Event Reference.

 

But I couldn't find something like OnPlayerEquipOnBack or something like that.

Did I overlook something, or isn't this created?

Is it possible to make such a thing?

 

-Thanks in forwards! :)

Link to comment
Share on other sites

It is possible. You need to overload the ISWearClothing:perform function like this:

require 'TimedActions/ISWearClothing'MyModName = {}MyModName.ISWearClothingOrigPerform = ISWearClothing.perform;ISWearClothing.perform = function(self)  -- call original function  MyModName.ISWearClothingOrigPerform(self)  if instanceof(self.item, "InventoryContainer") and self.item:canBeEquipped() == "Back" then    -- Do something if item gets equipped on back  else    if self.item:getBodyLocation() == ClothingBodyLocation.Top then     -- Do something if item is worn on upper body    elseif self.item:getBodyLocation() == ClothingBodyLocation.Shoes then      -- Do something if item is worn on lower body    elseif self.item:getBodyLocation() == ClothingBodyLocation.Bottoms then      -- Do something if item is worn on feet    end  endend

Put this into Zomboid/mods/MyModName/media/lua/client/MyModName_ISWearClothing.lua and you should be ready to go.

Link to comment
Share on other sites

  • 5 weeks later...
Also, if you want know when a item is wear or undress, use a event OnClothingUpdated(player).

With the player, you can take de primary, secondary or clothing items with his gets.

 

For example:



UpdateCloth = function(player)
  local shoes = player:getClothingItem_Feet();
  -- do something with shoes
end


Events.OnClothingUpdated.Add(UpdateCloth);


Javadoc IsoPlayer gets:


Link to comment
Share on other sites

  • 6 years later...
On 3/13/2015 at 2:11 PM, blindcoder said:

It is possible. You need to overload the ISWearClothing:perform function like this:

require 'TimedActions/ISWearClothing'MyModName = {}MyModName.ISWearClothingOrigPerform = ISWearClothing.perform;ISWearClothing.perform = function(self)  -- call original function  MyModName.ISWearClothingOrigPerform(self)  if instanceof(self.item, "InventoryContainer") and self.item:canBeEquipped() == "Back" then    -- Do something if item gets equipped on back  else    if self.item:getBodyLocation() == ClothingBodyLocation.Top then     -- Do something if item is worn on upper body    elseif self.item:getBodyLocation() == ClothingBodyLocation.Shoes then      -- Do something if item is worn on lower body    elseif self.item:getBodyLocation() == ClothingBodyLocation.Bottoms then      -- Do something if item is worn on feet    end  endend

Put this into Zomboid/mods/MyModName/media/lua/client/MyModName_ISWearClothing.lua and you should be ready to go.

This was really helpful for me. Thanks

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...