Indie game storeFree gamesFun gamesHorror games
Game developmentAssetsComics
SalesBundles
Jobs
Tags

Debugging inside the extension

A topic by Dragonite created Mar 17, 2020 Views: 283 Replies: 1
Viewing posts 1 to 2

So I’ve got an interesting issue where a script bound to Lua (lua_add_function(...)) is having its value changed somewhere between its “return” statement

show_debug_message(BattleActions.SKILL);
return BattleActions.SKILL;

and where it’s value is used in the Lua code

local def = Battle.default_act(me)
print(def)

(printouts: 0, 1)

The bound script seems to “return” 1 no matter what actually goes in front of the return statement - a number, text, nothing at all, etc. I tried tracing it through the lua_state_exec* and lua_script_execute in the extension itself using breakpoints and printouts, but most of the returned values inside there seem to be either pointers inside a buffer or instance IDs and I can’t really tell where anything gets lost. I’m not sure if “1” is supposed to represent “true,” or if it’s erroneously turning into “1 return result” as in some of the other lua_call functions, or if it’s just an arbitrary value somewhere in memory.

Side note: big thanks for doing this. This is a really odd issue that I haven’t been able to figure out for two days, but overall using Lua has been really useful for keeping certain parts of my code separate from each other.

Follow-up: there’s an (erroneous) line in the ref script that invokes a different section of Lua code, which itself returns a value of 1, which appears to be the rogue value that makes its way out into the game. This has gone from a case of “I don’t know why this single case isn’t working” to “I don’t know why the other instances aren’t breaking!” If anyone finds this thread in a Google search or something: don’t invoke Lua from inside a ref script.

So much for keeping parts of my code separate!