Salut, pour commencer je te conseille d'utiliser les balises [code=Lua][/code] afin de directement poster le Lua script dans ton message, ce qui donne ceci :
Language: Lua
-- simple sonic 2 speedometer display
-- demonstrates reading memory and writing text,
-- as well as predicting future frames and reading memory from them
-- create space in memory for a savestate
state = savestate.create()
-- register a function to run when the screen gets updated
gui.register( function ()
-- get the X and Y velocity of the player
xvel = memory.readwordsigned(0xffb010) -- sonic the hedgehog 2
yvel = memory.readwordsigned(0xffb012)
-- get the X and Y velocity of the player 2
txvel = memory.readwordsigned(0xffb050) -- tails (miles) prower
tyvel = memory.readwordsigned(0xffb052)
-- look 2 frames into the future, pretending the B button is held,
-- and get what the X and Y velocity of the player 2 will be
savestate.save(state)
for n=1,2 do
joypad.set(1, {B = true})
gens.emulateframeinvisible()
end
jumpxvel = memory.readwordsigned(0xffb010)
jumpyvel = memory.readwordsigned(0xffb012)
savestate.load(state) ------------------------------------------------------------------------------------------------------
jumpxvel2 = memory.readwordsigned(0xffb050)
jumpyvel2 = memory.readwordsigned(0xffb052)
savestate.load(state)
-- print the velocities onscreen, near the top-left corner,
-- in a blue color with a black outline
message = string.format("velocity: %d, %d", xvel, yvel)
gui.text(15, 60, message, "#0080FFFF", "black")
message = string.format("jump vel: %d, %d", jumpxvel, jumpyvel)
gui.text(15, 68, message, "#0080FFFF", "black")
message = string.format("speed: %d", memory.readwordsigned(0xffb014))
gui.text(22, 76, message, "#0080FFFF", "black")
-- print the velocities onscreen, near the top-right corner,
-- in a orange color with a black outline
message = string.format("velocity: %d, %d", txvel, tyvel)
gui.text(260, 60, message, "#FFA500FF", "black")
message = string.format("jump vel: %d, %d", jumpxvel2, jumpyvel2)
gui.text(260, 68, message, "#FFA500FF", "black")
message = string.format("speed: %d", memory.readwordsigned(0xffb054))
gui.text(260, 76, message, "#FFA500FF", "black")
end)
Je n'ai pas essayé de le lancer (je n'ai ni l'émulateur ni le jeu) mais à priori les adresses ont l'air d'avoir été correctement changées pour que le script fonctionne avec Sonic 2. Je ne suis pas sûr de totalement comprendre quel est ton problème mais je suis sûr que le savestate.load que j'ai indiqué avec des tirets est en trop (ou sinon il faudrait remettre une boucle qui fait avancer le jeu de 2 frames).
Si ça ne fonctionne pas après ça, alors il y a de fortes chances que le problème vienne du code couleur ou des coordonnées des messages (ou éventuellement de ta ROM, si tu as une version européenne au lieu de la version américaine par exemple).