Skip to content

Instantly share code, notes, and snippets.

@luckytyphlosion
Created March 14, 2021 17:22
Show Gist options
  • Save luckytyphlosion/15053d9c25d054c24aa69f302acdc98c to your computer and use it in GitHub Desktop.
Save luckytyphlosion/15053d9c25d054c24aa69f302acdc98c to your computer and use it in GitHub Desktop.
Script to modify XYZ coords based on an XYZ tuple.
-- =============================================================================
-- Copyright (c) 2021 luckytyphlosion
--
-- Permission to use, copy, modify, and/or distribute this software for any
-- purpose with or without fee is hereby granted.
--
-- THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
-- REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
-- AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
-- INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
-- LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
-- OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
-- PERFORMANCE OF THIS SOFTWARE.
-- =============================================================================
-- local inputStr = " 360,-100, 0)";
print("Running bn5c_xy.lua!");
function onSubmitChangeCoords()
local input = forms.gettext(texthandle);
local inputCoords = {};
for str in string.gmatch(input, "(%-?[0-9]+)") do
table.insert(inputCoords, str);
end
local x = tonumber(inputCoords[1]);
local y = tonumber(inputCoords[2]);
local z = tonumber(inputCoords[3]);
--print(x .. ", " .. y .. ", " .. z);
local xCoordAddr = 0x200ae4c + 2;
local yCoordAddr = 0x200ae4c + 6;
local zCoordAddr = 0x200ae4c + 10;
memory.write_s16_le(xCoordAddr, x);
memory.write_s16_le(yCoordAddr, y);
memory.write_s16_le(zCoordAddr, z);
end
function onExit()
forms.destroyall();
print("Exited bn5c_xy.lua!");
end
event.onexit(onExit);
formhandle = forms.newform(250, 130, "Change Coords");
texthandle = forms.textbox(formhandle, "", 140, 30, nil, 45, 15);
forms.button(formhandle, "Accept", onSubmitChangeCoords, 75, 50, 80, 30);
while true do
x = memory.read_s16_le(xCoordAddr);
y = memory.read_s16_le(yCoordAddr);
z = memory.read_s16_le(zCoordAddr);
gui.cleartext();
gui.text(10, 10, string.format("x: %d, y: %d, z: %d", x, y, z));
emu.frameadvance();
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment