Planimeter / game-engine-2d

Planimeter Game Engine 2D - LÖVE-based game engine for Lua
https://github.com/Planimeter/game-engine-2d/wiki
MIT License
736 stars 74 forks source link

Profile library might be broken? #17

Closed imthatgin closed 9 years ago

imthatgin commented 9 years ago

I think it could perhaps be broken, or I'm doing some stupid error.

function thefunction(args)
    profile.start("a")
    **function code**
    profile.stop("a")
end

The above does cause an error which goes along the lines of 'attempt to index global 'profile' (a nil value) on profile.start(), this might be an user error, not necesarily something broken, just need new eyes on it.

andrewmcwatters commented 9 years ago

Hey Ryan, the profiler isn't loaded by default in the engine anywhere at the moment. Add require( "engine.shared.profile" ) before those lines.

imthatgin commented 9 years ago

I did add that. Still receiving the same issue.

andrewmcwatters commented 9 years ago

If you're doing this in a module, make sure to access it from _G, _G.profile, etc.

imthatgin commented 9 years ago

I believe that was the issue. Thank-you. Would be useful to have somewhere in the wiki.

andrewmcwatters commented 9 years ago

I'll make sure to document this from now on in the various interfaces and libraries. It's important to know when stuff is available. Thanks for bringing this up!