items = {}
centerX = love.graphics.getWidth() / 2
centerY = love.graphics.getHeight() / 2
function item1()
sprite = love.graphics.newImage('sprites/stick.png') -- Image used for item
health = 10 -- Health for item
love.graphics.draw(sprite, centerX, centerY) -- Draw the sprite, and put it in the center
end
return items
Here is main.lua (Not all of it, just the important part):
-- Other require parts here
items = require("items")
-- Load everything
function love.load()
-- Load other scripts
items.item1()
-- Continue loading everything
end
-- Continue other functions
I am terribly sorry if there is answer for this somewhere, or if this is a really simplistic question; I am learning the ropes still
"He would often tell me that he didn't mind if people thought of him as cold or distant, he said that he knew he was actually a vibrant and compassionate person, but it takes time to really see that. It can be a very slow climb to get there."
To be a bit contrary to grump, let me give a different answer;
You can absolutely have love.graphics.draw and other stuff in functions other than love.draw; but grump is right in that you ultimately want to call your item1 function from love.load.
Now, to actually answer your question, you want to put the item1 function into the items table itself, that you're returning. There's actually two ways you can write the function's line like that: function items.item1() or items.item1 = function().
But apart from that, you should also separate the draw call out to a separate function, like items.draw or something; that would be the usual approach (which you'd then call from love.draw in your main.lua)
Me and my stuff True Neutral Aspirant. Why, yes, i do indeed enjoy sarcastically correcting others when they make the most blatant of spelling mistakes. No bullying or trolling the innocent tho.