I have a inventory(card) system im trying to implement
im using a code "snip-it" to start with and have been slowly learning the insides of what makes
it work... and im having a problem deleting the cards! I would be thankful for any help!
If you need art for your game please let me know!
Thanks!
Help with Inventory system!
Forum rules
Before you make a thread asking for help, read this.
Before you make a thread asking for help, read this.
Help with Inventory system!
- Attachments
-
- InventoryWork_9.love
- (59.31 KiB) Downloaded 207 times
Re: Help with Inventory system!
Can you explain how you want the delete interaction to work, and what you have tried so far?
Re: Help with Inventory system!
When you click on item it goes into yr mouse pos...like it's in yr hand..I want to be able to delete the card in the table
when its in my hand....or thow it at the door to use!!! script (inventoryGui.lua) approximate line 194 I have a comment explaining!
Please if you can help in any way! Thank You! I do insane art if you need anything!
The table item is there..I just cant seem to access it and delete that card thats in my hand..but keep any cards already in inventory!
Basicly a card gets put into inventory..you can move it around yr inventory....throw it at trash rectangle collision box below...or throw it at door rectangle collision box....You basicly get cards and throw them at the playfield to fix the door and stuff..or throw them in trash!
when its in my hand....or thow it at the door to use!!! script (inventoryGui.lua) approximate line 194 I have a comment explaining!
Please if you can help in any way! Thank You! I do insane art if you need anything!
The table item is there..I just cant seem to access it and delete that card thats in my hand..but keep any cards already in inventory!
Basicly a card gets put into inventory..you can move it around yr inventory....throw it at trash rectangle collision box below...or throw it at door rectangle collision box....You basicly get cards and throw them at the playfield to fix the door and stuff..or throw them in trash!
Last edited by Rondu on Mon May 27, 2024 7:05 pm, edited 1 time in total.
Re: Help with Inventory system!
This is the another version..I added a desrciption of what im trying to do along with instructions on line 194 in inventory.Gui.lua
Re: Help with Inventory system!
This is the another version..I added a desrciption of what im trying to do along with instructions on line 194 in inventory.Gui.lua
- Attachments
-
- InventoryWork_9.love
- (66.81 KiB) Downloaded 169 times
Re: Help with Inventory system!
if i understand your request, you need to
put this code in inventory.lua
any time you want to delete an item from table(inv) just call
inv:removeItem(row,coulmn) put the exact row and column of the item, then the item will be deleted.
put this code in inventory.lua
Code: Select all
-- ix = index x, iy = index y in table
function inventory:removeItem(iy,ix)
local stop = false
for y=1,#self.arr do
for x=1,#self.arr[1] do
self.arr[iy][ix] = 0
break
end
end
end
inv:removeItem(row,coulmn) put the exact row and column of the item, then the item will be deleted.
Re: Help with Inventory system!
table.remove is better suited as it does not leave hanging elements around, 0 does not equal nil etc.
https://www.lua.org/pil/19.2.html
https://www.lua.org/pil/19.2.html
My boat driving game demo: https://dusoft.itch.io/captain-bradley- ... itius-demo
Re: Help with Inventory system!
Ok..thank you!!! I will go through it as soon as I can! If you need any art please let me know!
Re: Help with Inventory system!
Hi. In that code the loops are redundant as you're not using the "x" and "y" variables.H.I wrote: ↑Sat Jun 08, 2024 8:15 amCode: Select all
-- ix = index x, iy = index y in table function inventory:removeItem(iy,ix) local stop = false for y=1,#self.arr do for x=1,#self.arr[1] do self.arr[iy][ix] = 0 break end end end
The function can be reduced to just this line, "self.arr[iy][ix] = 0"
Re: Help with Inventory system!
Thank you for the valuable info! I will go through this as soon as I can and post my work! If anyone needs art please let me know!
Who is online
Users browsing this forum: Ahrefs [Bot], Bing [Bot], Google [Bot] and 8 guests