Isotarge / ScriptHawk

A collection of Lua scripts and RAM watches for BizHawk.
MIT License
88 stars 15 forks source link

Add support for Donkey Kong Country 1 GBA & Small Fix for Bizhawk 2.9 #22

Closed SBDWolf closed 11 months ago

SBDWolf commented 1 year ago

Hi, some folks were working on a TAS for DKC1 GBA so i went ahead and added support for it here. The script is near identical to that of DKC2 GBA.

However, while working on this, i noticed starting from Bizhawk 2.9 (which upgraded the version of Lua), both DKC1 GBA and DKC2 GBA wouldn't work, with the following error in the console:

NLua.Exceptions.LuaScriptException: .\lib\LibScriptHawk.lua:205: attempt to call a nil value (field 'atan2')

It looks like starting Lua 5.3, the atan2 function got deprecated, instead recommending to uses the atan function with two parameters - https://www.lua.org/manual/5.3/manual.html#8.2

(For context, it looks like Bizhawk 2.8 uses Lua 5.1, while Bizhawk 2.9 uses Lua 5.4).

By replacing that function call with atan(), the error goes away and the scripts work on Bizhawk 2.9. From what i can tell, on older versions of Lua, the atan function also accepts two arguments, because the code in this PR also seems to work on versions of Bizhawk as old as 1.11.5, at least for DKC1 GBA and DKC2 GBA. However, i am not 100% sure this doesn't break something else i'm not aware of, so please double check this!

Isotarge commented 11 months ago

Thank you for your contribution, much appreciated.