Page 1 of 1

Attempt to index global 'ents' (a boolean value)

Posted: Fri Jan 16, 2015 5:10 am
by Fish Slappa
I'm making a game from Goature's tutorials, and I've had a few problems with the entities system.
It claims, among other things, that ents.Startup() in line 3 is attempting to index global 'ents', which it says is a boolean value. The code is below.
function love.load()
ents = require ("entities")
ents.Startup()
love.graphics.setBackgroundColor( 225, 225, 30 )
xCloud = 0
imageCloud = love.graphics.newImage( "textures/cloud.png" )
imageGround = love.graphics.newImage( "textures/ground.png" )
imageAfif = love.graphics.newImage( "textures/afif.png" )
imagePlayer = love.graphics.newImage( "textures/player.png" )

ents.create( "afif", 128, 128 )
end

Thanks.

Re: Attempt to index global 'ents' (a boolean value)

Posted: Fri Jan 16, 2015 7:20 am
by Doctory
could you post the .love?
and please use code blocks

Re: Attempt to index global 'ents' (a boolean value)

Posted: Fri Jan 16, 2015 7:34 am
by Roland_Yonaba
It seems the file entities.lua returns a boolean.
Try to print(ents, type(ents)). It should be true/false, plus the string "boolean".
Please, share your .love.

Re: Attempt to index global 'ents' (a boolean value)

Posted: Fri Jan 16, 2015 9:03 am
by zorg
the problem is probably that the ents.lua doesn't return a table, i.e. the ents module;
If the tutorial was correct, then you probably left out a

Code: Select all

return ents -- or t or something similar
from the very end of that file.

Re: Attempt to index global 'ents' (a boolean value)

Posted: Fri Jan 23, 2015 11:30 pm
by Positive07
Are you sure that the variable ents is not a GLOBAL variable?... try this:

Code: Select all

function love.load()
    require ("entities")
    ents.Startup()
    love.graphics.setBackgroundColor( 225, 225, 30 )
    xCloud = 0
    imageCloud = love.graphics.newImage( "textures/cloud.png" )
    imageGround = love.graphics.newImage( "textures/ground.png" )
    imageAfif = love.graphics.newImage( "textures/afif.png" )
    imagePlayer = love.graphics.newImage( "textures/player.png" )

    ents.create( "afif", 128, 128 )
end