Jump to content

How to add custom item interaction between existing items?


MXXIV

Recommended Posts

Imagine, for example, I wanted to allow user to use crowbar to destroy crates. What are the steps? Which tutorials should I read? I already read the pinned ones but there's nothing about interactions at all.

 

I have big respect for people making mods here because the state of the docs is terrible.

Link to comment
Share on other sites

I agree that the modding documentation is a bit scarce, or rather outdated, but that's understandable seeing that the game is in alpha and new things are being added (moving furniture is the latest stable feature added) - still would love to see some documentation on the matter someday *hint hint developers :P*

I haven't ventured much into making mods, but from what I know, these properties are apparently stored in ProjectZomboid\media\*.tiles tile definition files. These can be viewed by using the Tool menu of TileZed editor and hovering over the item, however, I see no option of editing them, most likely since the TileZed itself is outdated :( (idk if there's a replacement for it?)

Anyway, that's all I can tell you, hopefully someone more keen on the matter could aid you more. Either way, let us know if you find a way to do so, as I'm curious myself - I was wondering if there's a way to easily see (and change) the container weights, which is another propery that was recently added in build 34.

Link to comment
Share on other sites

I remember somewhere on the forums there is a unpacker to edit tiles don't remember where though

http://theindiestone.com/forums/index.php/topic/2473-how-to-mod-the-textures/?p=46190

 

 

Wait what? You can move furniture? How?

I just realized that what you were asking was destroying things, not picking them up :P My bad, I was sleepy. Then I don't know how to mod this up.

To move things, however, you use the icon that is below the crafting section. You can pickup most 1-tile objects, windows and floor tiles, some require tools and skills to move and have chance to break when picking up though. It was implemented in Build 33 IIRC.

Link to comment
Share on other sites

I agree that the modding documentation is a bit scarce, or rather outdated

 

Gotta rant a bit here as well. The documentation isn't even the problem, imo the problem is the lack of streamlining, organisation, and basic commenting.

 

We've got some data in .txt files, some is in random .lua files, some data is accessible via lua tables, some is in java, some is in .tiles coming from mapping tools, and the rest works in mysterious ways that noboby is going to figure out any time soon.

 

Example Fridges:

public ItemContainer(int ID, String containerName, IsoGridSquare square, IsoObject parent, int wid, int hei){[...]    if (containerName.equals("fridge"))    {        this.ageFactor = 0.02F;        this.CookingFactor = 0.0F;    }}

Yep, the data for fridges is apparently hardcoded into the ItemContainer constructor...

 

/rant off

Link to comment
Share on other sites

Wait you guys misunderstood. I was asking about general pattern for adding item interactions. Not just specifically crates, or specifically destroying.

 

Well, to answer your question instead of just ranting: It's possible to make this work by writing a lua script that adds a new option to the interaction menu. It could look something like this:

checkIfWeWantNewMenuOption = function( playerId, context, worldObjects )   --(some code here that checks if crowbar is equipped)   --(and some code here that checks if one of the clicked objects is a crate)   context:addOption("Break crate", breakTheCrate)endEvents.OnFillWorldObjectContextMenu.Add( checkIfWeWantNewMenuOption )breakTheCrate = function()    --destroy crateend

The best way to figure out things like that is to simply look at other modder's code.

 

Here's RoboMat's old Lockpicking mod:

http://theindiestone.com/forums/index.php/topic/33-lockpicking-mod-180/

 

That one's pretty old, maybe you can find a newer mod that does something similar.

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...