Post subject: Need help with simple, 12 line LUA script
Banned User
Joined: 5/11/2004
Posts: 1049
I don't know how to program in LUA but this is roughly what the code would look like in java/matlab:
x=0
while x<400
  x=x+1
  load state1
  advance 1 frame
  save state1
  advance 1 frame with input (start)
  advance 500 frames

  key(x,1)=x
  key(x,2)=(current value of memory address 0055)
end
print key
So it should print a 400 by 2 array with 1 through 400 in the first column and the values of memory address 0055 in the second column. If anyone can convert that to LUA, that'd be greatly appreciated.
"Great spirits have always found violent opposition from mediocrities. The latter cannot understand it when a man does not thoughtlessly submit to hereditary prejudices but honestly and courageously uses his intelligence."
Post subject: Re: Need help with simple, 12 line LUA script
Skilled player (1652)
Joined: 11/15/2004
Posts: 2202
Location: Killjoy
x=0;
StateVar = savestate.create();
savestate.save(StateVar);
inpt = {};
inpt['start'] = true;
while (x<400) do
  x=x+1;
  savestate.load(StateVar);
  emu.frameadvance();
   savestate.save(StateVar);
  joypad.set(1,inpt);
  for i=0,501,1 do 
    emu.frameadvance();
  end;
  print(x .. "      " .. memory.readbyte(0x55));
end;
No guarantees this code works, but thats the psuedo code converted.
Sage advice from a friend of Jim: So put your tinfoil hat back in the closet, open your eyes to the truth, and realize that the government is in fact causing austismal cancer with it's 9/11 fluoride vaccinations of your water supply.
Banned User
Joined: 5/11/2004
Posts: 1049
Awesome thanks! but it doesn't work :( The code seems to be running as if these lines:
joypad.set(1,inpt); 
  for i=0,1,501 do 
    emu.frameadvance(); 
  end;
didn't exist hence start doesn't get pressed, and the 500 frame advance doesn't happen. It does advance through 400 frames printing the output correct in about 20s. I'm running this in FCEUX with teenage mutant ninja turtles rom
"Great spirits have always found violent opposition from mediocrities. The latter cannot understand it when a man does not thoughtlessly submit to hereditary prejudices but honestly and courageously uses his intelligence."
Skilled player (1652)
Joined: 11/15/2004
Posts: 2202
Location: Killjoy
Fixed my post. Oops
Sage advice from a friend of Jim: So put your tinfoil hat back in the closet, open your eyes to the truth, and realize that the government is in fact causing austismal cancer with it's 9/11 fluoride vaccinations of your water supply.
Banned User
Joined: 5/11/2004
Posts: 1049
Really? I can't see any difference in the code. :\
"Great spirits have always found violent opposition from mediocrities. The latter cannot understand it when a man does not thoughtlessly submit to hereditary prejudices but honestly and courageously uses his intelligence."
Skilled player (1652)
Joined: 11/15/2004
Posts: 2202
Location: Killjoy
Spider-Waffle wrote:
Really? I can't see any difference in the code. :\
the order of the for statement I wrote it in a hurry as start, increment, finish, but it is supposed to be start, finish, increment
Sage advice from a friend of Jim: So put your tinfoil hat back in the closet, open your eyes to the truth, and realize that the government is in fact causing austismal cancer with it's 9/11 fluoride vaccinations of your water supply.
Player (210)
Joined: 7/7/2006
Posts: 798
Location: US
The format of applying input is a bit hard to get used to. DarkKobold set it up a more adaptable way, but in one line it might look like this.
joypad.set(1,{["start"]=true})  -- For player one, button start is to be pressed during the next frame advance.
The opposite of 'true' to joypad.set is 'nil' This would be the same as not supplying a button press, but if you're passing a variable to joypad.set it should have value 'true' or 'nil'
Banned User
Joined: 5/11/2004
Posts: 1049
Ahh sweet it works, thanks a lot!
"Great spirits have always found violent opposition from mediocrities. The latter cannot understand it when a man does not thoughtlessly submit to hereditary prejudices but honestly and courageously uses his intelligence."