Jump to content

Consumption of delta item that is not in the hands


Nebula

Recommended Posts

Help me please.
I'm trying to solve the problem myself, but it doesn’t work ...

I need to find the item in the inventory, read its current delta and reduce it.
What am I doing wrong?

 

function WorkDelta (items, player)

for i=0, items:size()-1 do
if items:get(i):getType() == "WorkItem" then
    items:setUsedDelta((getUsedDelta() - 0.001));
    end
end

Edited by Nebula
Link to comment
Share on other sites

9 hours ago, tommysticks said:

Hey man, you may need to define items yourself:

local items = player:getInventory():getItems()

I’m on mobile and can’t check if I got this correct, but try that

 

Thank you, problem solved.
Here is the correct code that I got.

 

function WorkDelta(items, player)
	local player = getPlayer();
    for i = 0, player:getInventory():getItems():size() - 1 do
	local item = player:getInventory():getItems():get(i);
        if item:getType() == "WorkItem" then
        item:setUsedDelta((item:getUsedDelta() - 0.01));
    end
end

 

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