Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Robot to play Timberman on the Color Computer 3
emu.pause()
j = manager:machine():ioport().ports[":joystick_rx"].fields["AD Stick X"]
b = manager:machine():ioport().ports[":joystick_buttons"].fields["Right Button 1"]
s = manager:machine().screens[":composite"]
a = 0
c = 0
function draw_hud()
if s:pixel(200,32) == 38424 then
if s:pixel(442,111) == 3087104 then
j:set_value(-100000)
else
j:set_value(100000)
end
a = a + 1
if a > 2 then
c = 1
else
c = 0
end
if a == 5 then
a = 0
end
b:set_value(c)
end
end
emu.register_frame(draw_hud, "frame")
emu.unpause()
@drencorxeen
Copy link

drencorxeen commented Jun 1, 2020

emu.pause()

j = manager:machine():ioport().ports[":joystick_rx"].fields["AD Stick X"]
b = manager:machine():ioport().ports[":joystick_buttons"].fields["Right Button 1"]
s = manager:machine().screens[":composite"]
a = 0
c = 0
d = 3

function do_my_joystick()
	if c == 0 then
		c = 1
	else
		c = 0
	end
	b:set_value(c)
end

function change_my_d()
	if d == 3 then
		d = 4
	else
		d = 3
	end
end

function draw_hud()
  if s:pixel(200,32) == 38424 then
	  if s:pixel(442,111) == 3087104 then
		j:set_value(-100000)
	  else
		j:set_value(100000)
	  end

	  a = a + 1
	  if a > d then
		do_my_joystick()
		a = 0
		change_my_d()
	  end
  end
end

emu.register_frame(draw_hud, "frame")

emu.unpause()

Well,
Here is my version of your code that will go on as long as you want it. :) or at least it worked on mine for an hour lol.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment