User File #639020550928746688

Upload All User Files

#639020550928746688 (unlisted) - TAStudio Output Logger Demo v0.95

KirbyLogger.lua
99 downloads
Uploaded 12/23/2025 2:51 AM by TASeditor (see all 192)
For Kirby's Adventure


require("TAStudioLogger")

--Simple use of the TAStudio Logger script

-- Logs the value from memory for each frame. First argument is logger name, second is a function that returns the value from a memory.read call.
AddLogger("XVel", "s16_le@0x05B9") -- Read 16 bit signed lower endian at address 0x05B9
AddLogger("YVel", "s16_le@0x05BD")

AddLogger("Flags", 0x05E1) -- Read byte unsigned at address 0x05E1

AddLogger("Xpos", "u8@0x0095#u8@0x0083") -- Read byte unsigned 0x0095*256 + byte unsigned 0x0083



-- Prints the values from the "XVel" log into a new column in TAStudio called "XVel" with a color gradient from red to green for values from 0 to 704; 1.5 modifies the gradient.
-- The argument nil is for text and tells the program to just print the values from "XVel" log. 4 is the number of digits for the new column.
AddPrinter("XVel", "XVel", "gradientabs,704,0xFFFF0000,0xFF00FF00,0,1.5", nil, 4)
AddPrinter("oXv", "oldval,XVel", "gradientabs,704,0xFFFF0000,0xFF00FF00,0,1.5", nil, 4)
AddPrinter("YVel", "YVel", "gradientabs,880,0xFFFFFFFF,0xFF0000FF,0,0.75", "whennot", 4)

-- Adds a column called "DX" into TAStudio and prints the values from the RelativeBranchCompare function as formatted by the third function into TAStudio.
-- RelativeBranchCompare takes the values from log called "Xpos" and subracts the value in branch log "Xpos" and multiplies it by the sign of the value in log "XVel"
AddPrinter("DX", "relbranchcomp,Xpos,XVel", "gradient,256,0xFFFF0000,0xFF00FF00", "modform", 4)



-- More complicated examples below
			
flagcolors = {} -- States for Kirby
flagcolors[0] = Colors.white --0xFFE0E0E0  --  standing
flagcolors[1] = 0xFFE04090  -- walking
flagcolors[2] = 0xFFFF1050  -- running
flagcolors[3] = 0xFFB04090  -- stopping
flagcolors[4] = 0xFF7070FF  -- jumping
flagcolors[5] = 0xFFD030FF  -- falling
flagcolors[6] = 0xFFA070FF  -- ducking
flagcolors[7] = 0xFFE020B0  -- sliding
flagcolors[9] = 0xFFD0D010  -- inhaling
flagcolors[10] = 0xFFD0A010 --  spitting
flagcolors[11] = 0xFFD0A010 --  swallowing
flagcolors[12] = 0xFFE08080 --  powerup use
flagcolors[13] = 0xFFE050FF --  flying

flagtext = {}
flagtext[0] = "stnd"
flagtext[1] = "walk"
flagtext[2] = "run"
flagtext[3] = "stop"
flagtext[4] = "jump"
flagtext[5] = "fall"
flagtext[6] = "duck"
flagtext[7] = "slde"
flagtext[9] = "succ"
flagtext[10] = "spit"
flagtext[11] = "swal"
flagtext[12] = "powr"
flagtext[13] = "fly"


function AnyValueMatching(value, values)

	for k,v in pairs(values) do
		if value == v
		then return true
		end
	end
	
	return false
end

-- A function for the values to display in column "P1 Right"
-- Return the value in "Flags" log if the value in "XVel" is greater than 0 and the value in "Flags" is 1, 2, 3 or 7, else it returns nil
function RightBtnPrinterValue(index)

	local xv = GetLogValue("XVel", index)
	if xv ~= nil and xv > 0 and AnyValueMatching(GetLogValue("Flags", index), {1, 2, 3, 7}) 
	then return GetLogValue("Flags", index)
	end
	
end

-- Same as above, but if "XVel" is less than 0
function LeftBtnPrinterValue(index)

	local xv = GetLogValue("XVel", index)
	if xv ~= nil and xv < 0 and AnyValueMatching(GetLogValue("Flags", index), {1, 2, 3, 7})
	then return GetLogValue("Flags", index)
	end
	
end

-- Returns the value in "Flags" if the value is in values
function FlagPrinterValue(index, values)

	if AnyValueMatching(GetLogValue("Flags", index), values)
	then return GetLogValue("Flags", index)
	end

end

-- New Column with the flagcolors table for coloring and flagtext for outputting text when the value has changed
AddPrinter("Flag", "Flags", flagcolors, "onchange;table,flagtext", 4)

AddPrinter("P1 Up",    function(index) return FlagPrinterValue(index, {13}) end, flagcolors, "") -- Color column "P1 Up" with the color in colortable if the value in "Flags" is 13
AddPrinter("P1 Down",  function(index) return FlagPrinterValue(index, {6, 7, 11}) end, flagcolors, "")
AddPrinter("P1 Right", RightBtnPrinterValue, flagcolors, "")
AddPrinter("P1 Left",  LeftBtnPrinterValue, flagcolors, "")
AddPrinter("P1 B",     function(index) return FlagPrinterValue(index, {9, 10, 12}) end, flagcolors, "")
AddPrinter("P1 A",     function(index) return FlagPrinterValue(index, {4, 5}) end, flagcolors, "")

InitializeLogger() -- Needed to load files and setting up variables and callbacks

while true do
	
	UpdateLogger() -- Logs values
	
	emu.yield()
end