Indie game storeFree gamesFun gamesHorror games
Game developmentAssetsComics
SalesBundles
Jobs
Tags

Issue with 2.3.1 and GM 2023

A topic by Hyomoto created Feb 01, 2023 Views: 146 Replies: 2
Viewing posts 1 to 2
(5 edits)

Hello, YAL.  The cheat sheet seems very straight-forward about getting started, but Apollo crashed immediately saying that lua_buffer is not defined when I tried to run lua_add_code().  Poking in the files I found lua_init() but this isn't called by the extension (it is shown as the init function in apollo_core.gml though), nor is it documented on the cheat sheet.  Also, I also get an error on first project reload saying Apollo.yy is missing and had 1 reference.  It might be that newer versions of GM are borking something.  Still, I couldn't find any quick start references or the like, just the cheat sheet, so I'm not sure if I'm just missing an obvious piece of documentation.

EDIT: Immediately after posting this I started thinking: perhaps this function IS called and it's just during the "pragma" phase that it's unavailable and ... yup.  That's it.  If you wait until an object even to run it works fine, but if you try to call the code during an initialization period beforehand, I'm guessing the extension just hasn't called it's init functions yet.  So, issue solved.  It is starting correctly, there's just a period of time when it will crash if called.  The obvious workaround is to clear it from the extension and just call it myself, not sure if that info is helpful to anyone but here it is.

Developer

It is what it is, unfortunately - global script init runs before both gml_pragma and extension init, and there is no way to automatically ensure that extension gets initialized before that.

I’m currently working on a new version of the extension (for GMS2.3/GM2022+) that just has you call lua_init yourself before you use any of it.

That's what I ended up doing.  I do feel a bit silly having gotten stumped by such a trivial thing, but I guess I'm just very used to working during the pragma section for initialization tasks.  Otherwise the experience out of the box is incredible.  I find a lot of libraries tend to be overly complex, but once I got past this small hurdle Apollo works as expected with little fuss or fanfare.  It was mostly just a technical detail I got hung up on because while the cheat sheet seems to make it pretty clear you just need to call lua_state_create() to get started, my issue was that because it wasn't working I didn't know if I was missing some detail or if it was something else and, as it turned out, it was something else.

I don't know how vital it would be, but a "hello world" in Apollo would've got me digging into the extension earlier and fussing less over missing documentation which is what prompted the initial post.  Given the lack of similar I'm probably an outlier though I won't be upset to see it in an updated version.