1 2 3 4 5 6 7 8 9
adelikat
He/Him
Emulator Coder, Site Developer, Site Owner, Expert player (3573)
Joined: 11/3/2004
Posts: 4754
Location: Tennessee
alden wrote:
I care about FCEU! And maybe you could take a look at dega?
I very much care about FCEU.
It's hard to look this good. My TAS projects
Skilled player (1444)
Joined: 7/15/2007
Posts: 1468
Location: Sweden
Lol, sure would have been nice to have that when I started working on the run >_>
Agare Bagare Kopparslagare
Joined: 3/17/2007
Posts: 97
Location: Berkeley, CA
Sorry for making noise, but I updated the Gradius III script because it sometimes got hitboxes wrong for your shots or missiles. Added the level height, too, since vertical wrap-around apparently confuses everybody. Cpadolf, your run is the reason I made the script, but it took me a while to figure out how collisions and enemy lists worked. Hope it helps.
IRC nick: UncombedCoconut
Former player
Joined: 2/19/2007
Posts: 424
Location: UK
Ok, I think I have fixed all the off-by-one-frame and desync problems in my super metroid ghost script now. I have also tried to modify it to be playable on an unmodified snes9x-lua (i.e. one without my own hacks). The files are http://folk.uio.no/sigurdkn/player.lua and http://folk.uio.no/sigurdkn/recorder.lua. As described earlier, this script superimposes hitboxes for Samus from other smvs on the screen. I think this script should be useful both for making assisted and unassited speedruns, as well as when watching and comparing them. Feedback would be appreciated.
gocha
Any
Emulator Coder, Former player
Joined: 6/21/2006
Posts: 401
Location: Japan, Nagoya
DeHackEd, I wonder why you don't release Lua 0.06 source code. Is there a special reason? (If so, it's OK. I don't mind.)
I am usually available on Discord server or Twitter.
Joined: 3/17/2007
Posts: 97
Location: Berkeley, CA
I second this request -- it could get to be a pain if I port this to FCEU and fix certain old bugs in a different way than you did. (I figure the setup will be refactored once it becomes clear how the code can be shoehorned into all the supported emulators,. That'll be easier if the code doesn't diverge first...)
IRC nick: UncombedCoconut
P.JBoy
Any
Editor
Joined: 3/25/2006
Posts: 850
Location: stuck in Pandora's box HELLPP!!!
DeHackEd doesn't have the 0.06 source code, he has already changed some of it and had never made a back-up
Joined: 12/10/2007
Posts: 260
Location: Oregon
May I ask what Lua scripting even is?
Emulator Coder, Site Developer, Former player
Joined: 11/6/2004
Posts: 833
Might want to check http://www.lua.org/ Read the documenation. Ignore all the parts about writing in C and embedding -- those are for me to worry about. Now add the snes9x API on top of what's provided. Now, what can you do with it? The idea is that the sky would be the limit. :) Someone on IRC remind me on Sunday to prepare and release 0.07.
arflech
He/Him
Joined: 5/3/2008
Posts: 1120
bump for sunday, I can hardly wait for more lua goodness
i imgur com/QiCaaH8 png
Joined: 5/20/2008
Posts: 10
hope movie.open gets added to 0.07 so i can try amaurea's ghost script :)
Former player
Joined: 2/19/2007
Posts: 424
Location: UK
Ah, so someone has tried it! As I said, I thought I had removed all occurrences of the non-standard scripting I have added to my own version, but those slipped through, I see. I could try to make one which does not depend on it (it could read how far the movie has come by the time the script is loaded, or wait for the move to load), but since the next version is supposed to be released soon, and I would be surprised if movie.open isn't there, I think I will wait.
Joined: 5/20/2008
Posts: 10
regarding input: it would be nicer to have full joypad access (if you have a joypad with 10 buttons 4 axes...) not only the snes keys because those r usually already used by the game and keyboard input would be nice too really usefull would be to have at least a "file > reload last lua script" menu option which reloads last loaded script (no matter if it had errors last time or not). better if it that call had a keyboard key configed to it. even better if the key(keyb or joyp) could be chosen by oneself (although pads 2-5 if unused in game can be misused for keyboard input)
Joined: 3/17/2007
Posts: 97
Location: Berkeley, CA
muxum wrote:
regarding input: it would be nicer to have full joypad access (if you have a joypad with 10 buttons 4 axes...) not only the snes keys because those r usually already used by the game and keyboard input would be nice too
Would a few "script control" hotkeys (and the abuse of, say, controllers #3-#5) be enough for your purposes? That'd be easier to add in a portable way. I'd really like to see CPU registers added to the memory.* functions (or at least the ability to register() PC and read the others). Heh, I'd also like nullary AND()/OR()/XOR(), even though they're useless. (Right now the bitwise math functions go out of their way to fail on zero args.)
IRC nick: UncombedCoconut
arflech
He/Him
Joined: 5/3/2008
Posts: 1120
If I understand correctly, would the nullary operators yield AND()->0 or FALSE, OR()->1 or TRUE, and XOR()->NULL (or maybe 1 or TRUE)?
i imgur com/QiCaaH8 png
Joined: 3/17/2007
Posts: 97
Location: Berkeley, CA
No. AND() is 0xFFFFFFFF (or 0x7FFFFFFF if signedness is too scary); OR() and XOR() are 0. That way rules like AND(list, v) = AND(AND(list), v) hold.
IRC nick: UncombedCoconut
arflech
He/Him
Joined: 5/3/2008
Posts: 1120
Oh you're talking about the bitwise operators. This still sounds logical, because AND is only 0 if there is at least one 0 operand, OR is only 1 if there is at least one 1 operand, and XOR is only 1 if the operands are different. So would the unary operators then be AND(n)=OR(n)=n and XOR(n)=0?
i imgur com/QiCaaH8 png
Joined: 3/17/2007
Posts: 97
Location: Berkeley, CA
Close. XOR(n) is also n -- the result of XORing a bunch of bits (1-bit #'s) is 1 if there are an odd number of 1's. (Sorry for derailing the topic :-P)
IRC nick: UncombedCoconut
Post subject: how to extend snes9x_lua with existing libraries
Joined: 5/20/2008
Posts: 10
how to extend snes9x lua without changing snes9x: find a library u want to use for example: http://nmap.org/book/nse-library.html checkout the Bitwise Logical Operations part dowload the library (http://nmap.org/dist/nmap-4.62-win32.zip inside ...bin folder u find the dll) move the libraryname.dll to your snes9x (which uses lua) folder to use it write require "libraryname" before u actually use parts of it in this example:
require "bit"

while true do
	gui.text(0,0,bit.band(2,6))
	snes9x.frameadvance()
end
Joined: 5/20/2008
Posts: 10
nitsujrehtona wrote:
Would a few "script control" hotkeys (and the abuse of, say, controllers #3-#5) be enough for your purposes?
pads 1-5 can already be accessed but only the snes keys like A B X Y... what i ment r keys not maped to a snes key that one could use. keys not addressed as ABXY.. but sometihing like the button with number and the axis with number and direction: Buttons -> B0,B1,B2... value: nil or true Axes -> A0X, A0Y value: nil or (+/-)number or Axes -> A0XP, A0XN (P=positive N=negative) value: nil or true (this would suffice too. dunno to what extent a +/- number is supported by snes and thus snes emus)
Joined: 3/17/2007
Posts: 97
Location: Berkeley, CA
Yeah, require() is magically easy! I'm working on a demo of using it and coroutines to run several scripts at once (but for FCEU). And I know what you _asked_ for regarding input... the less powerful alternatives I suggested would require less invasive changes to the emulator, which is kind of important for an out-of-tree patch to an actively developed program maintained by one person with finite time... (This is also why I'd be satisfied if something like memory.register("X", func) was never supported...)
IRC nick: UncombedCoconut
Joined: 5/20/2008
Posts: 10
you can run several scripts easy by adding
dofile("file.lua")
to your main lua file (the one u load in snes9x_lua) before u use stuff from that file or if u just want that script to be executed. but u should have only one (main) while loop in all those files together.
Joined: 5/20/2008
Posts: 10
here something to easy configure key combination on which a function is called. supports down, pressed and released behaviours joyp.lua :

--[[
joyp api by Xyrio/muxum

allows easy configuration of key combinations on which a function is called

version 0.1
lua 5.1+
]]

KEYSTATE = { UP=nil, DOWN=1, PRESSED=2, RELEASED=3 } --UP is so u know that all key reulting to nil r interpreted as having to be UP
--used to check all available keys
KEYLIST = { L=0, R=1, A=2, B=3, X=4, Y=5, start=6, select=7, up=8, down=9, left=10, right=11 }

--- joypad states with up=nil and notup = not nil joypad states (total 5 joypads)
keysold = { [1]={}, [2]={}, [3]={}, [4]={}, [5]={} }
keysnew = { [1]={}, [2]={}, [3]={}, [4]={}, [5]={} }

--- key combination list and their action
--- list item is a table like: { padnr=1, action=function() end, keys={ L=KEYSTATE.DOWN, R=KEYSTATE.PRESSED } } -- hold L and press R to trigger
--- note: index of keycombs can be anything
keycombs = {}

joyp = {}

--- key is down in current frame
--- returns nil on false else true
joyp.isDown = function(keymap,padnr,key)
	if padnr ~= nil and keymap[padnr][key] ~= nil then 
		return true
	end
end
--- key is down in current frame
--- returns nil on false else true
joyp.isUp = function(keymap,padnr,key)
	if padnr ~= nil and keymap[padnr][key] == nil then 
		return true
	end
end
--- key down this frame and was up last frame
--- returns nil on false else true
joyp.isPressed = function(for_interface_but_unused,padnr,key)
	if joyp.isDown(keysnew,padnr,key) and joyp.isUp(keysold,padnr,key) then
		return true
	end
end
--- key up this frame and was down last frame
--- returns nil on false else true
joyp.isReleased = function(for_interface_but_unused,padnr,key)
	if joyp.isUp(keysnew,padnr,key) and joyp.isDown(keysold,padnr,key) then
		return true
	end
end

joyp.getAllPadsKeys = function()
	local keys = {}
	keys[1] = joypad.read(1)
	keys[2] = joypad.read(2)
	keys[3] = joypad.read(3)
	keys[4] = joypad.read(4)
	keys[5] = joypad.read(5)
	return keys
end
--- to be called in mainloop
joyp.handleInput = function()
	local switch_keystate = { [KEYSTATE.DOWN]=joyp.isDown, [KEYSTATE.PRESSED]=joyp.isPressed, [KEYSTATE.RELEASED]=joyp.isReleased }
	keysnew = joyp.getAllPadsKeys()
	for i,kcomb in pairs(keycombs) do --for all key combinations
		local alltrue = true
		for key in pairs(KEYLIST) do -- for all possible keys
			if kcomb.keys[key] ~= nil then
				if switch_keystate[kcomb.keys[key]](keysnew,kcomb.padnr,key) == nil then
					alltrue = false
				end
			else
				if joyp.isUp(keysnew,kcomb.padnr,key) == nil then
					alltrue = false
				end
			end
		end
		if alltrue == true and kcomb.action ~= nil then
			kcomb.action()
		end
	end
	keysold = keysnew
end
and here an example of how you could use it: show mana - hold start and press select next weapon of same type (needs reequip to apply weapon stats) - hold start and press up prev weapon of same type (needs reequip to apply weapon stats) - hold start and press down weapon has polymorph status (changed enemy type on hit) - hold start and press L infinite stamina/ at least 100% weapon attacks - hold start and press R (script for that behaviour is in the download) one line from a file inside the download as an example how u config key combinations:
...
keycombs["showmana"] = { padnr=1, action=function() ui.flags.mana = toggle(ui.flags.mana) end, keys={ start=KEYSTATE.DOWN, select=KEYSTATE.PRESSED } } -- show mana values on screen
...
here everything for download: http://www.mediafire.com/?bbkwjy3xjy5
Post subject: energy bar lua
Joined: 5/20/2008
Posts: 10
secret of mana - bars selects treasures with a + and shows a bar for all players and enemies. the count of layers on the bar (1-8) can be changed by holding start and pressing left/right http://mitglied.lycos.de/muxum/secret%20of%20mana%20-%20bars.lua http://www.mediafire.com/?2lxvyaclyna
arflech
He/Him
Joined: 5/3/2008
Posts: 1120
:-X
i imgur com/QiCaaH8 png
1 2 3 4 5 6 7 8 9