iwalidza Posted March 1, 2022 Posted March 1, 2022 I have an inventory system it has stack system like one slot can get just 10 apples like if i write command to give player item and i want give player like 36 apples and he have 4 apples in him inventory then him inventory he be like that 10 10 10 10 10 how i can do it
Moderators IIYAMA Posted March 1, 2022 Moderators Posted March 1, 2022 25 minutes ago, iwalidza said: stack system The way the items are stacked depends on the inventory system. Basic formule: -- generate some fake data local item = {name = "apple", quantity = 36} -- do the stacking local stackSize = 10 local itemCount = item.quantity -- 36 local stacksRawCount = itemCount / stackSize local stacksMaxCount = math.ceil(stacksRawCount) -- 4 local stacksMinCount = math.floor(stacksRawCount) -- 3 local remainingItems = itemCount % stackSize -- 6 Do you want to improve your Lua programming skills and make less mistakes? Start with Lua Language Server! Useful functions 3x Spoiler checkPassiveTimer getScreenStartPositionFromBox getPedGender Tutorials 4x Spoiler Scaling DX Events Attach an addEventHandler on a group of elements Debugging
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now