|
| 28 Jun 2014 06:57 PM |
inventory = {} maxItems = 10 -- change this to how many items you can store currentItems = #inventory
function addItem(x) currentItems = #inventory if (currentItems < maxItems) then local item = table.insert(inventory, (currentItems + 1), x) print(x.. ' added') currentItems = #inventory else print('Inventory already full.') end end
function removeItem(y) currentItems = #inventory if (currentItems < 1) then print('Nothing to remove') else for i = 1, #inventory do if inventory[i] == y then table.remove(inventory, i) print(y.. ' removed.') break end end currentItems = #inventory end end
addItem("sword") addItem("axe") removeItem("axe") print(table.concat(inventory))
You can't tell me this isn't partially good. I made it so that you choose what the item is called, and what item you remove. |
|
|
| Report Abuse |
|
|
bohdan77
|
  |
| Joined: 10 Aug 2008 |
| Total Posts: 7944 |
|
|
| 28 Jun 2014 07:01 PM |
| eh, i'm not sure what we guis think. we're just visual |
|
|
| Report Abuse |
|
|
|
| 28 Jun 2014 07:03 PM |
| Haaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaah I see whatcha did there. |
|
|
| Report Abuse |
|
|
morash
|
  |
| Joined: 22 May 2010 |
| Total Posts: 5834 |
|
|
| 28 Jun 2014 10:21 PM |
| I am neither graphical, meant for the user, or an interface. Sorry. |
|
|
| Report Abuse |
|
|
| |
|
|
| 29 Jun 2014 08:57 AM |
| Sry but you fail. "gui" isn't an acronym, GUI is. |
|
|
| Report Abuse |
|
|
| |
|