Jump to content

How to make an item use batteries and how to effect the character


Sejemus

Recommended Posts

Hello fellow survivers.

I'm trying to get into modding, but I am unfamilliar with Lua.

I am familliar with programming in other languages and I do understand most of the modding aspects.

But how do I make an item use batteries? and how do I make an item do something to the character? Like drying yourself when you're wet, like a towel?

 

Thanks in advance.

-Sejemus

 

Link to comment
Share on other sites

If you can't find a tutorial for it then maybe you need to be "the guy" to write one :)

If you want to do stuff that no one has done before, then you'll need to find it out on your own. You could also simply download mods and read through their source code - they might do what you want to do, or at least something similar.

I'm going to move this thread to the correct section.

Link to comment
Share on other sites

Yea, I do download mods to see what to do, mainly to see how I make mods for build 25+

But I actually thought that someone would've made a mod with items that ran on batteries before ^^

But it doesn't appear to be the case then. Thanks anyway. I'll try the getModData() function and see if I can figure it out.

I found a tutorial for that on the pzmods.net website :)

Link to comment
Share on other sites

The game resources are your best friend sejemus. When i started with lua coding/modding a few weeks ago, i did not read a single tutorial (at least until i had to know about available events, etc.). What i did was analyzing the lua files of the AddBuilding mod, and when i got a basic understanding of the files involved i started with my own mod, learning step by step what i needed.

 

So here's what i would do in your case. First, as RoboMat has suggested too, look if there is a mod which has a similar function (e.g. adds an item using batteries). If there is one, analyse that mod. If there is no similar mod, then search the orignal lua file which handles the add/remove battery to flashlight. Most likely the important steps are done by java functions (you find most of them here: http://theindiestone.com/zomboidjavadocs/), but there will be a lua file which at least triggers the event. Look in files like ISContextMenu (or how they all are called), or use WinGrep to scan all lua files for keywords like "battery". Study that lua file, look what other files are involved etc. then start rebuilding that file by copy pasting the parts you need and modifying them so they do what you want them to do. Dont forget to give them different names so they dont override the original game files (if you dont need them to do so explicitly).

 

 

EDIT: i helped you a little bit by scanning the lua files for "battery". here's the result, you might want to check those files mention below first.

 

 

media\lua\client\BuildingObjects\ISUI\ISBuildMenu.lua

media\lua\client\ISUI\ISWorldObjectContextMenu.lua

media\lua\server\Items\SuburbsDistributions.lua

media\lua\server\recipecode.lua

media\lua\shared\Translate\EN\Tooltip_EN.txt

media\lua\shared\Translate\Recipes_empty.txt

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