Editor, Expert player (2477)
Joined: 4/8/2005
Posts: 1573
Location: Gone for a year, just for varietyyyyyyyyy!!
Can somebody tell me why Lua won't understand my X, Y and Z buttons?
joypad.set(1,{X=1})
joypad.set(1,{Y=1})
joypad.set(1,{Z=1})
All other buttons work without any problem.
upthorn
He/Him
Emulator Coder, Active player (391)
Joined: 3/24/2006
Posts: 1802
Have you made sure that your joypad is set to 6-button mode?
How fleeting are all human passions compared with the massive continuity of ducks.
Editor, Expert player (2477)
Joined: 4/8/2005
Posts: 1573
Location: Gone for a year, just for varietyyyyyyyyy!!
upthorn wrote:
Have you made sure that your joypad is set to 6-button mode?
Yes. Double-checked.
Joined: 10/3/2005
Posts: 1332
Hm. I thought Upthorn had it. This is probably a useless suggestion, but I'll put it forth anyway:
joypad.set(1, { ["X"] = true } )
...But logically, if joypad.set(1, {left = 1}) works as you imply it does, then there's no reason why this should work any better.
Banned User
Joined: 12/14/2009
Posts: 386
Location: Santiago, Chile
I created a code that makes the camera perfectly follow only to Tails, and not to Sonic. However it has graphics problems, what do you think?
gui.register( function ()
	
	p2x = memory.readwordunsigned(0xffb048)
	p2y = memory.readwordunsigned(0xffb04c)
	camx = memory.readword(0xffee00)
	camy = memory.readword(0xffee04)

	if p2x - (320/2) >= 0 then
		memory.writeword(0xffee00, p2x - (320/2))
	end
	memory.writeword(0xffee04, p2y - (224/2))

end)
Post subject: sonic-tails-path.lua
Banned User
Joined: 12/14/2009
Posts: 386
Location: Santiago, Chile
Look at this.
gui.register( function()
	
	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

	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)
It is a small LUA I wrote that has the function of: Highlight Sonic with a blue square and with an orange to Tails. They are united with a white line, on to Sonic is written the distance (in pixels) between Sonic and Tails.
Player (37)
Joined: 9/9/2006
Posts: 388
Felipe if you ever manage to get that code to show tails locked onto the screen with correct re-draw that is gonna be awesome. I will point out though that whilst I was simply watching the Sonic2 demos to see where tails ended up half the time, it caused them to desync (which in theory would cause netplay to desync too?)
A whisper in the wind~~
Banned User
Joined: 12/14/2009
Posts: 386
Location: Santiago, Chile
Is there any way to capture an image out of the game screen? This way could make TailsCam.lua The idea is that when Tails is out of the screen, the camera is activated and if he re-enters the screen, deactivated the camera. The values ​​in the memory useful for this are as follows: P2 X Pixel Position : word @ FFB048 (unsigned) P2 Y Pixel Position : word @ FFB04C (unsigned)
Player (37)
Joined: 9/9/2006
Posts: 388
As far as I'm aware. The hard-coded Camera hacks function by rendering the next X frames earlier, forcing Sonic & Cam to the required location for those frames, saving the data and using it to render. If possible, that might allow TailsCam.lua? You would essentially do the same thing, forward render (forcing Sonic to Tails' off-screen location) and take a copy of the tile data or whatever, so you can re-draw the screen.
A whisper in the wind~~
Banned User
Joined: 12/14/2009
Posts: 386
Location: Santiago, Chile
I have an idea, but i dont know how to write it. I had thought to obtain the following values:
    P1 X Pixel Position word @ FFB008 (unsigned) P1 Y Pixel Position word @ FFB00C (unsigned) P2 X Pixel Position word @ FFB048 (unsigned) P2 Y Pixel Position word @ FFB04C (unsigned) Camera X Position dword @ FFEE00 Camera Y Position dword @ FFEE04
The first is to position the screen in Tails and capture the screen. After, place the screen in Sonic and do the same. The 2 screenshots, go printed to the left side to see Sonic and Tails on the other side. How to divide the screen into 2. After the camera is positioned just where it was originally to avoid desync. Not exactly what I want but you will see to the 2 players.
Player (37)
Joined: 9/9/2006
Posts: 388
Sounds interesting and that's certainly -an- way to it. I thought perhaps though you should however; 1) STORE P1x,P1y & CamX, CamY in a variable 2) SET P1x,P1y & CamX,CamY to P2x,P2y 3) Screenshot the level data (somehow) 4) Restore P1x,P1y, & CamX, CamY to original values. This way you would get the level data you need to re-draw the screen when doing Tails.lua and can accurately draw it (which perhaps also fixes desyncs?) I'm pretty sure that as long as you do the above per screen render process, movies should sync up fine as the GAME will still see things happen the way they should, but the EMULATOR would allow the player to see Tails off-screen with accurate level data.
A whisper in the wind~~
Banned User
Joined: 12/14/2009
Posts: 386
Location: Santiago, Chile
This is what I can think to do:
-- Important variables
CamX = memory.readdword(0xffee00)
CamY = memory.readdword(0xffee04)

-- After, set camera's position in Tails an capture screen
memory.writedword(0xffee00, memory.readword(0xffb048) - 240)
memory.writedword(0xffee04, memory.readword(0xffb04c) - 112)
TailsCam = gens.gdscreenshot()

-- After, set camera's position in Sonic an capture screen
memory.writedword(0xffee00, memory.readword(0xffb008) - 160)
memory.writedword(0xffee04, memory.readword(0xffb00c) - 112)
SonicCam = gens.gdscreenshot()

-- Finally draw the pictures and set the camera's position to original.
gens.drawimage(-160,0,TailsCam)
gens.drawimage(160,0,SonicCam)
memory.writedword(0xffee00, CamX)
memory.writedword(0xffee04, CamY)
I dont know if it is well written, but this should work. But i dont know in what event run it. Maybe someone could make it any arrangement.
Player (37)
Joined: 9/9/2006
Posts: 388
Felipe wrote:
This is what I can think to do:
-- Important variables
CamX = memory.readdword(0xffee00)
CamY = memory.readdword(0xffee04)

-- After, set camera's position in Tails an capture screen
memory.writedword(0xffee00, memory.readword(0xffb048) - 240)
memory.writedword(0xffee04, memory.readword(0xffb04c) - 112)
TailsCam = gens.gdscreenshot()

-- After, set camera's position in Sonic an capture screen
memory.writedword(0xffee00, memory.readword(0xffb008) - 160)
memory.writedword(0xffee04, memory.readword(0xffb00c) - 112)
SonicCam = gens.gdscreenshot()

-- Finally draw the pictures and set the camera's position to original.
gens.drawimage(-160,0,TailsCam)
gens.drawimage(160,0,SonicCam)
memory.writedword(0xffee00, CamX)
memory.writedword(0xffee04, CamY)
I dont know if it is well written, but this should work. But i dont know in what event run it. Maybe someone could make it any arrangement.
nitsuja wrote:
This isn't so useful, but here's a little script that applies extreme motion blur to everything:
gens.registerbefore(function() gui.image(gui.gdscreenshot(), 0.8) end)
I adapted this.. doesn't seem to work as you suggest though... I think your missing the step of putting the two images into one as disabling either gui.image for Sonic/Tails ends up with interesting results...
gens.registerbefore(function()
	-- Important variables 
	CamX = memory.readdword(0xffee00) 
	CamY = memory.readdword(0xffee04) 

	-- After, set camera's position in Tails an capture screen 
	memory.writedword(0xffee00, memory.readword(0xffb048) - 240) 
	memory.writedword(0xffee04, memory.readword(0xffb04c) - 112) 
	TailsCam = gui.gdscreenshot() 

	-- After, set camera's position in Sonic an capture screen 
	memory.writedword(0xffee00, memory.readword(0xffb008) - 160) 
	memory.writedword(0xffee04, memory.readword(0xffb00c) - 112) 
	SonicCam = gui.gdscreenshot() 

	-- Finally draw the pictures and set the camera's position to original. 
	gui.image(-160,0,TailsCam) 
	gui.image(160,0,SonicCam) 
	memory.writedword(0xffee00, CamX) 
	memory.writedword(0xffee04, CamY)

end)
 
A whisper in the wind~~
Player (37)
Joined: 9/9/2006
Posts: 388
Alright.. so I sat and did some fiddling... and I can't help but wonder that THIS code should work;
gens.registerbefore(function()
	-- Important variables 
	SonicX = memory.readwordunsigned(0xffb008)
	SonicY = memory.readwordunsigned(0xffb00c)
	TailsX = memory.readwordunsigned(0xffb048)
	TailsY = memory.readwordunsigned(0xffb04c)

	-- Set Sonic's position in Tails an capture screen
	if TailsX>= 0 then memory.writeword(0xffb008, TailsX) end -- Set SonicX to TAILSX
	if TailsY>= 0 then memory.writeword(0xffb00c, TailsY) end -- set SonicY to TAILSY
	TailsCam = gui.gdscreenshot() 

	-- After, reset Sonic's position.
	memory.writeword(0xffb008, SonicX)					-- set SonicX to SonX
	memory.writeword(0xffb00c, SonicY)					-- set SonicY to SonY

	-- Finally draw the picture on the bottom half of the screen. (split-screen style) 
	gui.image(0,(224/2),TailsCam) 
end)
This should cause the level data to load correctly due to Sonic being at Tails' Co-ords which happens to bring along the Camera also. It seems to work alright and the Sonic2 demos don't desync at all, it even happily draws the split-screen view. What I don't get is that the second view (which should be showing modified camera?) is just a clone of the first?
A whisper in the wind~~
Banned User
Joined: 12/14/2009
Posts: 386
Location: Santiago, Chile
It is rare but apparently what the catch is to take a photo to the position of Sonic. Writing in the memory RAM, I think that not update if it not go to next frame. I think that should be used.
gens.frameadvance and savestate.create
I'll see if I can fix that.
Banned User
Joined: 12/14/2009
Posts: 386
Location: Santiago, Chile
For more I try get the same results. I thought that gens.emulateframeinvisible () would work. Althought i dont know how use: gens.frameadvance (), and I'm not sure that this will work. The point is to first adjust the position X, Y Sonic to Tails. Then save a savestate and emulate, 1 or 2 frames in the future to update the changes to memory. Then we capture the photo and load the savestate. Perhaps, frameadvance, is the key but I do not know use it.
Player (37)
Joined: 9/9/2006
Posts: 388
Taking another stab at it came up with this;
gens.registerafter( function()
		SonicX = memory.readwordunsigned(0xffb008) 
		SonicY = memory.readwordunsigned(0xffb00c) 
		TailsX = memory.readwordunsigned(0xffb048) 
		TailsY = memory.readwordunsigned(0xffb04c) 
		
		-- Save a rewind point.
		local state = savestate.create()
		savestate.save(state)

		-- Set Sonic's position in Tails
		if TailsX>= 1 then memory.writeword(0xffb008, TailsX) end -- Set SonicX to TAILSX 
		if TailsY>= 1 then memory.writeword(0xffb00c, TailsY) end -- set SonicY to TAILSY 
		
		--Frame Advance, Screencap, Rewind.
		gens.emulateframeinvisible()
		TailsCam = gui.gdscreenshot() 
		--savestate.load(state)
		
		-- Draw split-screen style if in level.
		if memory.readwordunsigned(0xFFF711)>=1 then gui.image(0,(224/2),TailsCam) end

end)
I wonder if the code is almost there because; If you uncomment --savestate.load(state), then the game is happy and runs as normal but you do not end up with split tails view. If you leave it commented the game is unhappy because Sonic is stuck at Tails. It seems that oddly the screenshot is getting updated along with the savestate, despite loading the savestate AFTER we've taken the screenshot.
A whisper in the wind~~
Former player
Joined: 7/6/2012
Posts: 207
Location: Réunion (FR)
Is it possible to write a script to dump AVI in HD? :)
~ [I]feeuzz
WST
She/Her
Active player (489)
Joined: 10/6/2011
Posts: 1697
Location: RU · ID · AM
I beleive it’s not a good idea to make direct uncompressed dumps in high resolution. A few minutes of such a video may have size of like a few terabytes… Way better to make HD on encoding stage.
S3&A [Amy amy%] improvement (with Evil_3D & kaan55) — currently in SPZ2 my TAS channel · If I ever come into your dream, I’ll be riding an eggship :)
Former player
Joined: 7/6/2012
Posts: 207
Location: Réunion (FR)
WST wrote:
I beleive it’s not a good idea to make direct uncompressed dumps in high resolution. A few minutes of such a video may have size of like a few terabytes… Way better to make HD on encoding stage.
yeah it's true...
~ [I]feeuzz
Joined: 2/16/2015
Posts: 26
marzojr wrote:
For the S3&K "go super" button: I made a script demonstrating how to make the Super/Hyper transformations (it is here). It is even possible to make a "Turbo Tails" transformation with only the seven chaos emeralds (it is off by default in the script I posted). You are free to incorporate it in your script if you wish.
Is There a S3K Super Lua for Sonic 3K Rom Hack?