Inventory help in an RPG game

Questions about the LÖVE API, installing LÖVE and other support related questions go here.
Forum rules
Before you make a thread asking for help, read this.
User avatar
Azhukar
Party member
Posts: 478
Joined: Fri Oct 26, 2012 11:54 am

Re: Inventory help in an RPG game

Post by Azhukar »

Pigeon wrote:Basically, where am I gonna put all of that code. That's what I want to know. Enough with me de-railing a thread I made.

Where do I put all of the code?
It wont help you if you don't know where to put it.
Pigeon wrote:I can't help the issues I have with my head. That's why when you said 'it might be all in your head' it really hurt me basically, because I have a severe anger disorder. So yeah. I am sorry, but I might not be in the next post, then I will be in the next. It is in my head, but I can't help it. Just don't openly abuse people anymore. It is probably just me who gives two shits. Now I'm sorry but I don't understand the code, because it has yet to have worked.
Your head is you. They are not 2 separate entities. If you are aggressive, then that's how you are. You control what you write, you choose to write letter after letter.

Anger is not a disorder.
User avatar
Davidobot
Party member
Posts: 1226
Joined: Sat Mar 31, 2012 5:18 am
Location: Oxford, UK
Contact:

Re: Inventory help in an RPG game

Post by Davidobot »

Azhukar wrote:
Pigeon wrote:Basically, where am I gonna put all of that code. That's what I want to know. Enough with me de-railing a thread I made.

Where do I put all of the code?
It wont help you if you don't know where to put it.
You need to put the code in main.lua
And load all the variables in love.load.
Azhukar wrote:
Pigeon wrote:I can't help the issues I have with my head. That's why when you said 'it might be all in your head' it really hurt me basically, because I have a severe anger disorder. So yeah. I am sorry, but I might not be in the next post, then I will be in the next. It is in my head, but I can't help it. Just don't openly abuse people anymore. It is probably just me who gives two shits. Now I'm sorry but I don't understand the code, because it has yet to have worked.
Your head is you. They are not 2 separate entities. If you are aggressive, then that's how you are. You control what you write, you choose to write letter after letter.

Anger is not a disorder.
Well, ever heard of the term Anger Issues? Well, that is referring to an anger disorder, when a person is very proven to getting angry. Sorry Pigeon, Azhukar should think before posting.
PM me on here or elsewhere if you'd like to discuss porting your game to Nintendo Switch via mazette!
personal page and a raycaster
User avatar
Azhukar
Party member
Posts: 478
Joined: Fri Oct 26, 2012 11:54 am

Re: Inventory help in an RPG game

Post by Azhukar »

Davidobot wrote:Well, ever heard of the term Anger Issues? Well, that is referring to an anger disorder, when a person is very proven to getting angry. Sorry Pigeon, Azhukar should think before posting.
Sorry I have a disorder that causes me to point out when someone is making excuses to act like an ass. Like when he said he has anger issues that are not his fault. Oops there I go again, sorry not my fault can't help it!

It's not my fault, it's a mental disorder that I have no control over.

/sarcasm
User avatar
Davidobot
Party member
Posts: 1226
Joined: Sat Mar 31, 2012 5:18 am
Location: Oxford, UK
Contact:

Re: Inventory help in an RPG game

Post by Davidobot »

Azhukar wrote:
Davidobot wrote:Well, ever heard of the term Anger Issues? Well, that is referring to an anger disorder, when a person is very proven to getting angry. Sorry Pigeon, Azhukar should think before posting.
Sorry I have a disorder that causes me to point out when someone is making excuses to act like an ass. Like when he said he has anger issues that are not his fault. Oops there I go again, sorry not my fault can't help it!

It's not my fault, it's a mental disorder that I have no control over.

/sarcasm
Do you want to make people feel bad?

Also: You can enable console in conf.lua, I think it is t.console = true or t.modules.console = true.
PM me on here or elsewhere if you'd like to discuss porting your game to Nintendo Switch via mazette!
personal page and a raycaster
jjmafiae
Party member
Posts: 1331
Joined: Tue Jul 24, 2012 8:22 am

Re: Inventory help in an RPG game

Post by jjmafiae »

Everybody calm down we are all in danger now, some mod will come here and give us all board issue warnings, Pigeon instead of asking for help then you should learn lua and try to experiment some more.

---End of Thread---
User avatar
Davidobot
Party member
Posts: 1226
Joined: Sat Mar 31, 2012 5:18 am
Location: Oxford, UK
Contact:

Re: Inventory help in an RPG game

Post by Davidobot »

I took the liberty of putting Azhukar code into a .love file:
Attachments
Inventory.love
Windows only! Uses console!
(1.16 KiB) Downloaded 176 times
PM me on here or elsewhere if you'd like to discuss porting your game to Nintendo Switch via mazette!
personal page and a raycaster
User avatar
Pigeon
Prole
Posts: 29
Joined: Sat Oct 05, 2013 9:37 am

Re: Inventory help in an RPG game

Post by Pigeon »

Davidobot wrote:I took the liberty of putting Azhukar code into a .love file:
Thank you so much Davidobot for telling me where to put it. And thanks to Azhukar for the code! Sorry about my Issues, but I hope to get some form of counselling soon! Thank you all a lot!
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. :)
Gravy
Citizen
Posts: 80
Joined: Sun Jan 22, 2012 10:15 pm
Location: CA, USA

Re: Inventory help in an RPG game

Post by Gravy »

Here's a link to a drag and drop RPG inventory I made a while back. It's not quite finished, but it demonstrates how something like this can be done.
http://love2d.org/forums/viewtopic.php? ... 54&p=62510
GameDummy
Prole
Posts: 3
Joined: Sun Oct 22, 2017 8:16 am

Re: Inventory help in an RPG game

Post by GameDummy »

Davidobot wrote: Tue Oct 22, 2013 4:29 am I took the liberty of putting Azhukar code into a .love file:
Thank you for that, but can you guys tell me a way to draw this on the actual game screen ? İ have been struggling with that for quite a while now.
User avatar
Azhukar
Party member
Posts: 478
Joined: Fri Oct 26, 2012 11:54 am

Re: Inventory help in an RPG game

Post by Azhukar »

GameDummy wrote: Sun Oct 22, 2017 8:20 amThank you for that, but can you guys tell me a way to draw this on the actual game screen ?

Code: Select all

local myInventory = {food = 10,sword = 4,coin = 50,axe = 2,shield = 1,armor = 40}

local function drawItem(item,itemWidth,itemHeight)
	if (item == "food") then
		love.graphics.setColor(0,128,0,255)
	elseif (item == "coin") then
		love.graphics.setColor(0,128,128,255)
	else
		love.graphics.setColor(128,0,0,255)
	end
	love.graphics.rectangle("fill",0,0,itemWidth,itemHeight)
end

local function drawInventory(inventory,itemWidth,itemHeight,itemSpacing,horizontalSlots)
	local slot_x,slot_y = 0,0
	for item,amount in pairs(myInventory) do
		local x,y = slot_x*(itemWidth+itemSpacing),slot_y*(itemHeight+itemSpacing)
		
		love.graphics.push()
		love.graphics.translate(x,y)
		drawItem(item,itemWidth,itemHeight)
		love.graphics.pop()
		
		love.graphics.setColor(255,255,255,255)
		love.graphics.print(item.."\n"..amount.."x",x,y)
		
		slot_x = slot_x + 1
		if (slot_x >= horizontalSlots) then
			slot_x = 0
			slot_y = slot_y + 1
		end
	end
end

function love.draw()
	drawInventory(myInventory,50,50,4,3)
end
Post Reply

Who is online

Users browsing this forum: Ahrefs [Bot], Bing [Bot] and 2 guests