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

General discussion about LÖVE, Lua, game development, puns, and unicorns.
Post Reply
Fish Slappa
Prole
Posts: 1
Joined: Fri Jan 16, 2015 4:56 am

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

Post 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.
User avatar
Doctory
Party member
Posts: 441
Joined: Fri Dec 27, 2013 4:53 pm

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

Post by Doctory »

could you post the .love?
and please use code blocks
User avatar
Roland_Yonaba
Inner party member
Posts: 1563
Joined: Tue Jun 21, 2011 6:08 pm
Location: Ouagadougou (Burkina Faso)
Contact:

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

Post 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.
User avatar
zorg
Party member
Posts: 3465
Joined: Thu Dec 13, 2012 2:55 pm
Location: Absurdistan, Hungary
Contact:

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

Post 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.
Me and my stuff :3True 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.
User avatar
Positive07
Party member
Posts: 1014
Joined: Sun Aug 12, 2012 4:34 pm
Location: Argentina

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

Post 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
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: Ahrefs [Bot], qq1723 and 4 guests