-
Notifications
You must be signed in to change notification settings - Fork 3
/
item.lua
804 lines (798 loc) · 24.1 KB
/
item.lua
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
Item =
{
name = "";
type = "General";
description = "None";
require = 0;
effect = 0;
quantity = 0;
price = 0;
durability = 0;
rarity = "Common";
tradeable = true;
subtype = "None";
}
----------------
if dokun then
Item.factory = Factory:new()
end
----------------
Item_mt =
{
__index = Item,
__gc =
function(self)
if dokun then
--Sprite.get_texture(self):destroy()
--Sprite.set_texture(self, nullptr)
Sprite.destroy(self)
end
print(self:get_name(), "deleted")
end
}
------------------
function Item:new(name, type, require, description, effect)
local item
if dokun then item = Sprite:new() -- table with ".udata" field
else
item = {} -- ordinary table
end
---------------------
-- Item:new()
if self == Item then
item.name = name
item.type = type
item.description = description
item.require = require
item.effect = effect
-- Item.new()
else
item.name = self
item.type = name
item.description = require
item.require = type
item.effect = description
end
---------------------
-- generate id number
if not Item.id then Item.id = 0
end
Item.id = Item.id + 1
item.id = Item.id
----------------------
-- create metatable for inst
item.mt = {__index = item}
----------------------
-- make clone function for inst
item.new = function()
local new_item -- copy of original item
if dokun then
new_item = Sprite:new()
else
new_item = {}
end
if dokun then
Item.factory:store(new_item) -- store even clone in factory database
end
setmetatable(new_item, item.mt)
-- non-stackable (set quantity to 0) equipments have their own unique quantity since they are non-stackable items
if not new_item:is_stackable() then
new_item:set_quantity(0)
end
return new_item
end
--------------------
if dokun then
Item.factory:store(item) -- store original item in factory
end
setmetatable(item, Item_mt)
return item
end
----------------
function Item:load(filename) -- Sprite.load sets the sprite's texture but only in c++ unfortunately :/
if dokun then
local texture = Texture:new()
if not texture:load(filename) then
print("Could not open "..filename)
return false
end
Sprite.set_texture(self, texture)--self.texture = texture
end
if self.on_load then self:on_load() end
self.filename = filename--save filename as proof that it has been loaded
return true
end
-----------------
function Item:draw()
if self.on_draw then self:on_draw() end
if dokun then
Sprite.draw(self)
end
end
----------------
-- if mouse over self, info displayed
function Item:show_info()
if is_item(self) then
print("Item name: "..self:get_name())--Item_name_label = Label:new() Item_name_label:set_string(self:get_name())
print("ID: "..self:get_id())
print("type: "..self:get_type())
if self:get_require() <= 0 then
print("level required: None")
else
print("level required: "..self:get_require())
end
print("usage: "..self:get_usage())
print("effect: "..self:get_effect())
print("price: "..self:get_price())
if self:in_bag() or self:get_type() == "Currency" and Bag.gold > 0 then
print("in_bag: ".."Yes")
else
print("in_bag: ".."No")
end
print("durability: "..self:get_durability())
if self:is_tradeable() then
print("tradeable: ".."Yes")
else
print("tradeable: ".."No")
end
print("rarity: "..self:get_rarity())
end
end
----------------
-- use an item that has been obtained
function Item:use(user)
-- If item is a string (must be item name)
if type(self) == "string" then self = get_item_by_name(self)
end -- Item.use("Potion", player)
-- call user implemented on_use function
self:on_use(user)
end
----------------
function Item:select() end -- self in the bag is selected
----------------
-- Item.move_to_slot -- Hold and drag to move an self in your bag.
function Item:swap(slot_num) -- Switch slots with another item in the bag.
if self:in_bag() then
-- Slot is empty.
if Bag.slots[slot_num] == nil then
if dokun then if bag_slots then bag_slots[self:get_slot()]:get_image():copy_texture(empty_texture) end end-- Empty texture on old slot
Bag.slots[self:get_slot()] = nil -- Empty old slot.
Bag.slots[slot_num] = self -- Fill new slot.
if dokun then if bag_slots then if Sprite.get_texture(self):is_texture() then bag_slots[self:get_slot()]:get_image():copy_texture(Sprite.get_texture(self)) end end end-- File self.texture on new slot
else
-- Slot is taken.
Bag.slots[self:get_slot()] = Bag.slots[slot_num] -- Move the other item from its slot to self's slot.
Bag.slots[slot_num] = self -- Now move self to the slot of the other item.
end
end
end -- slot must be empty
----------------
function Item:swap_with_another_item(item)
end
----------------
function Item:equip(user)
if is_player(user) then user:equip(self) end
end -- Equip an item from your bag.
----------------
function Item:unequip(user)
if is_player(user) then user:unequip(self) end
end
----------------
function Item:toss(player, bag, amount)
if type(bag) ~= "table" then bag = Bag end -- main bag
if type(amount) ~= "number" then amount = 1 end
-- If gold exists
if type(gold) == "table" then
-- item is gold (or copy of gold)
if self == gold or getmetatable(self) == gold.mt then print("gold gold gold")
-- player has enough gold to toss out of Bag
if Bag.gold >= amount then
-- reduce gold amount
Bag.gold = Bag.gold - amount
-- set obtained to false
self:set_obtained(false)
-- set position a few distance from player
if dokun then
local player_x, player_y = Sprite.get_position(player)
Sprite.set_position(self, player_x + math.random(-20, 80), player_y + math.random(-20, -20) )
end
-- show message
print(self:get_name(), "tossed")
end
end
end
-- check if item is in the bag
if self:in_bag() then
local slot_num
-- Non stackable items ( e.g equipments )
if not self:is_stackable() then -- non-stackable items take up a full slot in the Bag
-- get slot position in bag
slot_num = self:get_slot(bag)
-- delete item from bag
Bag.slots[ slot_num ]:delete()
-- set obtained to false (so it can be redrawn)
self:set_obtained(false)
-- drop at a few distance from current player position
if dokun then
local player_x, player_y = Sprite.get_position(player)
Sprite.set_position(self, player_x + math.random(-20, 80), player_y + math.random(-20, -20))
end
-- show message
print(self:get_name(), "tossed")
else -- if it is stackable delete the parent
-- self is a copy of original item
if self:is_copy() then
-- if item is stacked,
-- you only have to delete
-- the parent item from the bag
slot_num = self:get_parent():get_slot(bag)
-- delete parent from bag
self:get_parent():delete()
-- copy is not obtained (so it can be redrawn)
self:set_obtained(false)
-- drop copy item a few distance from player
if dokun then
local player_x, player_y = Sprite.get_position(player)
Sprite.set_position(self, player_x + math.random(-20, 80), player_y + math.random(-20, -20) )
end
-- show message
print(self:get_name().."(copy)", "tossed")
else
-- self is the the original item ; get its slot number
slot_num = self:get_slot(bag)
-- delete item from bag (decrement and set to nil)
Bag.slots[ slot_num ]:delete()
-- set obtained to false (so it can be redrawn)
self:set_obtained(false)
-- drop item a few distance from player
if dokun then
local player_x, player_y = Sprite.get_position(player)
Sprite.set_position(self, player_x + math.random(-20, 80), player_y + math.random(-20, -20))
end
-- show message
print(self:get_name(), "tossed")
end
end
end
end -- Toss an item out of your bag.
----------------
function Item:delete(amount, bag) -- Delete an item in your bag.
if not bag then bag = Bag end
-- amount is not specified, (amount to be deleted)
-- set default to one
if not amount then amount = 1
end
-- NON-STACKABLE CLONES(EQUIPMENT CLONES) ARE TREATED AS ORDINARY OBJECTS INHERITED FROM Item
-- reduce quantity of item if above zero
-- by a specified amount. (and if self is original item) e.g potion, sword or non-stackable clone
if not self:is_copy() or not self:is_stackable() then -- original or non-stackable
if self:get_quantity() > 0 then self:set_quantity( self:get_quantity() - amount ) --reduce the quantity
-- dokun graphical stuff
if dokun then if bag_slots then bag_slots[self:get_slot(bag)]:get_label():set_string(tostring(self:get_quantity())) end end--set quantity label
end
elseif self:is_copy() and self:is_stackable() then -- both a copy and stackable
-- reduce quantity of parent if stackable copy e.g potion:new()
local parent = self:get_parent()
if self:get_parent():get_quantity() > 0 then self:get_parent():set_quantity(self:get_parent():get_quantity() - amount)
-- dokun graphical stuff
if dokun then if bag_slots then bag_slots[parent:get_slot(bag)]:get_label():set_string(tostring(parent:get_quantity())) end end--set quantity label
end
end
-- once the quantity reaches 0, remove it from bag
if not self:is_stackable() or -- equipment (non-stackable)
self:get_quantity() <= 0 then -- None of the specific item found in bag.
self:set_quantity(0) -- To ensure that the item's quantity is not a negative number.
-- now remove from slot
for i = 1, bag:get_maximum_slots() do--#bag.slots do
-- bag slot contains the original item (not a copy) since its not stackable
if bag.slots[i] == self then -- The item is found in bag.
bag.slots[i] = nil--set slot where item was to nil --table.remove(bag.slots, i) -- Remove item from Bag, shifting elements up.--WARNING:Shifting items up-a-slot is a bad idea! Instead delete it from its current slot and when adding a new item, place it in the first available slot (that is nil)
-- dokun graphical stuff ... because of the item shifting up the slot, the image on its old_slot is not updated!!!!!!
if dokun then if bag_slots and empty_texture then bag_slots[i]:get_image():copy(empty_image) bag_slots[i]:get_label():set_string("") end end--if dokun then if bag_slots and empty_texture then bag_slots[i]:get_image():copy_texture(empty_texture) bag_slots[i]:get_image():set_color(64, 64, 64, 255) bag_slots[i]:get_label():set_string("") end end --clear bag_slots[i].image texture with an empty one--set bag_slots[i].image color to defaults (0,0,0,0)-- clear string from bag_slots[i].label
break
end
end
end
end
----------------
function Item:examine() end -- Examine an items outside of bag(works for non-obtainable items)
----------------
function Item:trade() end -- trade item with another player or npc
----------------
function Item:obtain(amount, bag) -- get the self inside your inventory; obtain an self by picking_up or collision?
-- default amount = 1
if not amount then amount = 1 end
-- use default Bag (if nil)
if not bag then bag = Bag end
-- store in bag
if bag:insert( self, amount ) then
if string.find(self:get_type(), nocase("currency")) then
print("Obtained "..amount.." "..self:get_name())
else
print("Obtained "..self:get_name().." +"..amount.."")
end
return true
end
return false
end
----------------
function Item:sell(amount)
local shop = Shop:new()
shop:sell(self, amount)
end
----------------
function Item:buy(shop, amount)
if not is_shop(shop) then
print("Not a valid shop")
end
if is_shop(shop) then
shop:buy(self, amount)
end
end
----------------
function Item:list() for _, item in pairs(_G) do if is_item(item) then print(item:get_name()) end end
end
----------------
-- SETTERS
----------------
function Item:set_name(name)
self.name = name
end
----------------
function Item:set_type(type)
self.type = type
end
----------------
function Item:set_description(description)
self.description = description
end
----------------
function Item:set_require(require)
self.require = require
end
----------------
function Item:set_effect(effect)
self.effect = effect
end
----------------
function Item:set_price(price)
self.price = price
end
----------------
function Item:set_quantity(quantity)
self.quantity = quantity
end
----------------
function Item:set_weight(weight)
self.weight = weight
end
----------------
function Item:set_durability(durability)
self.durability = durability
end
----------------
function Item:set_tradeable(tradeable)
self.tradeable = tradeable
end
----------------
function Item:set_subtype(subtype)
self.subtype = subtype
end
----------------
function Item:set_rarity(rarity)
self.rarity = rarity
end
----------------
function Item:set_obtained(obtained)
self.obtained = obtained
end
---------------- new!
function Item:set_storage_quantity(storage_quantity)
self.storage_quantity = storage_quantity
end
----------------
-- GETTERS
function Item:get_id()
return self.id
end
----------------
function Item:get_name()
return self.name
end
----------------
function Item:get_type()
return self.type
end
----------------
function Item:get_description()
return self.description
end
Item.get_usage = Item.get_description
----------------
function Item:get_require()
return self.require
end
----------------
function Item:get_effect()
return self.effect
end
----------------
function Item:get_price()
return self.price
end
----------------
function Item:get_quantity()
return self.quantity
end
----------------
function Item:get_weight()
return self.weight
end
----------------
function Item:get_durability()
return self.durability
end
----------------
function Item:get_rarity()
return self.rarity
end
----------------
function Item:get_subtype()
return self.subtype
end
----------------
-- NOTE: DOES NOT WORK WITH CLONE ITEMS.
-- CAN ONLY GET THE ORIGINAL ITEM.
function get_item_by_name(name)
local _G = _G
for _, item in pairs(_G) do
if is_item(item) then -- must be a valid item
if item.name == name then
return item
end
end
end
return nil
end
----------------
-- NOTE: DOES NOT WORK WITH CLONE ITEMS.
-- CAN ONLY GET THE ORIGINAL ITEM.
function get_item_by_id(id)
local _G = _G
for _, item in pairs(_G) do
if is_item(item) then -- must be a valid item
if item.id == id then
return item
end
end
end
return nil
end
----------------
-- STATIC FUNCTION(S)
function Item:get_item_by_id(id)
if self ~= Item then
error "'self' must be class Item"
end
local item = get_item_by_id(id)
return item
end
----------------
function Item:get_item_by_name(name)
if self ~= Item then
error "'self' must be class Item"
end
local item = get_item_by_name(name)
return item
end
----------------
function Item:get_count()
if self ~= Item then
error "'self' must be class Item"
end
local num_item = 0
local _G = _G
for _, item in pairs(_G) do
if is_item(item) then
num_item = num_item + 1
end
end
return num_item
end -- # of item objects
----------------
function Item:get_slot(bag) -- Get slot number of item inside bag or storage.
-- specify which bag ( if multiple bags )
if not bag then bag = Bag end
-- NON-Stackable items are their own tables while stackable will become the exact as the parent
-- a clone and stackable e.g. potion:new()
local item_obj = self
if self:is_copy() and self:is_stackable() then-- if self is a copy and stackable, get its parent
-- get the original item and set item_obj to equal self.parent
item_obj = self:get_parent()
end
for slot_num, item in pairs(bag.slots) do
if bag.slots[slot_num] == item_obj then
return slot_num
end
end
if getmetatable(bag) == Bag_mt or bag == Bag then
print("Not in bag")
return 0
end
if getmetatable(bag) == Storage_mt or bag == Storage then
print("Not in storage")
return 0
end
end
----------------
function Item:get_parent()
-- object of Item
if getmetatable(self) == Item_mt then return Item end
-- clone of Item object
local _G = _G
for _, item in pairs(_G) do
if type(item) == "table" then
if getmetatable(item) == Item_mt then
if getmetatable(self) == item.mt then
return item
end
end
end
end
end
----------------
function Item:get_storage_quantity()
return self.storage_quantity
end
----------------
-- CONDITIONS
----------------
function Item:is_item()
-- Is it a table?
if type(self) ~= "table" then
return false
end
-- The original item. (created with Item.new())
if getmetatable(self) == Item_mt then
return true
end
-- A copy of the item.
if not dokun then
local _G = _G
for _, item in pairs(_G) do
if getmetatable(item) == Item_mt then
if getmetatable(self) == item.mt then
return true
end
end
end
end
if dokun then
for _ = 1, Item.factory:get_size() do
if getmetatable(self) == Item.factory:get_object(_).mt then
return true
end
end
end
return false
end
----------------
is_item = Item.is_item
----------------
function Item:in_bag(bag)
if not bag then bag = Bag end
-- original or non-stackable
for slot_num, item in pairs(bag.slots) do -- scan through bag slots for item.
if item == self then
return true -- the item is the same as self.
end
end
-- stackable item
if self:is_stackable() then
-- A copy of the item.
for slot_num, item in pairs(bag.slots) do
if getmetatable(self) == item.mt then
return true
end
end
end
return false
end
----------------
function Item:in_storage(storage)
if not storage then storage = Storage end
-- original or non-stackable
for slot_num, item in pairs(storage.slots) do
if item == self then return true
end
end
-- stackable item
if self:is_stackable() then
-- A copy of the item.
for slot_num, item in pairs(storage.slots) do
if getmetatable(self) == item.mt then
return true
end
end
end
return false
end
----------------
function Item:in_shop(shop)
if not shop then return false end
-- original or non-stackable
for slot_num, item in pairs(shop.catalogue) do
if item == self then
return true
end
end
-- stackable item
if self:is_stackable() then
-- A copy of the item.
for slot_num, item in pairs(shop.catalogue) do
if getmetatable(self) == item.mt then
return true
end
end
end
return false
end
----------------
function Item:is_tradeable()
if type(self.tradeable) == "boolean" then
return self.tradeable
end
return false
end
----------------
function Item:is_obtained() -- new! NOTE: just because an item is in a bag does not mean its mean obtained; obtained is a different story as it applies to the physical item in its "sprite form"
if type(self.obtained) == "boolean" then
return self.obtained
end
return false
end
----------------
function Item:is_copy()
local _G = _G
for _, item in pairs(_G) do
if type(item) == "table" then
if getmetatable(item) == Item_mt then
if getmetatable(self) == item.mt then
return true
end
end
end
end
return false
end
Item.is_child = Item.is_copy
----------------
function Item:is_stackable() -- equipments are not stackable
if not string.find(self:get_type(), nocase("Equipment")) or not self:get_type() then
return true
end
return false
end
----------------
-- EVENT FUNCTION(S)
-- detect all collision with all items
function Item.collide_all() -- global items
end
----------------
-- draw all items
function Item:draw_all()
if dokun then
--Item:hover_all()
--Item:collide_all() -- collision event
--Item:toss_all()
--Item:use_all()
local item -- local in a loop reduces speed of Lua (local variables only exist within functions)
for i = 0, Item.factory:get_size() do
if type(Item.factory:get_object(i)) == "table" then
item = Item.factory:get_object(i)
-- items that are not visible cannot be obtained or drawn and should be ignored
if not Sprite.is_visible(item) then return end
-- if item is a copy and its texture is not set
if item:is_copy() then
--if not item.texture then print(item:get_name().." copy has no texture set") else print(item:get_name().." copy's texture: ", item.texture) end
--end --print(item:get_name().." copy's texture"..item.texture)--print(item:get_name().." copy", item, " | parent = ", item:get_parent())
end
-- obtain items on collision (you should not be able to obtain items that are not visible!)
if Sprite.collide(player, item) and not item:is_obtained() then
item:set_obtained(item:obtain())
end
-- draw items (if not obtained)(or if the item is equipped by a user, draw it on user's body)
if not item:is_obtained() or (string.find(item:get_type(), nocase("Equipment")) and player:is_equipped(item)) then --
Sprite.set_visible(item, true)--make sure its visible so it can be drawn
item:draw()
end
end
end
end
end
----------------
function Item:use_all()
--[[
if is_item(self) then
-- if key is pressed
--if Keyboard:is_pressed() then
-- item can be used
player:use(self)
--end
end
]]--
if dokun then
end
end
----------------
function Item:toss_all()
--[[
if is_item(self) then
-- if item is in the bag
if self:in_bag() then
-- toss the item out of bag
self:toss(player)
end
end
]]--
--[[
if dokun then
for i = 0, Item.factory:get_size() do
if type(Item.factory:get_object(i)) == "table" then
local item = Item.factory:get_object(i)
if Keyboard:is_pressed(0x0020) then
if item:in_bag() then
item:toss(player)
break
end
end
end
end
end
]]
end
----------------
function Item:hover_all()
--[[
if dokun then
for i = 0, Item.factory:get_size() do
if type(Item.factory:get_object(i)) == "table" then
local item = Item.factory:get_object(i)
local item_x, item_y = Sprite.get_position(item)
local item_width, item_height = Sprite.get_size(item)
if Mouse:is_over(item_x, item_y, item_width, item_height) then
--print("Mouse is over "..item:get_name())
--Mouse:set_cursor(58)
--else Mouse:set_cursor(68)
end
end
end
end
]]
end
----------------
function Item:look_at_mouse() -- rotates to mouse position
local mouse_x, mouse_y = Mouse:get_position(window)
local self_x, self_y = Sprite.get_position(sword)
local a = self_x - mouse_x
local b = self_y - mouse_y
-- get mouse angle
mouse_angle = math.atan(a, -b) * 180 / math.pi -- math.atan2 deprecated in Lua 5.3
-- object follow mouse
Sprite.rotate(self, mouse_angle + 180)
end
----------------
-- Load items here.
-- default items
dofile("item/gold.lua")
dofile("item/potion.lua")
dofile("item/health_potion.lua")
dofile("item/mana_potion.lua")
dofile("item/dual_potion.lua")
dofile("item/sword.lua")
dofile("item/warrior_sword.lua")
dofile("item/citizen_paper.lua")
--[[
[NOTE]: Equipments are non-stackable.
[NOTE]: Stackable items share the same quantity and non-stackable have their own unique quantity
]]--