Jump to content

[Crafting] 4 item Limit Is it a language limitation or can it be changed?


Shivster

Recommended Posts

I want to be able to make a item in game that takes more then 4 items is it even possible or is it something LUA is unable to handle?

 

Here is the Code i want to be able to use:

recipe Basicmarinad{Soysauce,Worcestershire,Pepper,Salt,Liquidsmoke,Result: Basicmarinad=3,Time:800,}

I do not want to make that and the Boring and Tasty versions into more then one recipe. But if i must i will :(

Link to comment
Share on other sites

I think i found it. now the question is can i make a file that will change the base File without editing the base file.

 

C:\Program Files (x86)\Desura\Common\Project Zomboid\media\lua\TimedActions\ISCraftAction.LUA

 

Think i need to change:

require "TimedActions/ISBaseTimedAction"ISCraftAction = ISBaseTimedAction:derive("ISCraftAction");function ISCraftAction:isValid()	-- do you still have the required item in your inventory	if self.character:getInventory():contains(self.itemsCraft[1])		and ((self.itemsCraft[2] and self.character:getInventory():contains(self.itemsCraft[2])) or not self.itemsCraft[2])		and ((self.itemsCraft[3] and self.character:getInventory():contains(self.itemsCraft[3])) or not self.itemsCraft[3])		and ((self.itemsCraft[4] and self.character:getInventory():contains(self.itemsCraft[4])) or not self.itemsCraft[4]) then		return true;	end	return false;end

And This

function ISCraftAction:perform()    self.item:getContainer():setDrawDirty(true);    self.item:setJobDelta(0.0);	local resultItemCreated = RecipeManager.PerformMakeItem(self.recipe, self.itemsCraft[1], self.itemsCraft[2], self.itemsCraft[3], self.itemsCraft[4], self.character);	if resultItemCreated then		local itemsAdded = self.character:getInventory():AddItems(resultItemCreated:getModule() .. "." .. resultItemCreated:getType(), self.recipe:getResult():getCount());		if itemsAdded and instanceof(resultItemCreated, "Food") then			for i=0, itemsAdded:size()-1 do				local newItem = itemsAdded:get(i);				newItem:setCooked(resultItemCreated:isCooked());			end		end	end
Link to comment
Share on other sites

Ok i changed above code adding in more items like so.

function ISCraftAction:isValid()	-- do you still have the required item in your inventory	if self.character:getInventory():contains(self.itemsCraft[1])		and ((self.itemsCraft[2] and self.character:getInventory():contains(self.itemsCraft[2])) or not self.itemsCraft[2])		and ((self.itemsCraft[3] and self.character:getInventory():contains(self.itemsCraft[3])) or not self.itemsCraft[3])		and ((self.itemsCraft[4] and self.character:getInventory():contains(self.itemsCraft[4])) or not self.itemsCraft[4]) 		and ((self.itemsCraft[5] and self.character:getInventory():contains(self.itemsCraft[5])) or not self.itemsCraft[5])		and ((self.itemsCraft[6] and self.character:getInventory():contains(self.itemsCraft[6])) or not self.itemsCraft[6])		and ((self.itemsCraft[7] and self.character:getInventory():contains(self.itemsCraft[7])) or not self.itemsCraft[7]) then		return true;	end	return false;end

and here

function ISCraftAction:perform()    self.item:getContainer():setDrawDirty(true);    self.item:setJobDelta(0.0);	local resultItemCreated = RecipeManager.PerformMakeItem(self.recipe, self.itemsCraft[1], self.itemsCraft[2], self.itemsCraft[3], self.itemsCraft[4], self.itemsCraft[5], self.itemsCraft[6], self.itemsCraft[7], self.character);	if resultItemCreated then		local itemsAdded = self.character:getInventory():AddItems(resultItemCreated:getModule() .. "." .. resultItemCreated:getType(), self.recipe:getResult():getCount());		if itemsAdded and instanceof(resultItemCreated, "Food") then			for i=0, itemsAdded:size()-1 do				local newItem = itemsAdded:get(i);				newItem:setCooked(resultItemCreated:isCooked());			end		end	end

Still not working in fact it broke crafting :( Must be another file that has the 4 Limit will keep looking!

Link to comment
Share on other sites

It wont work, the crafting recipe limit is controlled by a java file. If we had a new java file with the amount of items increased, then the lua could be changed to the same limit and it would work fine.

 

So no, not without replacing the base class java file.

 

 

Edit: I am 99% sure it is this java file.

 

Project Zomboid\zombie\scripting\objects\recipe.class

Edited by kinyoshi
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...