Jump to content

All mods seem to have no effect, or cause PZ to crash on load


Damienknight

Recommended Posts

(I posted this under the Tutorial thread, but thought it might fit better here).

 

I cannot get any .lua based mods to work.

 

Specifically I tried the dry towels mod, and couple attempts at modding myself.

 

Here is the simple intro mod (that for me does nothing):

 

function sayHello()
playerlog = getSpecificPlayer(0);
playerlog.Say("Hello");
end
 
Events.EveryTenMinutes.Add(sayHello);
 
 
I placed this inside of my mods folder %%Zomboid\mods\helloworld\media\lua
 
I setup the mod.info and poster.png in the helloworld root folder.
 
The mod info file:
 
name=Hello World (1.0.0)
poster=poster.png
description=Test where player 0 says Hello World every 10 in game minutes
id=helloworld
url=www.google.com
 
 
When booting, the mod appears in the mod list, with poster working.  I double click to activate (checkmark appears).
 
I start a Beginner survival game.  I would expect to have my character say 'Hello' every 10 minute in game interval.
 
Any advice?

 

Link to comment
Share on other sites

There's a subtle error in your script.

You need to use "player:Say("Hello");" instead of "player.Say("Hello");".

The difference is a colon ( :) instead of a dot (.) between player and Say.

This is why I shouldn't post after waking up, BlindCoder. Totally missed it. :D
Link to comment
Share on other sites

There's a subtle error in your script.

You need to use "player:Say("Hello");" instead of "player.Say("Hello");".

The difference is a colon ( :) instead of a dot (.) between player and Say.

 

So when calling Events Add, I should use a period but when calling the Say function I should use a Colon?  What is the rule for when to use a colon and when to use a period?

 

Events.EveryTenMinutes.Add(sayHello);  <-- Use a Period for the ADD method?

 

player:Say("Hello");  <-- Use a Colon for the Say method?

Link to comment
Share on other sites

You use a colon when you are calling a method of an instantiated object (something that has a "self" reference).

You use a dot when you use a function stored in a table.

 

I agree that it is not always obvious, and i'm honestly not sure why the Events.*.Add don't have a colon :/

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