The newbie question

General discussion about LÖVE, Lua, game development, puns, and unicorns.
Post Reply
User avatar
Periwasmarkedasspam
Prole
Posts: 9
Joined: Sun Feb 08, 2015 5:30 am

The newbie question

Post by Periwasmarkedasspam »

Hello im the newbie of the day, and i have a good question.

Code: Select all

function loadAssets()
	assetimage = love.graphics.newImage
	assets =
	{
		images =
		{
		splash = assetimage("splash.png")	
		}
	}	
end

function getImageAsset(theImage)

	return assets[images][..""..theImage..""..]

end
Thats my actual code, that tries to create a asset thingy by using tables. The problem is at the function below. Any clue? I want to get the name of the image and ive tried using String thingys and dont work... Any clue? (Please some Admin, change my name :P I wasnt able to create my account with outlook, and i had to create this gmail account... Strange. My wished name is Peri and yes i OBEY)
User avatar
Jasoco
Inner party member
Posts: 3727
Joined: Mon Jun 22, 2009 9:35 am
Location: Pennsylvania, USA
Contact:

Re: The newbie question

Post by Jasoco »

The problem might be the .. before and after theAsset. And the empty quotes are useless and are doing nothing.
User avatar
Jeeper
Party member
Posts: 611
Joined: Tue Mar 12, 2013 7:11 pm
Contact:

Re: The newbie question

Post by Jeeper »

The best thing to do is to post a .love file!

It is always recommended to do so unless you have a very specific question.
User avatar
Robin
The Omniscient
Posts: 6506
Joined: Fri Feb 20, 2009 4:29 pm
Location: The Netherlands
Contact:

Re: The newbie question

Post by Robin »

Without context, I'd say

Code: Select all

function getImageAsset(theImage)
   return assets.images[theImage]
end
But yeah, we need a .love to give you a real answer.
Help us help you: attach a .love.
User avatar
Periwasmarkedasspam
Prole
Posts: 9
Joined: Sun Feb 08, 2015 5:30 am

Re: The newbie question

Post by Periwasmarkedasspam »

Ok, now i have some other problems that i dont know why they are apearing.

Ill post the .love

The error:

Code: Select all

attempt to index global assets(a nil value)
is in a Require, idk if this is the problem.

:awesome: :awesome:
Attachments
ironBuckshot.love
(7.36 KiB) Downloaded 108 times
User avatar
Robin
The Omniscient
Posts: 6506
Joined: Fri Feb 20, 2009 4:29 pm
Location: The Netherlands
Contact:

Re: The newbie question

Post by Robin »

Move the call to stateSystem() down to the end of the function. You've not yet called loadAssets() at the point you're calling stateSystem now.
Help us help you: attach a .love.
User avatar
Periwasmarkedasspam
Prole
Posts: 9
Joined: Sun Feb 08, 2015 5:30 am

Re: The newbie question

Post by Periwasmarkedasspam »

Thanks! Ill post any other question here :P
User avatar
Positive07
Party member
Posts: 1014
Joined: Sun Aug 12, 2012 4:34 pm
Location: Argentina

Re: The newbie question

Post by Positive07 »

Periwasmarkedasspam wrote:Thanks! Ill post any other question here :P
Nope! Post a new thread or GTFO :neko: Always wanted to use that hahaha. But for real, post a new thread and try to be more descriptive with your titles
for i, person in ipairs(everybody) do
[tab]if not person.obey then person:setObey(true) end
end
love.system.openURL(github.com/pablomayobre)
Post Reply

Who is online

Users browsing this forum: Bing [Bot], Google [Bot] and 4 guests