Heyo, it's me again. I've decided to make an inventory system for my RPG, but I have no idea how to do it. I have no current code on the inventory and can't figure it out. Sorry for posting so much, I just need help with the advanced stuff (and tables) The .love is below
Thanks in Advance,
Pigeon.
Inventory help in an RPG game
Forum rules
Before you make a thread asking for help, read this.
Before you make a thread asking for help, read this.
Inventory help in an RPG game
If I seem aggressive, It's because of my head. Not me. Please do the best you can to deal with it, it's not my fault I'm the way I am.
Re: Inventory help in an RPG game
hint: use tables
Re: Inventory help in an RPG game
jjmafiae wrote:hint: use tables
Any help with using those tables? I did say I was terrible with them? Please?
If I seem aggressive, It's because of my head. Not me. Please do the best you can to deal with it, it's not my fault I'm the way I am.
Re: Inventory help in an RPG game
watch sock munkees tuts on how you make tables, you can't make good games without tables!
you can also read this: Lua First Edition
you can also read this: Lua First Edition
Re: Inventory help in an RPG game
Yeah I understand tables, I honestly do. I'm just not too good. Please, I asked about an inventory, stay on topic maybe? Sorry,jjmafiae wrote:watch sock munkees tuts on how you make tables, you can't make good games without tables!
you can also read this: Lua First Edition
Pigeon
If I seem aggressive, It's because of my head. Not me. Please do the best you can to deal with it, it's not my fault I'm the way I am.
Re: Inventory help in an RPG game
Pigeon wrote:Any help with using those tables? I did say I was terrible with them? Please?
Code: Select all
local function addItemToInventory(inventory,item,amount)
if (inventory[item] ~= nil) then
inventory[item] = inventory[item] + amount
else
inventory[item] = amount
end
end
local function removeItemFromInventory(inventory,item,amount)
if (inventory[item] == nil) then return end
if (inventory[item] <= amount) then
inventory[item] = nil
else
inventory[item] = inventory[item] - amount
end
end
local function printItemsInInventory(inventory)
for item,amount in pairs(inventory) do
if (type(item)=="table") then
print(item.name or "Unknown",amount)
else
print(item,amount)
end
end
end
local myInventory = {}
local myItem = "hammer"
local myUniqueItem = {name="superhammer",bonus=5}
addItemToInventory(myInventory,myItem,10)
addItemToInventory(myInventory,myUniqueItem,1)
removeItemFromInventory(myInventory,myItem,4)
printItemsInInventory(myInventory)
You do not understand tables. He was on topic.Pigeon wrote:Yeah I understand tables, I honestly do. I'm just not too good. Please, I asked about an inventory, stay on topic maybe?
Re: Inventory help in an RPG game
Azhukar wrote:Pigeon wrote:Any help with using those tables? I did say I was terrible with them? Please?Code: Select all
local function addItemToInventory(inventory,item,amount) if (inventory[item] ~= nil) then inventory[item] = inventory[item] + amount else inventory[item] = amount end end local function removeItemFromInventory(inventory,item,amount) if (inventory[item] == nil) then return end if (inventory[item] <= amount) then inventory[item] = nil else inventory[item] = inventory[item] - amount end end local function printItemsInInventory(inventory) for item,amount in pairs(inventory) do if (type(item)=="table") then print(item.name or "Unknown",amount) else print(item,amount) end end end local myInventory = {} local myItem = "hammer" local myUniqueItem = {name="superhammer",bonus=5} addItemToInventory(myInventory,myItem,10) addItemToInventory(myInventory,myUniqueItem,1) removeItemFromInventory(myInventory,myItem,4) printItemsInInventory(myInventory)
You do not understand tables. He was on topic.Pigeon wrote:Yeah I understand tables, I honestly do. I'm just not too good. Please, I asked about an inventory, stay on topic maybe?
Thanks, that's all I needed. explanation would have been nice, but I think I understand. Sorry for being such a pain. Plus: I did understand tables, and I did watch SockMunkee's videos. I think I know what I know, if you know what I mean.
Last edited by Pigeon on Mon Oct 21, 2013 10:57 am, edited 1 time in total.
If I seem aggressive, It's because of my head. Not me. Please do the best you can to deal with it, it's not my fault I'm the way I am.
Re: Inventory help in an RPG game
you should try before asking for help, just like i did back in my noob days.
Re: Inventory help in an RPG game
I've tried messing about with it, but to no avail. I've tried what I've tried, and I feel as though your judging me.jjmafiae wrote:you should try before asking for help, just like i did back in my noob days.
If I seem aggressive, It's because of my head. Not me. Please do the best you can to deal with it, it's not my fault I'm the way I am.
Re: Inventory help in an RPG game
Of course, who doesn't judge others?Pigeon wrote:I feel as though your judging me.
Who is online
Users browsing this forum: Ahrefs [Bot], Bing [Bot] and 0 guests