Youtube Sonic TAS community

Impossible is possible

You are not logged in.

#1 2013-01-06 20:56:44

WST
administrator
From: Maykop, RU · Jakarta, ID
Registered: 2012-10-06
Posts: 287
Website

Useful Lua scripts

If you write some little useful script, post it here.
Here is mine, which I wrote while TASing Sonic the Hedgehog 2 today (for competition with feeuzz22).
It implements reversed frame advance, which may be handy for TASing as well as for viewing existing movies.

-- Frame advance backwards
-- Gens Lua script by the members of Youtube Sonic TAS community <http://ystc.ru>

-- Script settings:
local history_size = 255;
local hotkey_number = 1;

-- Below is the code itself
local stack = {};

input.registerhotkey(hotkey_number, function()
	if(#stack == 0) then
		print('History is empty');
		return;
	end;
	
	savestate.load(table.remove(stack, #stack));
	gens.redraw();
	print('Step back');
end);

gens.registerbefore(function()
	local slot = savestate.create();
	savestate.save(slot);
	table.insert(stack, slot);
	
	if #stack > history_size then
		table.remove(stack, 1);
	end;
end);

Usage instructions

Start Gens, go to Options > Input menu. In the section called „Hotkeys” find „Lua custom hotkey 1” and bind it onto some unbound key (I used backspace key). Save settings, then run the script while playing some game. When you need, press your configured hotkey, and you’ll make a step back. The number of saved states may be adjusted by editing the „history_size” variable. Note that more saved states consume more memory. If the first hotkey is already used by some other script, you may change the „hotkey_number” to what suits your needs.

The only problem with this script is that if you load some savestate from a slot, and then try to press backspace, it will not return you to the previous frame, but will send you to the place where you was before loading the savestate. Of course, it can be fixed, just tell me if you need such ability, and I will implement it when I have spare time (it will require some additional programming).

Licensing

The script above, and any further scripts listed in my posts in this thread, are distributed under the terms of WTFPL.

Repository

The scripts are available on Github. Feel free to star, fork, pull request, etc.


Sonic the EDGEhog has been obsoleted by Amy the LTEhog ©

Offline

#2 2013-01-10 13:52:49

WST
administrator
From: Maykop, RU · Jakarta, ID
Registered: 2012-10-06
Posts: 287
Website

Re: Useful Lua scripts

It is known that most TASers use the quicksave slots for different purposes (as shown in this message in the Russian section of TASvideos forum), and navigate over them using keys 1–0 (for reading) and [shift+1]–[shift+0]. Usually 1 of slots points to the beginning of the level, some 3–4 slots are used for saving results of different successful attempts (to compare them). And only 2–3 slots are used as temporary buffers. However, I prefer using all those savestates as temporary buffers, storing 10 last temporary states, and navigating between them in round-robin style, by pressing F5 for quick save, F8 for quick load, and F6&F7 for switching between the states. I tried using the „traditional” layout, but felt very uncomfortable and fucked up too often, because I often overwrote wrong slots by mistake.

To solve the issue, I wrote a very simple script, allowing me to have additional slots outside the round-robin slot stack. I’ve bound them on the following keys: F1-F4 and F9-F12 (if you want to do like me, you will need to unbind the default actions assigned to those keys). So, now I can navigate over the round-robin slot stack in my favorite manner, and have 4 additional slots for saving different attempts at doing the same, in order to compare the attempts later. The only little problem is that F10 activates the menu bar, and I could not find how to unbind it.

However, I still use paper stickers sometimes, especially when optimizing loops (because they allow me to draw tree-styled graphs illustrating the frames at which I jump to boost my speed).

Here is the script itself.
Of course, you may join it with the previous script, if you need.

-- Additional quick-save slots
-- Gens Lua script by the members of Youtube Sonic TAS community <http://ystc.ru>

local slots = {savestate.create(), savestate.create(), savestate.create(), savestate.create()};
local saved = {false, false, false, false};

input.registerhotkey(8, function()
	savestate.save(slots[1]);
	saved[1] = true;
end);

input.registerhotkey(9, function()
	savestate.save(slots[2]);
	saved[2] = true;
end);

input.registerhotkey(10, function()
	savestate.save(slots[3]);
	saved[3] = true;
end);

input.registerhotkey(11, function()
	savestate.save(slots[4]);
	saved[4] = true;
end);

input.registerhotkey(12, function()
	if saved[1] then
		savestate.load(slots[1]);
		gens.redraw();
	else
		print('Slot is empty');
	end;
end);

input.registerhotkey(13, function()
	if saved[2] then
		savestate.load(slots[2]);
		gens.redraw();
	else
		print('Slot is empty');
	end;
end);

input.registerhotkey(14, function()
	if saved[3] then
		savestate.load(slots[3]);
		gens.redraw();
	else
		print('Slot is empty');
	end;
end);

input.registerhotkey(15, function()
	if saved[4] then
		savestate.load(slots[4]);
		gens.redraw();
	else
		print('Slot is empty');
	end;
end);

Sonic the EDGEhog has been obsoleted by Amy the LTEhog ©

Offline

#3 2013-01-10 15:40:58

feeuzz22
administrator
Registered: 2012-10-07
Posts: 249

Re: Useful Lua scripts

You may find this strange, but I don't use the "Sonic lua HUD" (by MarzoJr), I always play with a little lua script which give me only what I want, what I use, and no more...

-- A simple Sonic HUD for classic Sonic games and their hacks (Sonic, Tails, Knuckles, Amy)
--Now, support also Sonic Classic Heroes v0.07f6 (current)
-- Except Amy in Sonic 1 and Knuckles in Sonic 1 /Sonic 2
-- Gens Lua script by the members of Youtube Sonic TAS community <http://ystc.ru>
-- Include codes from Felipe @TasVideo.org

--Tails' hud is false by default
Tails_HUD = false
local hotkey_number = 2;
input.registerhotkey(hotkey_number, function()
Tails_HUD = not Tails_HUD
return
end)

------------------------------------------------------------------------------------------------------------------
------------------------------------------------------------------------------------------------------------------
----**********************************************************************************************************----
---- you have to define a lua hotkey (the second) before lauching the srcipt if you want player 2 HUD (Tails) ----
----##########################################################################################################----
------------------------------------------------------------------------------------------------------------------
------------------------------------------------------------------------------------------------------------------



-- create space in memory for a savestate
state = savestate.create()

-- register a function to run when the screen gets updated
gui.register( function ()


	rom = memory.readbyte(0x000013f)


--first, the timer:
if rom == 69 then

  --reading datas
    timerpart1 = memory.readbytesigned(0xffff33)
    timerpart2 = memory.readbytesigned(0xffff34)
    timerpart3 = memory.readbytesigned(0xffff35)
else

    timerpart1 = memory.readbytesigned(0xfffe23)
    timerpart2 = memory.readbytesigned(0xfffe24)
    timerpart3 = memory.readbytesigned(0xfffe25)
end


  --show them
if timerpart3 < 10 then
if timerpart2 < 10 then
        message = string.format("real timer:")
        gui.text(114, 01, message, "#FFFFFFFF", "black")
	message = string.format("  %d", timerpart1)
	gui.text(153, 01, message, "#FFFFFFFF", "black")
	message = string.format(":0%d:", timerpart2)
	gui.text(165, 01, message, "#FFFFFFFF", "black")
	message = string.format(" :0%d", timerpart3)
	gui.text(176, 01, message, "#FFFFFFFF", "black")
else
        message = string.format("real timer:")
        gui.text(114, 01, message, "#FFFFFFFF", "black")
	message = string.format("  %d", timerpart1)
	gui.text(153, 01, message, "#FFFFFFFF", "black")
	message = string.format(":%d:", timerpart2)
	gui.text(165, 01, message, "#FFFFFFFF", "black")
	message = string.format(" :0%d", timerpart3)
	gui.text(176, 01, message, "#FFFFFFFF", "black")
end
else
if timerpart2 < 10 then
        message = string.format("real timer:")
        gui.text(114, 01, message, "#FFFFFFFF", "black")
	message = string.format("  %d", timerpart1)
	gui.text(153, 01, message, "#FFFFFFFF", "black")
	message = string.format(":0%d:", timerpart2)
	gui.text(165, 01, message, "#FFFFFFFF", "black")
	message = string.format(" :%d", timerpart3)
	gui.text(176, 01, message, "#FFFFFFFF", "black")
else
        message = string.format("real timer:")
        gui.text(114, 01, message, "#FFFFFFFF", "black")
	message = string.format("  %d", timerpart1)
	gui.text(153, 01, message, "#FFFFFFFF", "black")
	message = string.format(":%d:", timerpart2)
	gui.text(165, 01, message, "#FFFFFFFF", "black")
	message = string.format(" :%d", timerpart3)
	gui.text(176, 01, message, "#FFFFFFFF", "black")
end

end

--******************************************************************************************************--

--players' speed and position

--checking the rom
if rom == 69 then

-- If rom is Sonic Classic Heroes
	-- get the X and Y velocity of sonic the hedgehog 
	xvel = memory.readwordsigned(0xffb018)  
	bxvel = memory.readbytesigned(0xffb018)
	yvel = memory.readwordsigned(0xffb01a)
	byvel = memory.readbytesigned(0xffb01a)


	-- get the X and Y velocity of tails (miles) prower
	txvel = memory.readwordsigned(0xffb064)  
	btxvel = memory.readbytesigned(0xffb064)
	tyvel = memory.readwordsigned(0xffb066)
	btyvel = memory.readbytesigned(0xffb066)


	-- get the X and Y velocity of knuckles the echidna
	kxvel = memory.readwordsigned(0xffb0b0)  
	bkxvel = memory.readbytesigned(0xffb0b0)
	kyvel = memory.readwordsigned(0xffb0b2)
	bkyvel = memory.readbytesigned(0xffb0b2)


	-- get the position of each character
   camX = memory.readdword(0xffeea2) -- x position of the camera
   camY = memory.readdword(0xffee4c) -- y position of the camera
   p1x = memory.readwordunsigned(0xffb010) -- x position of sonic
   p1y = memory.readwordunsigned(0xffb014) -- y position of sonic
   p2x = memory.readwordunsigned(0xffb05c) -- x position of tails
   p2y = memory.readwordunsigned(0xffb060) -- y position of tails
   p3x = memory.readwordunsigned(0xffb0a8) -- x position of knuckles
   p3y = memory.readwordunsigned(0xffb0ac) -- y position of knuckles
   p1sxb = memory.readwordunsigned(0xffb012) -- subx position of sonic
   p1syb = memory.readwordunsigned(0xffb016) -- suby position of sonic
   p2sxb = memory.readwordunsigned(0xffb05e) -- subx position of tails
   p2syb = memory.readwordunsigned(0xffb062) -- suby position of tails
   p3sxb = memory.readwordunsigned(0xffb0aa) -- subx position of knuckles
   p3syb = memory.readwordunsigned(0xffb0ae) -- suby position of knuckles
   
   
   p1sx = p1sxb/256
   p2sx = p2sxb/256
   p3sx = p3sxb/256
   p1sy = p1syb/256
   p2sy = p2syb/256
   p3sy = p3syb/256


	message = string.format("velocity: %d, %d", xvel, yvel)
	gui.text(15, 60, message, "#0080FFFF", "black")
	message = string.format("velocity: %d, %d", bxvel, byvel)
	gui.text(15, 68, message, "#0080FFFF", "black")
	message = string.format("speed:    %d", memory.readwordsigned(0xffb01c))
	gui.text(22, 76, message, "#0080FFFF", "black")
	message = string.format("sonic subpix: %d, %d", p1sx, p1sy)
	gui.text(10, 110, message, "#FFFFFFF", "black")


	message = string.format("velocity: %d, %d", txvel, tyvel)
	gui.text(260, 60, message, "#FFA500FF", "black")
	message = string.format("velocity: %d, %d", btxvel, btyvel)
	gui.text(260, 68, message, "#FFA500FF", "black")
	message = string.format("speed:    %d", memory.readwordsigned(0xffb068))
	gui.text(260, 76, message, "#FFA500FF", "black")
	message = string.format("tails subpix: %d, %d", p2sx, p2sy)
	gui.text(10, 118, message, "#FFFFFFF", "black")


	message = string.format("velocity: %d, %d", kxvel, kyvel)
	gui.text(260, 130, message, "#E70739FF", "black")
	message = string.format("velocity: %d, %d", bkxvel, bkyvel)
	gui.text(260, 138, message, "#E70739FF", "black")
	message = string.format("speed:    %d", memory.readwordsigned(0xffb0b4))
	gui.text(260, 146, message, "#E70739FF", "black")
	message = string.format("knux subpix: %d, %d", p3sx, p3sy)
	gui.text(10, 126, message, "#FFFFFFF", "black")

-- compare all positions

   xposvisual1 = p1x - camX
   yposvisual1 = p1y - camY
   xposvisual2 = p2x - camX
   yposvisual2 = p2y - camY
   xposvisual3 = p3x - camX
   yposvisual3 = p3y - camY

   gui.box(xposvisual1 - 16, yposvisual1 - 16, xposvisual1 + 16, yposvisual1 + 16, {0, 0, 255, 128}, "blue")
   gui.box(xposvisual2 - 16, yposvisual2 - 16, xposvisual2 + 16, yposvisual2 + 16, {255, 127, 0, 128}, {255, 127, 0})
   gui.box(xposvisual3 - 16, yposvisual3 - 16, xposvisual3 + 16, yposvisual3 + 16, {255, 0, 0, 128}, "red")

if memory.readbytesigned(0xfffef1) == 0 then 
   x1 = math.abs(xposvisual2 - xposvisual1)
   y1 = math.abs(yposvisual2 - yposvisual1)
   x2 = math.abs(xposvisual3 - xposvisual1)
   y2 = math.abs(yposvisual3 - yposvisual1)
   gui.line(xposvisual1, yposvisual1, xposvisual2, yposvisual2 , "white")
   gui.line(xposvisual1, yposvisual1, xposvisual3, yposvisual3 , "white")

   distance1 = (x1^2+y1^2)^(1/2)
   distance2 = (x2^2+y2^2)^(1/2)

   message = string.format("%d /", distance1)
   gui.text(xposvisual1 - 24, yposvisual1 - 25, message, "white", "black")
   message = string.format("%d px.", distance2)
   gui.text(xposvisual1 + 4, yposvisual1 - 25, message, "white", "black")


elseif memory.readbytesigned(0xfffef1) == 76 then
   x1 = math.abs(xposvisual3 - xposvisual2)
   y1 = math.abs(yposvisual3 - yposvisual2)
   x2 = math.abs(xposvisual1 - xposvisual2)
   y2 = math.abs(yposvisual1 - yposvisual2)
   gui.line(xposvisual2, yposvisual2, xposvisual3, yposvisual3 , "white")
   gui.line(xposvisual2, yposvisual2, xposvisual1, yposvisual1 , "white")

   distance1 = (x1^2+y1^2)^(1/2)
   distance2 = (x2^2+y2^2)^(1/2)

   message = string.format("%d /", distance1)
   gui.text(xposvisual2 - 24, yposvisual2 - 25, message, "white", "black")
   message = string.format("%d px.", distance2)
   gui.text(xposvisual2 + 4, yposvisual2 - 25, message, "white", "black")


elseif memory.readbytesigned(0xfffef1) == -104 then
   x1 = math.abs(xposvisual1 - xposvisual3)
   y1 = math.abs(yposvisual1 - yposvisual3)
   x2 = math.abs(xposvisual2 - xposvisual3)
   y2 = math.abs(yposvisual2 - yposvisual3)
   gui.line(xposvisual3, yposvisual3, xposvisual1, yposvisual1 , "white")
   gui.line(xposvisual3, yposvisual3, xposvisual2, yposvisual2 , "white")

   distance1 = (x1^2+y1^2)^(1/2)
   distance2 = (x2^2+y2^2)^(1/2)

   message = string.format("%d /", distance1)
   gui.text(xposvisual3 - 24, yposvisual3 - 25, message, "white", "black")
   message = string.format("%d px.", distance2)
   gui.text(xposvisual3 + 4, yposvisual3 - 25, message, "white", "black")
  end



elseif rom == 32 or rom == 116 or rom == 105 or rom == 51 then

--If rom is Sonic 3 & Knuckles /Amy in Sonic 3 /Sonic 3 & Knuckles Master edition 2 /Sonic 3 & Knuckles Master edition
--Or rom is Sonic 3

	-- get the X and Y velocity of the player
	xvel = memory.readwordsigned(0xffb018) -- sonic the hedgehog 3
	bxvel = memory.readbytesigned(0xffb018)
	yvel = memory.readwordsigned(0xffb01a)
	byvel = memory.readbytesigned(0xffb01a)


	-- get the X and Y velocity of the player 2
	txvel = memory.readwordsigned(0xffb062) -- tails (miles) prower
	btxvel = memory.readbytesigned(0xffb062)
	tyvel = memory.readwordsigned(0xffb064)
	btyvel = memory.readbytesigned(0xffb064)


	-- get the position of each character
   camX = memory.readword(0xffee78) -- x position of the camera
   camY = memory.readword(0xffee7c) -- y position of the camera
   p1x = memory.readwordunsigned(0xffb010) -- x position of sonic
   p1y = memory.readwordunsigned(0xffb014) -- y position of sonic
   p2x = memory.readwordunsigned(0xffb05a) -- x position of tails
   p2y = memory.readwordunsigned(0xffb05e) -- y position of tails
   p1sxb = memory.readwordunsigned(0xffb012) -- subx position of sonic
   p1syb = memory.readwordunsigned(0xffb016) -- suby position of sonic
   p2sxb = memory.readwordunsigned(0xffb05c) -- subx position of tails
   p2syb = memory.readwordunsigned(0xffb060) -- suby position of tails
   p1sx = p1sxb/256
   p2sx = p2sxb/256
   p1sy = p1syb/256
   p2sy = p2syb/256
	ss = p2x-p1x
	st = p2y-p1y



if memory.readwordsigned(0xffb018)>0 then





if memory.readwordsigned(0xffb018)<257 then
	message = string.format("velocity: %d, %d", xvel, yvel)
	gui.text(10, 80, message, "#32CD32FF", "black")
else 	message = string.format("velocity: %d, %d", xvel, yvel)
	gui.text(10, 80, message, "#FF0000FF", "black") end
if memory.readbytesigned(0xffb018)<10 then
	message = string.format("velocity: %d, %d", bxvel, byvel)
	gui.text(10, 90, message, "#FF0000FF", "black")
elseif memory.readbytesigned(0xffb018)>16 then
	message = string.format("velocity: %d, %d", bxvel, byvel)
	gui.text(10, 90, message, "#FFFFFFFF", "black")
else    message = string.format("velocity: %d, %d", bxvel, byvel)
	gui.text(10, 90, message, "#32CD32FF", "black") end

else





if memory.readwordsigned(0xffb018)>-257 then
	message = string.format("velocity: %d, %d", xvel, yvel)
	gui.text(10, 80, message, "#32CD32FF", "black")
else 	message = string.format("velocity: %d, %d", xvel, yvel)
	gui.text(10, 80, message, "#FF0000FF", "black") end
if memory.readbytesigned(0xffb018)>-10 then
	message = string.format("velocity: %d, %d", bxvel, byvel)
	gui.text(10, 90, message, "#FF0000FF", "black")
elseif memory.readbytesigned(0xffb018)<-16 then
	message = string.format("velocity: %d, %d", bxvel, byvel)
	gui.text(10, 90, message, "#FFFFFFFF", "black")
else    message = string.format("velocity: %d, %d", bxvel, byvel)
	gui.text(10, 90, message, "#32CD32FF", "black") end

end

	message = string.format("sonic subpix: %d, %d", p1sx, p1sy)
	gui.text(10, 110, message, "#FFFFFFF", "black")
	message = string.format("speed:    %d", memory.readwordsigned(0xffb01c))
	gui.text(10, 100, message, "#0080FFFF", "black")


if Tails_HUD == true then

	message = string.format("sonic: %d, %d, : %d", p1x, p1y, ss)
	gui.text(10, 51, message, "#FFFF00FF", "black")
	message = string.format("tails: %d, %d, : %d", p2x, p2y, st)
	gui.text(10, 59, message, "#FFFF00FF", "black")

	message = string.format("tails subpix: %d, %d", p2sx, p2sy)
	gui.text(200, 110, message, "#FFFFFFF", "black")

if memory.readwordsigned(0xffb062)>0 then





if memory.readwordsigned(0xffb062)<257 then
	message = string.format("velocity: %d, %d", txvel, tyvel)
	gui.text(220, 80, message, "#32CD32FF", "black")
else 	message = string.format("velocity: %d, %d", txvel, tyvel)
	gui.text(220, 80, message, "#FF0000FF", "black") end
if memory.readbytesigned(0xffb062)<10 then
	message = string.format("velocity: %d, %d", btxvel, btyvel)
	gui.text(220, 90, message, "#FF0000FF", "black")
elseif memory.readbytesigned(0xffb062)>16 then
	message = string.format("velocity: %d, %d", btxvel, btyvel)
	gui.text(220, 90, message, "#FFFFFFFF", "black")
else    message = string.format("velocity: %d, %d", btxvel, btyvel)
	gui.text(220, 90, message, "#32CD32FF", "black") end
else





if memory.readwordsigned(0xffb062)>-257 then
	message = string.format("velocity: %d, %d", txvel, tyvel)
	gui.text(220, 80, message, "#32CD32FF", "black")
else 	message = string.format("velocity: %d, %d", txvel, tyvel)
	gui.text(220, 80, message, "#FF0000FF", "black") end
if memory.readbytesigned(0xffb062)>-10 then
	message = string.format("velocity: %d, %d", btxvel, btyvel)
	gui.text(220, 90, message, "#FF0000FF", "black")
elseif memory.readbytesigned(0xffb062)<-16 then
	message = string.format("velocity: %d, %d", btxvel, btyvel)
	gui.text(220, 90, message, "#FFFFFFFF", "black")
else    message = string.format("velocity: %d, %d", btxvel, btyvel)
	gui.text(220, 90, message, "#32CD32FF", "black") end
end

	message = string.format("speed:    %d", memory.readwordsigned(0xffb066))
	gui.text(220, 100, message, "#FF8000FF", "black")

-- compare Tails' position to Sonic's

   xposvisual1 = p1x - camX
   yposvisual1 = p1y - camY
   xposvisual2 = p2x - camX
   yposvisual2 = p2y - camY

   gui.box(xposvisual1 - 16, yposvisual1 - 16, xposvisual1 + 16, yposvisual1 + 16, {0, 0, 255, 128}, "blue")
   gui.box(xposvisual2 - 16, yposvisual2 - 16, xposvisual2 + 16, yposvisual2 + 16, {255, 127, 0, 128}, {255, 127, 0})
   gui.line(xposvisual1, yposvisual1, xposvisual2, yposvisual2 , "white")

   x = math.abs(xposvisual2 - xposvisual1)
   y = math.abs(yposvisual2 - yposvisual1)
   distance = (x^2+y^2)^(1/2)

   message = string.format("%d px.", distance)
   gui.text(xposvisual1 - 10, yposvisual1 - 25, message, "white", "black")
  end
if Tails_HUD == false then
   	message = string.format("sonic: %d, %d", p1x, p1y)
	gui.text(10, 51, message, "#FFFF00FF", "black")

 

return
end
--******************************************************************************************************--

elseif rom == 50 or rom == 86 then
-- if rom is Sonic 2 /Sonic 2 Master edition 3 /Amy in Sonic 2


	-- get the X and Y velocity of the player
	xvel = memory.readwordsigned(0xffb010) -- sonic the hedgehog 2
	bxvel = memory.readbytesigned(0xffb010)
	yvel = memory.readwordsigned(0xffb012)
	byvel = memory.readbytesigned(0xffb012)


	-- get the X and Y velocity of the player 2
	txvel = memory.readwordsigned(0xffb050) -- tails (miles) prower
	btxvel = memory.readbytesigned(0xffb050)
	tyvel = memory.readwordsigned(0xffb052)
	btyvel = memory.readbytesigned(0xffb052)


	-- get the position of each character
   camX = memory.readword(0xffee00) -- x position of the camera
   camY = memory.readword(0xffee04) -- y position of the camera
   p1x = memory.readwordunsigned(0xffb008) -- x position of sonic
   p1y = memory.readwordunsigned(0xffb00c) -- y position of sonic
   p2x = memory.readwordunsigned(0xffb048) -- x position of tails
   p2y = memory.readwordunsigned(0xffb04c) -- y position of tails


	ss = p2x-p1x
	st = p2y-p1y


if memory.readwordsigned(0xffb018)>0 then





if memory.readwordsigned(0xffb010)<257 then
	message = string.format("velocity: %d, %d", xvel, yvel)
	gui.text(10, 80, message, "#32CD32FF", "black")
else 	message = string.format("velocity: %d, %d", xvel, yvel)
	gui.text(10, 80, message, "#FF0000FF", "black") end
if memory.readbytesigned(0xffb010)<10 then
	message = string.format("velocity: %d, %d", bxvel, byvel)
	gui.text(10, 90, message, "#FF0000FF", "black")
elseif memory.readbytesigned(0xffb010)>17 then
	message = string.format("velocity: %d, %d", bxvel, byvel)
	gui.text(10, 90, message, "#FFFFFFFF", "black")
else    message = string.format("velocity: %d, %d", bxvel, byvel)
	gui.text(10, 90, message, "#32CD32FF", "black") end

else





if memory.readwordsigned(0xffb010)>-257 then
	message = string.format("velocity: %d, %d", xvel, yvel)
	gui.text(10, 80, message, "#32CD32FF", "black")
else 	message = string.format("velocity: %d, %d", xvel, yvel)
	gui.text(10, 80, message, "#FF0000FF", "black") end
if memory.readbytesigned(0xffb010)>-10 then
	message = string.format("velocity: %d, %d", bxvel, byvel)
	gui.text(10, 90, message, "#FF0000FF", "black")
elseif memory.readbytesigned(0xffb010)<-17 then
	message = string.format("velocity: %d, %d", bxvel, byvel)
	gui.text(10, 90, message, "#FFFFFFFF", "black")
else    message = string.format("velocity: %d, %d", bxvel, byvel)
	gui.text(10, 90, message, "#32CD32FF", "black") end

end

	message = string.format("speed:    %d", memory.readwordsigned(0xffb014))
	gui.text(10, 100, message, "#0080FFFF", "black")

if Tails_HUD == true then

	message = string.format("sonic: %d, %d, : %d", p1x, p1y, ss)
	gui.text(10, 51, message, "#FFFF00FF", "black")
	message = string.format("tails: %d, %d, : %d", p2x, p2y, st)
	gui.text(10, 59, message, "#FFFF00FF", "black")

if memory.readwordsigned(0xffb050)>0 then





if memory.readwordsigned(0xffb050)<257 then
	message = string.format("velocity: %d, %d", txvel, tyvel)
	gui.text(220, 80, message, "#32CD32FF", "black")
else 	message = string.format("velocity: %d, %d", txvel, tyvel)
	gui.text(220, 80, message, "#FF0000FF", "black") end
if memory.readbytesigned(0xffb050)<10 then
	message = string.format("velocity: %d, %d", btxvel, btyvel)
	gui.text(220, 90, message, "#FF0000FF", "black")
elseif memory.readbytesigned(0xffb050)>17 then
	message = string.format("velocity: %d, %d", btxvel, btyvel)
	gui.text(220, 90, message, "#FFFFFFFF", "black")
else    message = string.format("velocity: %d, %d", btxvel, btyvel)
	gui.text(220, 90, message, "#32CD32FF", "black") end
else





if memory.readwordsigned(0xffb050)>-257 then
	message = string.format("velocity: %d, %d", txvel, tyvel)
	gui.text(220, 80, message, "#32CD32FF", "black")
else 	message = string.format("velocity: %d, %d", txvel, tyvel)
	gui.text(220, 80, message, "#FF0000FF", "black") end
if memory.readbytesigned(0xffb050)>-10 then
	message = string.format("velocity: %d, %d", btxvel, btyvel)
	gui.text(220, 90, message, "#FF0000FF", "black")
elseif memory.readbytesigned(0xffb050)<-17 then
	message = string.format("velocity: %d, %d", btxvel, btyvel)
	gui.text(220, 90, message, "#FFFFFFFF", "black")
else    message = string.format("velocity: %d, %d", btxvel, btyvel)
	gui.text(220, 90, message, "#32CD32FF", "black") end
end

	message = string.format("speed:    %d", memory.readwordsigned(0xffb054))
	gui.text(220, 100, message, "#FF8000FF", "black")

-- compare Tails' position to Sonic's

   xposvisual1 = p1x - camX
   yposvisual1 = p1y - camY
   xposvisual2 = p2x - camX
   yposvisual2 = p2y - camY

   gui.box(xposvisual1 - 16, yposvisual1 - 16, xposvisual1 + 16, yposvisual1 + 16, {0, 0, 255, 128}, "blue")
   gui.box(xposvisual2 - 16, yposvisual2 - 16, xposvisual2 + 16, yposvisual2 + 16, {255, 127, 0, 128}, {255, 127, 0})
   gui.line(xposvisual1, yposvisual1, xposvisual2, yposvisual2 , "white")

   x = math.abs(xposvisual2 - xposvisual1)
   y = math.abs(yposvisual2 - yposvisual1)
   distance = (x^2+y^2)^(1/2)

   message = string.format("%d px.", distance)

   gui.text(xposvisual1 - 10, yposvisual1 - 25, message, "white", "black")
else
	message = string.format("sonic: %d, %d", p1x, p1y)
	gui.text(10, 51, message, "#FFFF00FF", "black")
end
--*******************************************************************************************************--

elseif rom == 71 or rom == 74 then

--If rom is Sonic 1 or Sonic open source project

	-- get the X and Y velocity of the player
	xvel = memory.readwordsigned(0xffd010) -- sonic the hedgehog
	bxvel = memory.readbytesigned(0xffd010)
	yvel = memory.readwordsigned(0xffd012)
	byvel = memory.readbytesigned(0xffd012)


	-- get the position of the character
   p1x = memory.readwordunsigned(0xffd008) -- x position of sonic
   p1y = memory.readwordunsigned(0xffd00c) -- y position of sonic

	message = string.format("sonic: %d, %d", p1x, p1y)
	gui.text(10, 51, message, "#FFFF00FF", "black")


if memory.readwordsigned(0xffd010)>0 then





if memory.readbytesigned(0xffd010)<6 then
	message = string.format("velocity: %d, %d", xvel, yvel)
	gui.text(10, 80, message, "#F0000FF", "black")
	message = string.format("velocity: %d, %d", bxvel, byvel)
	gui.text(10, 90, message, "#FF0000FF", "black")
elseif memory.readbytesigned(0xffd010)>14 then
	message = string.format("velocity: %d, %d", xvel, yvel)
	gui.text(10, 80, message, "#FFFFFFFF", "black")
	message = string.format("velocity: %d, %d", bxvel, byvel)
	gui.text(10, 90, message, "#FFFFFFFF", "black")
else    message = string.format("velocity: %d, %d", bxvel, byvel)
	gui.text(10, 90, message, "#32CD32FF", "black")
	message = string.format("velocity: %d, %d", xvel, yvel)
	gui.text(10, 80, message, "#32CD32FF", "black") end

else




if memory.readbytesigned(0xffd010)>-6 then
	message = string.format("velocity: %d, %d", bxvel, byvel)
	gui.text(10, 90, message, "#FF0000FF", "black")
	message = string.format("velocity: %d, %d", xvel, yvel)
	gui.text(10, 80, message, "#FF0000FF", "black")
elseif memory.readbytesigned(0xffd010)<-14 then
	message = string.format("velocity: %d, %d", bxvel, byvel)
	gui.text(10, 90, message, "#FFFFFFFF", "black")
	message = string.format("velocity: %d, %d", xvel, yvel)
	gui.text(10, 80, message, "#FFFFFFFF", "black")
else    message = string.format("velocity: %d, %d", bxvel, byvel)
	gui.text(10, 90, message, "#32CD32FF", "black")
	message = string.format("velocity: %d, %d", xvel, yvel)
	gui.text(10, 80, message, "#32CD32FF", "black") end

end


else

--*******************************************************************************************************--

print("rom is not supported", rom)

--end of the HUD
end
end)

Last edited by feeuzz22 (2013-05-19 14:38:31)


Sonic is the fastest thing alive, and Hyper Sonic is the fastest thing.

Offline

#4 2013-01-10 16:10:01

WST
administrator
From: Maykop, RU · Jakarta, ID
Registered: 2012-10-06
Posts: 287
Website

Re: Useful Lua scripts

Let’s agree to add a header like this to all of our scripts

-- A simple Sonic 3 and Knuckles HUD
-- Gens Lua script by the members of Youtube Sonic TAS community <http://ystc.ru>

If you agree, edit your post above to much this pattern, and let me add it into my script collection on Github.


Sonic the EDGEhog has been obsoleted by Amy the LTEhog ©

Offline

#5 2013-01-10 16:49:45

feeuzz22
administrator
Registered: 2012-10-07
Posts: 249

Re: Useful Lua scripts

Okay, but a part of my script was written by Felipe and adapted by me only
It's correct.

Last edited by feeuzz22 (2013-01-10 17:46:22)


Sonic is the fastest thing alive, and Hyper Sonic is the fastest thing.

Offline

#6 2013-01-10 17:51:27

feeuzz22
administrator
Registered: 2012-10-07
Posts: 249

Re: Useful Lua scripts

You can add it


Sonic is the fastest thing alive, and Hyper Sonic is the fastest thing.

Offline

#7 2013-01-11 08:46:55

WST
administrator
From: Maykop, RU · Jakarta, ID
Registered: 2012-10-06
Posts: 287
Website

Re: Useful Lua scripts

feeuzz22 wrote:

You can add it

Done. Added a comment about Felipe’s code as well. Added you to the list of developers, so you are allowed to make commits now.
Pity that github does not provide Subversion repositories, I am a lot more experienced with Subversion, but yep, it’s true, Subversion is not in fashion now.

A short HOWTO for those who are unfamiliar with git:

If you want to connect the github repository to your computer (it will allow you to easilly keep the scripts up to date), use the following commands:

git clone https://github.com/WST/tas-scripts.git

To clone the repository into “tas-scripts” subdirectory in the current directory;

cd tas-scripts
git pull

To fetch the last updates from the repository.

On Windows systems, you may probably use TortoiseGit, but I’ve never tried it.


Sonic the EDGEhog has been obsoleted by Amy the LTEhog ©

Offline

#8 2013-01-12 12:25:32

feeuzz22
administrator
Registered: 2012-10-07
Posts: 249

Re: Useful Lua scripts

I've updated my script, Have I to rewrite it all on your github?


Sonic is the fastest thing alive, and Hyper Sonic is the fastest thing.

Offline

#9 2013-01-12 12:29:42

WST
administrator
From: Maykop, RU · Jakarta, ID
Registered: 2012-10-06
Posts: 287
Website

Re: Useful Lua scripts

feeuzz22 wrote:

I've updated my script, Have I to rewrite it all on your github?

1. Enter the directory
2. Edit the file
3. Execute the following commands:

export EDITOR=mcedit
git pull
git add s3k-hud.lua
git commit
git push

The last command will ask you for your github username and password.
The first command simply sets the text editor to edit the message describing your editions.

Btw, for some reasons using of the «Additional quick-save slots» script seems to cause desyncs sometimes. This needs investigating, I am not much experienced with Lua and Gens API for it.


Sonic the EDGEhog has been obsoleted by Amy the LTEhog ©

Offline

#10 2013-01-13 08:50:15

feeuzz22
administrator
Registered: 2012-10-07
Posts: 249

Re: Useful Lua scripts

WST wrote:
feeuzz22 wrote:

I've updated my script, Have I to rewrite it all on your github?

1. Enter the directory
2. Edit the file
3. Execute the following commands:

export EDITOR=mcedit
git pull
git add s3k-hud.lua
git commit
git push

The last command will ask you for your github username and password.
The first command simply sets the text editor to edit the message describing your editions.

thanks but Ctrl+C and Ctrl+V work too.

WST wrote:

Btw, for some reasons using of the «Additional quick-save slots» script seems to cause desyncs sometimes. This needs investigating, I am not much experienced with Lua and Gens API for it.

I don't know, I'm not experiienced in Lua.


Sonic is the fastest thing alive, and Hyper Sonic is the fastest thing.

Offline

#11 2013-01-13 09:00:42

WST
administrator
From: Maykop, RU · Jakarta, ID
Registered: 2012-10-06
Posts: 287
Website

Re: Useful Lua scripts

feeuzz22 wrote:

thanks but Ctrl+C and Ctrl+V work too

Ctrl+C and Ctrl+V? o_O where? yikes

(upd) ah, lol, web interface for editing… This is crazy %)


Sonic the EDGEhog has been obsoleted by Amy the LTEhog ©

Offline

#12 2013-01-13 09:46:15

feeuzz22
administrator
Registered: 2012-10-07
Posts: 249

Re: Useful Lua scripts

Is it possible to create a lua which let us to shoot avi in 30 fps (and two times less heavy)?
And is it possible to re-name a lua on your github?


Sonic is the fastest thing alive, and Hyper Sonic is the fastest thing.

Offline

#13 2013-01-13 09:56:32

WST
administrator
From: Maykop, RU · Jakarta, ID
Registered: 2012-10-06
Posts: 287
Website

Re: Useful Lua scripts

feeuzz22 wrote:

Is it possible to create a lua which let us to shoot avi in 30 fps (and two times less heavy)?
And is it possible to re-name a lua on your github?

Renaming is possible, but only if you use console tools as mentioned above. Maybe you simply tell me what name I should give the script?
Dumping avi from Lua should be possible, but I am not going to try it. You need to write avi files directly from your code. Of course, you will have to know avi format specification. And it seems that you’ll have to dump sound data separately.


Sonic the EDGEhog has been obsoleted by Amy the LTEhog ©

Offline

#14 2013-01-13 11:53:02

feeuzz22
administrator
Registered: 2012-10-07
Posts: 249

Re: Useful Lua scripts

hum... yeah.
name it like you want, just to say that now it's for s3k and s2.


Sonic is the fastest thing alive, and Hyper Sonic is the fastest thing.

Offline

#15 2013-01-15 09:37:12

feeuzz22
administrator
Registered: 2012-10-07
Posts: 249

Re: Useful Lua scripts

New update (and not the last): v2.5
**********Now can enable or disenable player 2 HUD using lua hotkey number 2********

-- A simple Sonic HUD for classic Sonic games and their hacks (Sonic, Tails, Knuckles, Amy)
-- Except Amy in Sonic 1 and Knuckles in Sonic 1 /Sonic 2
-- Gens Lua script by the members of Youtube Sonic TAS community <http://ystc.ru>
-- Include codes from Felipe @TasVideo.org

--Tails' hud is false by default
Tails_HUD = false
local hotkey_number = 2;
input.registerhotkey(hotkey_number, function()
if Tails_HUD == false then
Tails_HUD = true
else
Tails_HUD = false
end
return
end)

------------------------------------------------------------------------------------------------------------------
------------------------------------------------------------------------------------------------------------------
----**********************************************************************************************************----
---- you have to define a lua hotkey (the second) before lauching the srcipt if you want player 2 HUD (Tails) ----
----##########################################################################################################----
------------------------------------------------------------------------------------------------------------------
------------------------------------------------------------------------------------------------------------------



-- create space in memory for a savestate
state = savestate.create()

-- register a function to run when the screen gets updated
gui.register( function ()



--first, the timer:


  --reading datas
    timerpart1 = memory.readbytesigned(0xfffe23)
    timerpart2 = memory.readbytesigned(0xfffe24)
    timerpart3 = memory.readbytesigned(0xfffe25)

  --show them
if memory.readbytesigned(0xfffe25) < 10 then
if memory.readbytesigned(0xfffe24) < 10 then
        message = string.format("real timer:")
        gui.text(114, 01, message, "#FFFFFFFF", "black")
	message = string.format("  %d", timerpart1)
	gui.text(153, 01, message, "#FFFFFFFF", "black")
	message = string.format(":0%d:", timerpart2)
	gui.text(165, 01, message, "#FFFFFFFF", "black")
	message = string.format(" :0%d", timerpart3)
	gui.text(176, 01, message, "#FFFFFFFF", "black")
else
        message = string.format("real timer:")
        gui.text(114, 01, message, "#FFFFFFFF", "black")
	message = string.format("  %d", timerpart1)
	gui.text(153, 01, message, "#FFFFFFFF", "black")
	message = string.format(":%d:", timerpart2)
	gui.text(165, 01, message, "#FFFFFFFF", "black")
	message = string.format(" :0%d", timerpart3)
	gui.text(176, 01, message, "#FFFFFFFF", "black")
end
else
if memory.readbytesigned(0xfffe24) < 10 then
        message = string.format("real timer:")
        gui.text(114, 01, message, "#FFFFFFFF", "black")
	message = string.format("  %d", timerpart1)
	gui.text(153, 01, message, "#FFFFFFFF", "black")
	message = string.format(":0%d:", timerpart2)
	gui.text(165, 01, message, "#FFFFFFFF", "black")
	message = string.format(" :%d", timerpart3)
	gui.text(176, 01, message, "#FFFFFFFF", "black")
else
        message = string.format("real timer:")
        gui.text(114, 01, message, "#FFFFFFFF", "black")
	message = string.format("  %d", timerpart1)
	gui.text(153, 01, message, "#FFFFFFFF", "black")
	message = string.format(":%d:", timerpart2)
	gui.text(165, 01, message, "#FFFFFFFF", "black")
	message = string.format(" :%d", timerpart3)
	gui.text(176, 01, message, "#FFFFFFFF", "black")
end

end

--******************************************************************************************************--

--players' speed and position

--checking the rom

	rom = memory.readbyte(0x000013f)

if rom == 32 or rom == 116 or rom == 105 or rom == 51 then

--If rom is Sonic 3 & Knuckles /Amy in Sonic 3 /Sonic 3 & Knuckles Master edition 2 /Sonic 3 & Knuckles Master edition
--Or rom is Sonic 3

	-- get the X and Y velocity of the player
	xvel = memory.readwordsigned(0xffb018) -- sonic the hedgehog 3
	bxvel = memory.readbytesigned(0xffb018)
	yvel = memory.readwordsigned(0xffb01a)
	byvel = memory.readbytesigned(0xffb01a)


	-- get the X and Y velocity of the player 2
	txvel = memory.readwordsigned(0xffb062) -- tails (miles) prower
	btxvel = memory.readbytesigned(0xffb062)
	tyvel = memory.readwordsigned(0xffb064)
	btyvel = memory.readbytesigned(0xffb064)


	-- get the position of each character
   camX = memory.readword(0xffee78) -- x position of the camera
   camY = memory.readword(0xffee7c) -- y position of the camera
   p1x = memory.readwordunsigned(0xffb010) -- x position of sonic
   p1y = memory.readwordunsigned(0xffb014) -- y position of sonic
   p2x = memory.readwordunsigned(0xffb05a) -- x position of tails
   p2y = memory.readwordunsigned(0xffb05e) -- y position of tails


	ss = p2x-p1x
	st = p2y-p1y



if memory.readwordsigned(0xffb018)>0 then





if memory.readwordsigned(0xffb018)<257 then
	message = string.format("velocity: %d, %d", xvel, yvel)
	gui.text(10, 80, message, "#32CD32FF", "black")
else 	message = string.format("velocity: %d, %d", xvel, yvel)
	gui.text(10, 80, message, "#FF0000FF", "black") end
if memory.readbytesigned(0xffb018)<10 then
	message = string.format("velocity: %d, %d", bxvel, byvel)
	gui.text(10, 90, message, "#FF0000FF", "black")
elseif memory.readbytesigned(0xffb018)>16 then
	message = string.format("velocity: %d, %d", bxvel, byvel)
	gui.text(10, 90, message, "#FFFFFFFF", "black")
else    message = string.format("velocity: %d, %d", bxvel, byvel)
	gui.text(10, 90, message, "#32CD32FF", "black") end

else





if memory.readwordsigned(0xffb018)>-257 then
	message = string.format("velocity: %d, %d", xvel, yvel)
	gui.text(10, 80, message, "#32CD32FF", "black")
else 	message = string.format("velocity: %d, %d", xvel, yvel)
	gui.text(10, 80, message, "#FF0000FF", "black") end
if memory.readbytesigned(0xffb018)>-10 then
	message = string.format("velocity: %d, %d", bxvel, byvel)
	gui.text(10, 90, message, "#FF0000FF", "black")
elseif memory.readbytesigned(0xffb018)<-16 then
	message = string.format("velocity: %d, %d", bxvel, byvel)
	gui.text(10, 90, message, "#FFFFFFFF", "black")
else    message = string.format("velocity: %d, %d", bxvel, byvel)
	gui.text(10, 90, message, "#32CD32FF", "black") end

end

	message = string.format("speed:    %d", memory.readwordsigned(0xffb01c))
	gui.text(10, 100, message, "#0080FFFF", "black")


if Tails_HUD == true then

	message = string.format("sonic: %d, %d, : %d", p1x, p1y, ss)
	gui.text(10, 51, message, "#FFFF00FF", "black")
	message = string.format("tails: %d, %d, : %d", p2x, p2y, st)
	gui.text(10, 59, message, "#FFFF00FF", "black")

if memory.readwordsigned(0xffb062)>0 then





if memory.readwordsigned(0xffb062)<257 then
	message = string.format("velocity: %d, %d", txvel, tyvel)
	gui.text(220, 80, message, "#32CD32FF", "black")
else 	message = string.format("velocity: %d, %d", txvel, tyvel)
	gui.text(220, 80, message, "#FF0000FF", "black") end
if memory.readbytesigned(0xffb062)<10 then
	message = string.format("velocity: %d, %d", btxvel, btyvel)
	gui.text(220, 90, message, "#FF0000FF", "black")
elseif memory.readbytesigned(0xffb062)>16 then
	message = string.format("velocity: %d, %d", btxvel, btyvel)
	gui.text(220, 90, message, "#FFFFFFFF", "black")
else    message = string.format("velocity: %d, %d", btxvel, btyvel)
	gui.text(220, 90, message, "#32CD32FF", "black") end
else





if memory.readwordsigned(0xffb062)>-257 then
	message = string.format("velocity: %d, %d", txvel, tyvel)
	gui.text(220, 80, message, "#32CD32FF", "black")
else 	message = string.format("velocity: %d, %d", txvel, tyvel)
	gui.text(220, 80, message, "#FF0000FF", "black") end
if memory.readbytesigned(0xffb062)>-10 then
	message = string.format("velocity: %d, %d", btxvel, btyvel)
	gui.text(220, 90, message, "#FF0000FF", "black")
elseif memory.readbytesigned(0xffb062)<-16 then
	message = string.format("velocity: %d, %d", btxvel, btyvel)
	gui.text(220, 90, message, "#FFFFFFFF", "black")
else    message = string.format("velocity: %d, %d", btxvel, btyvel)
	gui.text(220, 90, message, "#32CD32FF", "black") end
end

	message = string.format("speed:    %d", memory.readwordsigned(0xffb066))
	gui.text(220, 100, message, "#FF8000FF", "black")

-- compare Tails' position to Sonic's

   xposvisual1 = p1x - camX
   yposvisual1 = p1y - camY
   xposvisual2 = p2x - camX
   yposvisual2 = p2y - camY

   gui.box(xposvisual1 - 16, yposvisual1 - 16, xposvisual1 + 16, yposvisual1 + 16, {0, 0, 255, 128}, "blue")
   gui.box(xposvisual2 - 16, yposvisual2 - 16, xposvisual2 + 16, yposvisual2 + 16, {255, 127, 0, 128}, {255, 127, 0})
   gui.line(xposvisual1, yposvisual1, xposvisual2, yposvisual2 , "white")

   x = math.abs(xposvisual2 - xposvisual1)
   y = math.abs(yposvisual2 - yposvisual1)
   distance = (x^2+y^2)^(1/2)

   message = string.format("%d px.", distance)
   gui.text(xposvisual1 - 10, yposvisual1 - 25, message, "white", "black")
  end
if Tails_HUD == false then
   	message = string.format("sonic: %d, %d", p1x, p1y)
	gui.text(10, 51, message, "#FFFF00FF", "black")

 

return
end
--******************************************************************************************************--

elseif rom == 50 or rom == 86 then
-- if rom is Sonic 2 /Sonic 2 Master edition 3 /Amy in Sonic 2


	-- get the X and Y velocity of the player
	xvel = memory.readwordsigned(0xffb010) -- sonic the hedgehog 2
	bxvel = memory.readbytesigned(0xffb010)
	yvel = memory.readwordsigned(0xffb012)
	byvel = memory.readbytesigned(0xffb012)


	-- get the X and Y velocity of the player 2
	txvel = memory.readwordsigned(0xffb050) -- tails (miles) prower
	btxvel = memory.readbytesigned(0xffb050)
	tyvel = memory.readwordsigned(0xffb052)
	btyvel = memory.readbytesigned(0xffb052)


	-- get the position of each character
   camX = memory.readword(0xffee00) -- x position of the camera
   camY = memory.readword(0xffee04) -- y position of the camera
   p1x = memory.readwordunsigned(0xffb008) -- x position of sonic
   p1y = memory.readwordunsigned(0xffb00c) -- y position of sonic
   p2x = memory.readwordunsigned(0xffb048) -- x position of tails
   p2y = memory.readwordunsigned(0xffb04c) -- y position of tails


	ss = p2x-p1x
	st = p2y-p1y


if memory.readwordsigned(0xffb018)>0 then





if memory.readwordsigned(0xffb010)<257 then
	message = string.format("velocity: %d, %d", xvel, yvel)
	gui.text(10, 80, message, "#32CD32FF", "black")
else 	message = string.format("velocity: %d, %d", xvel, yvel)
	gui.text(10, 80, message, "#FF0000FF", "black") end
if memory.readbytesigned(0xffb010)<10 then
	message = string.format("velocity: %d, %d", bxvel, byvel)
	gui.text(10, 90, message, "#FF0000FF", "black")
elseif memory.readbytesigned(0xffb010)>17 then
	message = string.format("velocity: %d, %d", bxvel, byvel)
	gui.text(10, 90, message, "#FFFFFFFF", "black")
else    message = string.format("velocity: %d, %d", bxvel, byvel)
	gui.text(10, 90, message, "#32CD32FF", "black") end

else





if memory.readwordsigned(0xffb010)>-257 then
	message = string.format("velocity: %d, %d", xvel, yvel)
	gui.text(10, 80, message, "#32CD32FF", "black")
else 	message = string.format("velocity: %d, %d", xvel, yvel)
	gui.text(10, 80, message, "#FF0000FF", "black") end
if memory.readbytesigned(0xffb010)>-10 then
	message = string.format("velocity: %d, %d", bxvel, byvel)
	gui.text(10, 90, message, "#FF0000FF", "black")
elseif memory.readbytesigned(0xffb010)<-17 then
	message = string.format("velocity: %d, %d", bxvel, byvel)
	gui.text(10, 90, message, "#FFFFFFFF", "black")
else    message = string.format("velocity: %d, %d", bxvel, byvel)
	gui.text(10, 90, message, "#32CD32FF", "black") end

end

	message = string.format("speed:    %d", memory.readwordsigned(0xffb014))
	gui.text(10, 100, message, "#0080FFFF", "black")

if Tails_HUD == true then

	message = string.format("sonic: %d, %d, : %d", p1x, p1y, ss)
	gui.text(10, 51, message, "#FFFF00FF", "black")
	message = string.format("tails: %d, %d, : %d", p2x, p2y, st)
	gui.text(10, 59, message, "#FFFF00FF", "black")

if memory.readwordsigned(0xffb050)>0 then





if memory.readwordsigned(0xffb050)<257 then
	message = string.format("velocity: %d, %d", txvel, tyvel)
	gui.text(220, 80, message, "#32CD32FF", "black")
else 	message = string.format("velocity: %d, %d", txvel, tyvel)
	gui.text(220, 80, message, "#FF0000FF", "black") end
if memory.readbytesigned(0xffb050)<10 then
	message = string.format("velocity: %d, %d", btxvel, btyvel)
	gui.text(220, 90, message, "#FF0000FF", "black")
elseif memory.readbytesigned(0xffb050)>17 then
	message = string.format("velocity: %d, %d", btxvel, btyvel)
	gui.text(220, 90, message, "#FFFFFFFF", "black")
else    message = string.format("velocity: %d, %d", btxvel, btyvel)
	gui.text(220, 90, message, "#32CD32FF", "black") end
else





if memory.readwordsigned(0xffb050)>-257 then
	message = string.format("velocity: %d, %d", txvel, tyvel)
	gui.text(220, 80, message, "#32CD32FF", "black")
else 	message = string.format("velocity: %d, %d", txvel, tyvel)
	gui.text(220, 80, message, "#FF0000FF", "black") end
if memory.readbytesigned(0xffb050)>-10 then
	message = string.format("velocity: %d, %d", btxvel, btyvel)
	gui.text(220, 90, message, "#FF0000FF", "black")
elseif memory.readbytesigned(0xffb050)<-17 then
	message = string.format("velocity: %d, %d", btxvel, btyvel)
	gui.text(220, 90, message, "#FFFFFFFF", "black")
else    message = string.format("velocity: %d, %d", btxvel, btyvel)
	gui.text(220, 90, message, "#32CD32FF", "black") end
end

	message = string.format("speed:    %d", memory.readwordsigned(0xffb054))
	gui.text(220, 100, message, "#FF8000FF", "black")

-- compare Tails' position to Sonic's

   xposvisual1 = p1x - camX
   yposvisual1 = p1y - camY
   xposvisual2 = p2x - camX
   yposvisual2 = p2y - camY

   gui.box(xposvisual1 - 16, yposvisual1 - 16, xposvisual1 + 16, yposvisual1 + 16, {0, 0, 255, 128}, "blue")
   gui.box(xposvisual2 - 16, yposvisual2 - 16, xposvisual2 + 16, yposvisual2 + 16, {255, 127, 0, 128}, {255, 127, 0})
   gui.line(xposvisual1, yposvisual1, xposvisual2, yposvisual2 , "white")

   x = math.abs(xposvisual2 - xposvisual1)
   y = math.abs(yposvisual2 - yposvisual1)
   distance = (x^2+y^2)^(1/2)

   message = string.format("%d px.", distance)

   gui.text(xposvisual1 - 10, yposvisual1 - 25, message, "white", "black")
else
	message = string.format("sonic: %d, %d", p1x, p1y)
	gui.text(10, 51, message, "#FFFF00FF", "black")
end
--*******************************************************************************************************--

elseif rom == 71 then

--If rom is Sonic 1

	-- get the X and Y velocity of the player
	xvel = memory.readwordsigned(0xffd010) -- sonic the hedgehog
	bxvel = memory.readbytesigned(0xffd010)
	yvel = memory.readwordsigned(0xffd012)
	byvel = memory.readbytesigned(0xffd012)


	-- get the position of the character
   p1x = memory.readwordunsigned(0xffd008) -- x position of sonic
   p1y = memory.readwordunsigned(0xffd00c) -- y position of sonic

	message = string.format("sonic: %d, %d", p1x, p1y)
	gui.text(10, 51, message, "#FFFF00FF", "black")


if memory.readwordsigned(0xffd010)>0 then





if memory.readbytesigned(0xffd010)<6 then
	message = string.format("velocity: %d, %d", xvel, yvel)
	gui.text(10, 80, message, "#F0000FF", "black")
	message = string.format("velocity: %d, %d", bxvel, byvel)
	gui.text(10, 90, message, "#FF0000FF", "black")
elseif memory.readbytesigned(0xffd010)>14 then
	message = string.format("velocity: %d, %d", xvel, yvel)
	gui.text(10, 80, message, "#FFFFFFFF", "black")
	message = string.format("velocity: %d, %d", bxvel, byvel)
	gui.text(10, 90, message, "#FFFFFFFF", "black")
else    message = string.format("velocity: %d, %d", bxvel, byvel)
	gui.text(10, 90, message, "#32CD32FF", "black")
	message = string.format("velocity: %d, %d", xvel, yvel)
	gui.text(10, 80, message, "#32CD32FF", "black") end

else




if memory.readbytesigned(0xffd010)>-6 then
	message = string.format("velocity: %d, %d", bxvel, byvel)
	gui.text(10, 90, message, "#FF0000FF", "black")
	message = string.format("velocity: %d, %d", xvel, yvel)
	gui.text(10, 80, message, "#FF0000FF", "black")
elseif memory.readbytesigned(0xffd010)<-14 then
	message = string.format("velocity: %d, %d", bxvel, byvel)
	gui.text(10, 90, message, "#FFFFFFFF", "black")
	message = string.format("velocity: %d, %d", xvel, yvel)
	gui.text(10, 80, message, "#FFFFFFFF", "black")
else    message = string.format("velocity: %d, %d", bxvel, byvel)
	gui.text(10, 90, message, "#32CD32FF", "black")
	message = string.format("velocity: %d, %d", xvel, yvel)
	gui.text(10, 80, message, "#32CD32FF", "black") end

end


else

--*******************************************************************************************************--

print("rom is not supported", rom)

--end of the HUD
end
end)

Last edited by feeuzz22 (2013-01-16 13:51:58)


Sonic is the fastest thing alive, and Hyper Sonic is the fastest thing.

Offline

#16 2013-01-18 15:27:08

WST
administrator
From: Maykop, RU · Jakarta, ID
Registered: 2012-10-06
Posts: 287
Website

Re: Useful Lua scripts

if Tails_HUD == false then
   Tails_HUD = true
else
   Tails_HUD = false
end

huh?

Tails_HUD = not Tails_HUD

smile


Sonic the EDGEhog has been obsoleted by Amy the LTEhog ©

Offline

#17 2013-01-18 18:24:19

feeuzz22
administrator
Registered: 2012-10-07
Posts: 249

Re: Useful Lua scripts

Ham... Yes, yes, I didn't know This thing.


Sonic is the fastest thing alive, and Hyper Sonic is the fastest thing.

Offline

#18 2013-08-13 12:20:26

got4n
member
Registered: 2013-08-13
Posts: 1

Re: Useful Lua scripts

Lua Hud Script too should be useful tongue

Offline

#19 2013-08-14 06:42:18

feeuzz22
administrator
Registered: 2012-10-07
Posts: 249

Re: Useful Lua scripts

Of course it is, but these script you see here are written by our members.. or almost smile
Moreover, Marzojr's Lua script is so famous now... no need to explain tongue
Also, we can link this (if not already done).


Sonic is the fastest thing alive, and Hyper Sonic is the fastest thing.

Offline

Board footer

Powered by FluxBB

Яндекс.Метрика