All pastes #636801 Raw Edit

Anonymous

public text v1 · immutable
#636801 ·published 2007-07-28 06:57 UTC
rendered paste body
--                       TAMS
--Toribash Automated Move System
--     coded by NewbLuck and Veb

--Define globals
flag = { }        --Define and set flag states and globals
timer = { }
flag['lp'] = 0
flag['rp'] = 0
flag['lk'] = 0
flag['rk'] = 0
timer['lp'] = 0
timer['rp'] = 0
timer['lk'] = 0
timer['rk'] = 0


move_lp = { }     --Define and set moves (simple for now, will do frame by frame later)
for foo = 0 , 20 do move_lp[foo] = "31321312311133333333" end
for foo = 21 , 26 do move_lp[foo] = "12312311312333333333" end
move_lp['frames'] = 26


local function on_frame()     --Process moves
	
	if flag.lp == 1 then    --Start our Left Punch state block
		local fooz = 0
		local joint_foo = 0
		freeze_game()
		for fooz = 0, 19 do 
			joint_foo = string.sub(move_lp[timer.lp],fooz + 1,fooz + 1)
		    joint_num = tonumber(joint_foo)
			set_joint_state(0, fooz, joint_num) 
		end
		timer.lp = timer.lp + 1
		
		if timer.lp == (move_lp.frames + 1) then
			timer.lp = 0
			flag.lp = 0
		end
	    unfreeze_game()
	end
		
end

local function key_pressed(key)
    echo("keydown")

	if (key == string.byte('k') and flag.lp == 0) then
		flag.lp = 1
		timer.lp = 0
	    echo("Pressed " .. string.byte('k') )
	end
end

local function start()
flag['lp'],timer['lp'] = 0
flag['rp'],timer['rp'] = 0
flag['lk'],timer['lk'] = 0
flag['rk'],timer['rk'] = 0
echo(move_lp.frames)
end



add_hook("new_game","TAMS", start)
add_hook("key_down","TAMS", key_pressed)
add_hook("enter_frame", "TAMS", on_frame)