简体   繁体   中英

FCEUX stops responding when i run this code made by me

--llama a IUP

require("iuplua")

--Variables

on= 1

puntos1=memory.readbyte(0x0007DE) --Read the points value
puntos2=memory.readbyte(0x0007DF)
puntos3=memory.readbyte(0x0007E0)
puntos4=memory.readbyte(0x0007E1)
puntos5=memory.readbyte(0x0007E2)

p1=puntos1*100000 --Convert the raw values to it's game value
p2=puntos2*10000
p3=puntos3*1000
p4=puntos4*100
p5=puntos5*10

maxpuntaje=p1+p2+p3+p4+p5 --Calculate the final result

mundo=memory.readbyte(0x00075F) --Read the "world" value
nivel=memory.readbyte(0x000760) --Read the "level" value

estado=memory.readbyte(0x000770) --Read the mario "state" (00 not in game, 01 playing, 03 game over)

--Escribir las variables anteriores al morir


memory.writebyte(0x00075A,00) --Change the "lives" value to 1

while(on==1) do
estado=memory.readbyte(0x000770)
print(estado)
print(type(estado))
if(estado==03)then
    print("Puntuacion maxima (sesion actual) = ",maxpuntaje)
    print("Mundo y nivel Actual: ",mundo+1,"-",nivel+1)
end

end

(code edited)

This is the state of 0x000770 when playing

This is the state of 0x000770 when the Game Over scene jumps in

is there anything wrong? fceux just stop responding when i run this script, im new at stacks overflow and at programming so, every help will be welcome

It's rather simple to debug this but more information is required

  1. Make sure (estado==03) yields true and also print following variables and add into your question
    mundo=memory.readbyte(0x00075F)
    nivel=memory.readbyte(0x000760)
    estado=memory.readbyte(0x000770)
    print(mundo, nivel, estado)
  2. Check the types of these memory read vaiables ig print(type(mundo))
  3. Make Sure that the if condition checks against correct types
  4. You realize that memonry is read once and while is always true

Try this:

while(on==1) do
    estado=memory.readbyte(0x000770)
    print(estado)
    print(type(estado))
    if(estado==03)then
        print("Puntuacion maxima (sesion actual) = ",maxpuntaje)
        print("Mundo y nivel Actual: ",mundo+1,"-",nivel+1)
    end
end

im so sorry for wasting your time, but i found the error, it was actually quite simple, there was a missing FCEU.frameadvance at the end of the cycle. i dont know why it caused the emulator to crash but after putting it in place it stopped crashing. thanks to wsha for helping.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM