Jump to content

Question about PZ moding


Neptune

Recommended Posts

Hello everyone,I have some question about modding.My English is not good ,but I am working on it.

 

.Lua script of mod how to load? I have read the 'how to use the modding loader'.But I still cant load my mod.This is structure of my mod.

 

Zomboid
    |-- mods
        |-- NeptuneMod/
            |-- poster.png
            |-- mod.info
            |-- media/
                |-- lua/
                    |-- lua.lua
                |-- scripts/
                    |-- NeptuneCustomItems.txt
 
and this is source of lua.lua
 
local function addItems(_keyPressed)  local key = _keyPressed;  print(key);  if key == 96 then    local player = getSpecificPlayer(0);    local inv = player:getInventory();    inv:AddItem("neptune.NeptuneBag");  endendEvents.OnKeyPressed.Add(addItems);

and this is Source of NeptuneCustomItems.txt

module neptune{	item NeptuneBag		{			WeightReduction		=	90,			Weight			=	0.5,			Type			=	Container,			Capacity		=	500,			DisplayName		=	Neptune Bag,			Icon			=	Duffelbag,	                CanBeEquipped 		= 	Back,	                OpenSound   		=       PZ_OpenBag,	                CloseSound   		=       PZ_CloseBag,	                PutInSound   		=       PZ_PutInBag,		}}

I can find mod in mod manager and I can select it to green,But it not work,When I press the Num 0,nothing happened.So I want to know the Lua Script how to load in correct.I cant solve this problem by my self,I need help.QAQ

 

Yours

 

A China Player

 

Link to comment
Share on other sites

lua files have to go into a file structure like

NeptuneMod/media/lua/client/lua.lua

NeptuneMod/media/lua/server/lua.lua

NeptuneMod/media/lua/shared/lua.lua

Or any sub-directory of /client or /server or /shared

 

More information than you asked for:

Files in the /shared directory load first, both in client and server contexts. This is where you might put shared 'library' type code.

Files in the /client directory only load on the client. They never load on a server (but they are still checked by the server for checksumming purposes.)

So code that only runs on the client, like GUI changes, make the most sense here.

Files in the /server directory load last, both in client and server contexts. This is where you'd put code that needs to run both on servers and clients.

 

And 'require()' can change the load order up too, so being strict about directory structure isn't really all that important except in the case of /client.

Link to comment
Share on other sites

lua files have to go into a file structure like

NeptuneMod/media/lua/client/lua.lua

NeptuneMod/media/lua/server/lua.lua

NeptuneMod/media/lua/shared/lua.lua

Or any sub-directory of /client or /server or /shared

 

More information than you asked for:

Files in the /shared directory load first, both in client and server contexts. This is where you might put shared 'library' type code.

Files in the /client directory only load on the client. They never load on a server (but they are still checked by the server for checksumming purposes.)

So code that only runs on the client, like GUI changes, make the most sense here.

Files in the /server directory load last, both in client and server contexts. This is where you'd put code that needs to run both on servers and clients.

 

And 'require()' can change the load order up too, so being strict about directory structure isn't really all that important except in the case of /client.

 

Thank u very much! I got much useful information.The trouble was solved.I try to change my code then it work.

 

its src:

NeptuneHandler = {};NeptuneHandler.addItems = function(_keyPressed)  local key = _keyPressed; -- Store the parameter in a local variable.  print(key); -- Prints the pressed key to the console.  -- We test if the correct key is pressed.  if key == 82 then    local player = getSpecificPlayer(0);    -- Java: get player one    local inv = player:getInventory();      -- Java: access player inv    -- Java: add the actual items to the inventory    inv:AddItem("neptune.NeptuneBag");  endend-- This will be fired whenever a key is pressed.Events.OnKeyPressed.Add(NeptuneHandler.addItems);
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...