## Problem with register[]

Questions about the LÖVE API, installing LÖVE and other support related questions go here.
Forum rules
Gold_Car
Prole
Posts: 27
Joined: Thu Jan 01, 2015 2:07 am

### Problem with register[]

I've been working on an experiment in LOVE which comes from a tutorial I found. I'm very new to Lua and Love, so watching the tutorial and just doing what the teacher does is the only way for me to get anything done.

The problem is, the video series is fairly old and since then, Love updated to 0.9.1, and broke a lot of the syntax. I've already had problems with require, which I have since fixed by changing the syntax. Now I've got a problem with what I believe to be this piece of code.

Code: Select all

function ents.Startup()
register["box"] = love.filesystem.load( ents.objpath .. "box" )
end
I've set up the console to print "The entity called Box isn't real." if the game doesn't recognize the box.lua file as a real thing. Here's the thing, though. In the main.lua file I have these:

Code: Select all

if love.filesystem.isDirectory("entityobjects") then
print("Found the entity folder.")
end
if love.filesystem.isFile("entityobjects/base.lua") then
print("Found the base.lua.")
end
if love.filesystem.isDirectory("texturesofthings") then
print("Found the texture folder.")
end
if love.filesystem.isFile("entityobjects/box.lua") then
print("Found the box.lua.")
end
They all evaluate to true. My guess is that I just have the syntax wrong with the register thingy. What's the correct syntax for it?
Attachments
Looking for the box.love

davisdude
Party member
Posts: 1154
Joined: Sun Apr 28, 2013 3:29 am
Location: North Carolina

### Re: Problem with register[]

The problem is that you aren't calling ents.startup().
Because of that, the table index is never created.
GitHub | MLib - Math and shape intersections library | Walt - Animation library | Brady - Camera library with parallax scrolling | Vim-love-docs - Help files and syntax coloring for Vim

Gold_Car
Prole
Posts: 27
Joined: Thu Jan 01, 2015 2:07 am

### Re: Problem with register[]

I just tried that. I've put ents.startup() into the main lua file. Unfortunately, now the game turns into a blue screen.

This is what it says.
Error

main.lua:26: attempt to call field 'startup' (a nil value)

Traceback

[C]: in function 'xpcall'
I don't quite understand what it means.

davisdude
Party member
Posts: 1154
Joined: Sun Apr 28, 2013 3:29 am
Location: North Carolina

### Re: Problem with register[]

I'm sorry, I meant to type "ents.Startup"
GitHub | MLib - Math and shape intersections library | Walt - Animation library | Brady - Camera library with parallax scrolling | Vim-love-docs - Help files and syntax coloring for Vim

Gold_Car
Prole
Posts: 27
Joined: Thu Jan 01, 2015 2:07 am

### Re: Problem with register[]

davisdude wrote:I'm sorry, I meant to type "ents.Startup"
I tried both of these:

Code: Select all

ents.Startup()
local boxEnt = ents.Create( "box", 128, 128 )

Code: Select all

ents.Startup
local boxEnt = ents.Create( "box", 128, 128 )
Neither worked. I got bluescreen again. This is very odd.

For the Startup that does have the brackets afterward, the error tells me that objpath is a nil value.

davisdude
Party member
Posts: 1154
Joined: Sun Apr 28, 2013 3:29 am
Location: North Carolina

### Re: Problem with register[]

Two problems:
- When you use love.filesystem.load you need to put .lua at the end of the file.
- ents.objpath needs to have quotation marks and a backslash. In other words, do:

Code: Select all

ents.objecpath = "entityobjects/"
By the way, it's a lot more helpful to us if you post the actual errors you get.
GitHub | MLib - Math and shape intersections library | Walt - Animation library | Brady - Camera library with parallax scrolling | Vim-love-docs - Help files and syntax coloring for Vim

Gold_Car
Prole
Posts: 27
Joined: Thu Jan 01, 2015 2:07 am

### Re: Problem with register[]

davisdude wrote:Two problems:
- When you use love.filesystem.load you need to put .lua at the end of the file.
- ents.objpath needs to have quotation marks and a backslash. In other words, do:

Code: Select all

ents.objecpath = "entityobjects/"
By the way, it's a lot more helpful to us if you post the actual errors you get.
Actually, when I use ents.objpath = (entityobjects/) it makes the game crash, every time; whereas without it, the game would normally run fine.

Also, is it objecpath or objpath? I'm getting a bit of conflicting information here.

davisdude
Party member
Posts: 1154
Joined: Sun Apr 28, 2013 3:29 am
Location: North Carolina

### Re: Problem with register[]

That's because you need to use quotation marks " not parenthesis (
And I'm assuming it's objpath, but I would need the tutorial you're watching to be sure.
GitHub | MLib - Math and shape intersections library | Walt - Animation library | Brady - Camera library with parallax scrolling | Vim-love-docs - Help files and syntax coloring for Vim

Gold_Car
Prole
Posts: 27
Joined: Thu Jan 01, 2015 2:07 am

### Re: Problem with register[]

davisdude wrote:That's because you need to use quotation marks " not parenthesis (
And I'm assuming it's objpath, but I would need the tutorial you're watching to be sure.
Thanks for that. I changed the punctuation and now the game doesn't crash anymore. The console log still tells me that the box isn't real, but at least the game isn't white text on a blue screen anymore.

Here's the tutorial.
Sorry for being late with that one.

Goature's help really got thrown off track for me when version 0.9.1 broke his code.

davisdude
Party member
Posts: 1154
Joined: Sun Apr 28, 2013 3:29 am
Location: North Carolina

### Re: Problem with register[]

Here. This has all of the changes I showed you in the previous posts. Look at main.lua an entities.lua to see what I changed.
Attachments
Looking for the box.love