:/ as in, in a bad way.Azhukar wrote:Of course, who doesn't judge others?Pigeon wrote:I feel as though your judging me.
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.
Re: 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
You do keep saying sorry, as if you have done something bad. Maybe it's all in your head.Pigeon wrote::/ as in, in a bad way.
Re: Inventory help in an RPG game
So I read through the Programming in Lua (the tables bit) and watch SockMunkee's tutorials. I have attempted at making an Inventory and it kinda failed. I've done all you asked. Any help now please? And now my feelings of reality are slipping, cheers Azhukar
Cheers,
Pigeon
Cheers,
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
You were already given an example inventory code.Pigeon wrote:Any help now please?
One step further out of your bubble.Pigeon wrote:And now my feelings of reality are slipping, cheers Azhukar
Re: Inventory help in an RPG game
Fine, sure. Thanks. I guess.Azhukar wrote:You were already given an example inventory code.Pigeon wrote:Any help now please?
One step further out of your bubble.Pigeon wrote:And now my feelings of reality are slipping, cheers Azhukar
Code: Select all
function time:wasted(?)
if time == "wasted" then
log_off_lua = true
curse_timewasters_name = true
pissed = true
end
end
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
Syntax error: ?:1: <name> or '...' expected near '?'Pigeon wrote:Fine, sure. Thanks. I guess.
Code: Select all
function time:wasted(?) if time == "wasted" then log_off_lua = true curse_timewasters_name = true pissed = true end end
Re: Inventory help in an RPG game
The question mark was for show, not for real code.Azhukar wrote:Syntax error: ?:1: <name> or '...' expected near '?'Pigeon wrote:Fine, sure. Thanks. I guess.
Code: Select all
function time:wasted(?) if time == "wasted" then log_off_lua = true curse_timewasters_name = true pissed = true end end
Code: Select all
function time:wastedevenmore()
if time == "wastedevenmore" then
thoughts = "f*ck off, all I asked for was a bit of help"
end
end
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
Is there something you do not understand about the inventory code? Like say, tables? D:Pigeon wrote:The question mark was for show, not for real code.
Code: Select all
function time:wastedevenmore() if time == "wastedevenmore" then thoughts = "f*ck off, all I asked for was a bit of help" end end
Re: Inventory help in an RPG game
almost everything in the code... + sorry for being rudeAzhukar wrote:Is there something you do not understand about the inventory code? Like say, tables? D:Pigeon wrote:The question mark was for show, not for real code.
Code: Select all
function time:wastedevenmore() if time == "wastedevenmore" then thoughts = "f*ck off, all I asked for was a bit of help" end end
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:almost everything in the code... + sorry for being rude
Code: Select all
local function addItemToInventory(inventory,item,amount)
if (inventory[item] ~= nil) then --there are items like this in the inventory already
inventory[item] = inventory[item] + amount --so we add the amount to the ones already there
else --there is no item like this in the inventory
inventory[item] = amount --so the new amount of that item is the one we're adding
end
end
local function removeItemFromInventory(inventory,item,amount)
if (inventory[item] == nil) then return end --there are no such items in the inventory, we do nothing
if (inventory[item] <= amount) then --we're removing more of such items than there are in the inventory
inventory[item] = nil --so we will have no items like it afterwards
else --there is more of such items than we are removing
inventory[item] = inventory[item] - amount --so we subtract the amount we're removing
end
end
local function printItemsInInventory(inventory)
for item,amount in pairs(inventory) do --we're traversing the table, table keys are items, table values are amounts of items
if (type(item)=="table") then --complicated items are represented by a table
print(item.name or "Unknown",amount) --if item has a name we use that, otherwise we use "Unknown" for printing
else --it's a simple item represented by a string
print(item,amount) --we print the item and how much there is of it
end
end
end
local myInventory = {} --our new inventory is a simple table
local myItem = "hammer" --simple item will be a string
local myUniqueItem = {name="superhammer",bonus=5} --special item will be a table with anything we like in it
addItemToInventory(myInventory,myItem,10) --we add 10 hammers to inventory
addItemToInventory(myInventory,myUniqueItem,1) --we add 1 superhammer to inventory
removeItemFromInventory(myInventory,myItem,4) --we remove 4 hammers from inventory
printItemsInInventory(myInventory) --we print contents of the inventory
Who is online
Users browsing this forum: Bing [Bot] and 11 guests