Jump to content

Clarification on "How to" mod


Diogeno

Recommended Posts

Hello survivors,

I just recently started to put my hands on the lua language, knowing a bit of C and Java and I would like to ask your modus operandi for modding Project Zomboid.

Let me explain(and please correct me if I write monstruosity):

I'm writing simple .lua where I add items, change values etcetc. and i'm doing it reading both the Javadoc (http://theindiestone.com/zomboidjavadocs/) and the events that i found here(http://pz-mods.net/guide/event-reference/).

When I change something and I want to test it with the game opened, I save the .lua, disable the mod in the game menu' and then enable it again and load a save to see the changes.

 

The problem  is that the whole thing is time consuming since sometimes I do not know the use of what is in Javadoc, sometimes events don't work as I think they should and my way of testing the whole thing looks to me a lot unprofessional.

 

A simple example of what I mean:

 

I was using the  event OnWeaponSwingHitPoint (in that site is written that it "Triggers when the player succesfully attack and hit a zombie") and I was interpreting it something like " OnHit && OnAttack" while it was "OnHit || OnAttack" .

I decided then to try something else and i wanted to see on the screen without opening a window the health value of the player.

I looked for something userful in the javadoc and found getHealth(). I used it on the player but it was showing only 1 when alive and 0 on death and not a value for the health(10, 100, 1000) and it means that i probably took the wrong method.

 

This is why I'm asking:

what am i doing wrong in my way of doing things or is there a simpler way to work for a mod ?

 

And since I'm opening a topic, if it is not a problem to ask, how can i get the health of the player?

Thank you

 

Link to comment
Share on other sites

getPlayer():getHealth() to retrieve it and health is a floating point number between 0 and 1 I do believe. So 80% ought to manifest as 0.8. Again this is speculation now because I haven't handled that in a while and don't have the code in front of me now. But I am fairly certain it is the case.

 

And the actual health and what the floating point represents is based on character fitness and such I do believe. Again, I only skimmed through the code some weeks ago on the matter and haven't touched it since or worked with it intimately.

 

And welcome to the Forums and happy modding :)

 

Hope to see you around, others will hopefully help more effectively than I.

Link to comment
Share on other sites

Hmmm interesting, I'll check into it a bit as well.

 

EDIT: Ah you are correct, I am getting 1 when alive and -1 when dead, with absolutely no gradient in between. I shall have to look deeper into the system to figure out what is going on here :P

Edited by Viceroy
Link to comment
Share on other sites

You can use the lua debugger to load your lua files while in game, so you won't have to do the whole process of reloading a mod. It doesn't necessarily work with all situations, but it's a ton of help!

 

I was able to use the lua debugger but it does nothing or at least I'm not able to use it. I can see the experimental reload file but nothing more. 

Any help with that is much appreciated. A pic of it:

Untitled.jpg

 

About the funtiontions, as you can see on the screenshot i'm trying to call getName, getDamage etc but they always their initialization(1, null, 0 etc.).

Anyone knows what i'm doing wrong?

 

function printT()  local player = getSpecificPlayer(0);  local health = player:getName();  print("Name");  print(health);  local age = player:getAge();  print("Age");  print(age);  endEvents.OnKeyPressed.Add(printT);

Thank you

Link to comment
Share on other sites

Considering the error, it might well be because you're playing in debug mode.

getPlayer();getBodyDamage(): . . . something-something is probably what you want.

 

I'm not quite sure that i understood but if I use DrawString to get them ingame i get the same result(their values never change):

Untitled.jpg

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