Need help

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.
magreidis
Prole
Posts: 8
Joined: Sat May 05, 2012 3:32 pm

Need help

Post by magreidis »

Im seeking Goature tutorials and i'm stuck in 7 part. I have created entities.lua, but this don't work at all. It says:
Error

main.lua:2:module 'entities.lua' not found:
no file "entities/lua.lua" in LOVE paths.

no extension "entities.lua" in LOVE paths.

no field package.preload['entities.lua']
no file '.\entities\lua'
no file 'C:\Program Files\LOVE\lua\entities\lua.lua'
no file 'C:\Program Files\LOVE\lua\entities\init.lua'
no file 'C:\Program Files\LOVE\entities\lua.lua'
no file 'C:\Program Files\LOVE\entities\init.lua'
no file '.\entities\lua.dll'
no file 'C:\Program Files\LOVE\entities\lua.dll'
no file 'C:\Program Files\LOVE\loadall.dll'
no file '.\entities.dll'
no file 'C:\Program Files\LOVE\entities.dll'
no file 'C:\Program Files\LOVE\loadall.dll'

Traceback

[C]: in function 'require'
main.lua:2: in function 'load'
[C]: in function 'xpcall'

My main.lua code:

Code: Select all

function love.load()
	require("entities.lua")
	xCloud1 = 0
	xCloud2 = 100
	imageCloud = love.graphics.newImage("textures/cloud.png")
	imageGround = love.graphics.newImage("textures/ground.png")
	imageEnemy_1 = love.graphics.newImage("textures/enemy1.png")
	imageEnemy_2 = love.graphics.newImage("textures/enemy2.png")
end

function love.draw()
	-- Draws Rectangle that is assiciating with grass
	love.graphics.setColor( 103, 164, 21, 255 )
	love.graphics.rectangle("fill",0, 392, 800, 392 )
	-- Draws Rectangle who is assiciating with sky
	love.graphics.setColor(0,192,255,255)
	love.graphics.rectangle("fill",0,0,800,408)
	--Draws cloud1
	love.graphics.setColor(255,255,255,255)
	love.graphics.draw(imageCloud, xCloud1 - 200, 128, 0,1,1,0,0)
	--Draws cloud2
	love.graphics.setColor(255,255,255,255)
	love.graphics.draw(imageCloud, xCloud2 - 200,256,0,1,1,0,0)
	-- Draws Meldon land words in X: 32 Y: 32
	love.graphics.setColor(0,0,0,255)
	love.graphics.print("Meldon Land",32,32,0,1,1)
	--Draws Upper grass
	love.graphics.setColor(255,255,255,255)
	love.graphics.draw( imageGround, (800-1024)/2, 408-64, 0, 1, 1, 0, 0 )
end

function love.update(dt)
	xCloud1 = xCloud1 + 60*dt
	if xCloud1 >= (800 + 200) then
	  xCloud1 = 0
	end
	xCloud2 = xCloud2 + 48*dt
	if xCloud2 >= (800+200) then
      xCloud2 = 0
	end
end

function love.focus(bool)
end

function love.keypressed( key, unicode )
	if key == "escape" then
      love.event.push("quit")   -- actually causes the app to quit
   end
end

function love.keyreleased( key, unicode )
end

function love.mousepressed( x, y, button )
	print("X: " .. x,"Y: " .. y)
end

function love.mousereleased( x, y, button )
end

function love.quit()
end

My entities.lua code:
ents = {}
ents.objects = {}
ents.objpath = "entities/"
local register = {}
local id = 0

function ents.Startup()

end

function ents.Create(name, x, y)
	if not x then
	  x = 0
	end
	if not y then
	  y = 0
	end
	
	if register(name) then
	  id = id +1
	  local ent = register[name]()
	  ent:load()
	  ent.setPos(x, y)
	  ent.id = id
	  ents.objects[#ents.obejcts + 1] = ent
	  return ents.objects[#ents.objects]
	else
	  print("ERROR! Entity name does not exists")
	  return false;
end

So please help me. I really want to continue developing games with Love2D
Last edited by magreidis on Sat May 05, 2012 8:55 pm, edited 1 time in total.
magreidis
Prole
Posts: 8
Joined: Sat May 05, 2012 3:32 pm

Re: Need help

Post by magreidis »

Somebody??? :brows:
SudoCode
Citizen
Posts: 61
Joined: Fri May 04, 2012 7:05 pm

Re: Need help

Post by SudoCode »

I'm fairly new here, but I think the syntax for require has changed in 0.8.0.

Change

Code: Select all

require = "entities.lua"
to

Code: Select all

require = "entities"
magreidis
Prole
Posts: 8
Joined: Sat May 05, 2012 3:32 pm

Re: Need help

Post by magreidis »

Thanks it really helped. I have another problem with the last part of Goature videos. Now i have another error and here it is:
Error

main.lua:3: attempt to index global 'ents'(a nil value)

Traceback

main.lua:3: in function 'load'
[C]: in function 'xpcall'

And here is the code of main.lua:

Code: Select all

function love.load()
	require = "entities.lua"
	ents.Startup()
	love.graphics.setBackgroundColor( 255, 255, 255 )
	xCloud = 0
	imageCloud = love.graphics.newImage("textures/cloud.png")
	imageGround = love.graphics.newImage( "textures/ground.png" )
	imageEnemy_1 = love.graphics.newImage( "textures/enemy1.png" )
	imageEnemy_2 = love.graphics.newImage( "textures/enemy2.png" )
	
	local boxEnt = ents.Create( "box", 128, 128 )
	local boxEnt2 = ents.Create( "box", 256, 128 )
	boxEnt2:setSize( 64, 128 )
end

function love.draw()
	local x = love.mouse.getX( )
	local y = love.mouse.getY( )
	
	love.graphics.setColor( 198, 241, 255, 255 )
	love.graphics.rectangle( "fill", 0, 0, 800, 300 )
	
	love.graphics.setColor( 255, 255, 255, 255 )
	love.graphics.draw( imageCloud, xCloud - 256, 128, 0, 1, 1, 0, 0 )
	
	love.graphics.setColor( 103, 164, 21, 255 )
	love.graphics.rectangle( "fill", 0, 300, 800, 300 )
	
	love.graphics.setColor( 255, 255, 255, 255 )
	love.graphics.draw( imageGround, (800-1024)/2, 300-64, 0, 1, 1, 0, 0 )
	
	ents:draw()
end

function love.update(dt)
	xCloud = xCloud + 32*dt
	if xCloud >= (800 + 256) then
		xCloud = 0
	end
	ents:update(dt)
end

function love.focus(bool)
end

function love.keypressed( key, unicode )
end

function love.keyreleased( key, unicode )
	
end

function love.mousepressed( x, y, button )
end

function love.mousereleased( x, y, button )
end

function love.quit()
end
Last edited by magreidis on Sat May 05, 2012 8:54 pm, edited 1 time in total.
Zeliarden
Party member
Posts: 139
Joined: Tue Feb 28, 2012 4:40 pm

Re: Need help

Post by Zeliarden »

try

Code: Select all

ents =  require ("entities")
magreidis
Prole
Posts: 8
Joined: Sat May 05, 2012 3:32 pm

Re: Need help

Post by magreidis »

Nope it's not working and here is an error:
Error

Syntax error: main.lua:2: unexpected symbol near '='

Traceback

[C]: ?
[C]: in function 'require'
[C]: in function 'xpcall'
User avatar
bartbes
Sex machine
Posts: 4946
Joined: Fri Aug 29, 2008 10:35 am
Location: The Netherlands
Contact:

Re: Need help

Post by bartbes »

That's because you probably used wrong syntax, we can't tell without the current source.

On behalf of moderator-me:
- Please don't double-post, and especially not to bump and ESPECIALLY not after less than 2 hours.
- Use code tags, the way you post your code now is pretty much unreadable.
- Generally, the first line of the error is enough, especially when it's simple errors like these.
User avatar
Jasoco
Inner party member
Posts: 3727
Joined: Mon Jun 22, 2009 9:35 am
Location: Pennsylvania, USA
Contact:

Re: Need help

Post by Jasoco »

Can you please use the code tags? Edit your posts to add them in. It makes the post very long. And makes reading your code very hard.

THAT'S WHAT SHE SAID.
magreidis
Prole
Posts: 8
Joined: Sat May 05, 2012 3:32 pm

Re: Need help

Post by magreidis »

FOr this bug i just changed into older version on Love2D
User avatar
TechnoCat
Inner party member
Posts: 1612
Joined: Thu Jul 30, 2009 12:31 am
Location: Milwaukee, WI
Contact:

Re: Need help

Post by TechnoCat »

magreidis wrote:FOr this bug i just changed into older version on Love2D
Image
Post Reply

Who is online

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