Jump to content

Consumption of delta item that is not in the hands

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));

Edited by Nebula

Share this post

Link to post
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));


Edited by Nebula

Share this post

Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.


  • Create New...