groverburger / g3d

Simple and easy 3D engine for LÖVE.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

g3d/model.lua:145: attempt to index local 'self' (a nil value)

leaf456 opened this issue · comments

I'm very new to g3d, but I have this simple code:
local g3d = require("g3d") local object = g3d.newModel("objs/sphere.obj", "objs/texture.png", {0, 0, 0, 0}) function love.draw() object.draw() end and when I run the code, it errors. I know that the files are there, and the issue is this line of code:
local shader = shader or self.shader (line 145 in model.lua). I'm not sure what happened, i was following the code showed on the examples page (home page).

object.draw() should be object:draw().
The colon means that calling it is functionally identical to object.draw(object). It's what's known as a "method", i.e. a function that needs to be given the object as a parameter, since otherwise it won't know which object you want to draw.