local cond_jnc_result= GAMESTATE:IsPlayerEnabled(PLAYER_1)

local cond_knc_result= GAMESTATE:IsPlayerEnabled(PLAYER_2)

local cond_lnc_result= not GAMESTATE:IsPlayerEnabled(PLAYER_1)

local cond_mnc_result= not GAMESTATE:IsPlayerEnabled(PLAYER_2)

local function optional_actor(cond, actor)
	if cond then return actor end
	return Def.Actor{}
end

return Def.ActorFrame{
  Name= "actor_nnc",
  Def.ActorFrame{
    Name= "actor_onc",
    Def.Quad{
      Name= "actor_pnc",
      InitCommand= function(self)
		
			--this is where variables go when the simfile starts up
			--function declarations, and things that will never change even
			--if this particular minigame is restarted after being played once before
		
			--for storing if a button is held down
			mawaru_code_held = {0,0,0,0,0,0,0,0};
			
			function mawaru_code_right(pn)
				local n = _G['mawaru_code_codestringp'..pn]
				MESSAGEMAN:Broadcast('SFAttack'..n..'P'..pn);
				if n == 1 then
					Sound('swing1');
				elseif n == 2 then
					Sound('swing2');
				elseif n == 3 then
					Sound('skill2');
					Sound('hadoken');
				end
			end
			
			mawaru_code_dirs = {'l','d','u','r'};
			mawaru_code_codedirvalues = {
				l=90,
				d=0,
				u=180,
				r=-90
			};
			mawaru_code_codes = {}
			for i=1,50 do
				mawaru_code_g = {}
				--[[
				if table.getn(mawaru_code_codes)<3 then
					mawaru_code_numletters = 3
				else
					mawaru_code_numletters = 4
				end
				]]
				mawaru_code_numletters = 3
				for j=1,mawaru_code_numletters do
					if j==1 then
						mawaru_code_gadd = math.random(1,4)
					else
						while mawaru_code_dirs[mawaru_code_gadd] == mawaru_code_g[table.getn(mawaru_code_g)] do
							mawaru_code_gadd = math.random(1,4)
						end
					end
					mawaru_code_g[table.getn(mawaru_code_g)+1] = mawaru_code_dirs[mawaru_code_gadd]
				end
				mawaru_code_codes[table.getn(mawaru_code_codes)+1] = mawaru_code_g;
			end
			
			mawaru_code_codedp1 = 0;
			mawaru_code_codedp2 = 0;
			mawaru_code_codestringp1 = 1;
			mawaru_code_codestringp2 = 1;
			
			mawaru_code_waitp1 = 0
			mawaru_code_waitp2 = 0
			
			mawaru_code_p1iwaitd = 0;
			mawaru_code_p1iwaitl = 0;
			mawaru_code_p1iwaitr = 0;
			mawaru_code_p1iwaitu = 0;
			mawaru_code_p2iwaitd = 0;
			mawaru_code_p2iwaitl = 0;
			mawaru_code_p2iwaitr = 0;
			mawaru_code_p2iwaitu = 0;
			
		end,
      KillCommand= function(self)
			--any cleanup, if necessary
		end,
      StartCommand= function(self)
		
			
			
			--variables set up when a game is started
			--wait 2 seconds (for the curtain or whatever) before accepting any inputs
			mawaru_code_lockinput = {.3,.3};
			
			self:sleep(0.02);
			self:queuecommand('Update');

		end,
      UpdateCommand= function(self)
			
			--game logic
			
			if mawaru_code_waitp1 >= 0 then mawaru_code_waitp1 = mawaru_code_waitp1-0.02 end
			if mawaru_code_waitp2 >= 0 then mawaru_code_waitp2 = mawaru_code_waitp2-0.02 end
			
			if mawaru_code_p1iwaitl >= 0 then mawaru_code_p1iwaitl = mawaru_code_p1iwaitl-0.02; end
			if mawaru_code_p1iwaitd >= 0 then mawaru_code_p1iwaitd = mawaru_code_p1iwaitd-0.02; end
			if mawaru_code_p1iwaitu >= 0 then mawaru_code_p1iwaitu = mawaru_code_p1iwaitu-0.02; end
			if mawaru_code_p1iwaitr >= 0 then mawaru_code_p1iwaitr = mawaru_code_p1iwaitr-0.02; end
			if mawaru_code_p2iwaitl >= 0 then mawaru_code_p2iwaitl = mawaru_code_p2iwaitl-0.02; end
			if mawaru_code_p2iwaitd >= 0 then mawaru_code_p2iwaitd = mawaru_code_p2iwaitd-0.02; end
			if mawaru_code_p2iwaitu >= 0 then mawaru_code_p2iwaitu = mawaru_code_p2iwaitu-0.02; end
			if mawaru_code_p2iwaitr >= 0 then mawaru_code_p2iwaitr = mawaru_code_p2iwaitr-0.02; end
			
			if mawaru_curgame == 16 then
				--SCREENMAN:SystemMessage(tableString(mawaru_code_codes[mawaru_code_codedp1+1]))
				mawaru_code_codeforp1:x(172-(20*table.getn(mawaru_code_codes[mawaru_code_codedp1+1])));
				mawaru_code_codeforp2:x(492-(20*table.getn(mawaru_code_codes[mawaru_code_codedp2+1])));
				mawaru_code_codeforp1:y(160);
				mawaru_code_codeforp2:y(160);
				
				if mawaru_code_codestringp1 > table.getn(mawaru_code_codes[mawaru_code_codedp1+1]) then
					--SOUND:PlayOnce(songName..'lua/right.ogg');
					mawaru_code_codedp1 = mawaru_code_codedp1+1;
					MESSAGEMAN:Broadcast('UpdateScorep1')
					mawaru_code_codestringp1 = 1;
					mawaru_code_waitp1 = 0.2;
					MESSAGEMAN:Broadcast('NextShitBp1');
				end
				if mawaru_code_codestringp2 > table.getn(mawaru_code_codes[mawaru_code_codedp2+1]) then
					--SOUND:PlayOnce(songName..'lua/right.ogg');
					MESSAGEMAN:Broadcast('UpdateScorep2')
					mawaru_code_codedp2 = mawaru_code_codedp2+1;
					mawaru_code_codestringp2 = 1;
					mawaru_code_waitp2 = 0.2;
					MESSAGEMAN:Broadcast('NextShitBp2');
				end
				
				if mawaru_code_waitp1 <= 0 then
					for i=0,5 do
						if i+1<table.getn(mawaru_code_codes[mawaru_code_codedp1+1])+1 then
							_G['arrowp1g'..i]:diffusealpha(1);
							_G['arrowp1g'..i]:rotationz(mawaru_code_codedirvalues[mawaru_code_codes[mawaru_code_codedp1+1][i+1]]);
							if mawaru_code_codestringp1 >= i+2 then
								_G['arrowp1l'..i]:diffusealpha(1);
							else
								_G['arrowp1l'..i]:diffusealpha(0);
							end
							_G['arrowp1l'..i]:rotationz(mawaru_code_codedirvalues[mawaru_code_codes[mawaru_code_codedp1+1][i+1]]);
						else
							_G['arrowp1g'..i]:diffusealpha(0);
							_G['arrowp1l'..i]:diffusealpha(0);
						end
					end
				else
					for i=0,5 do
						_G['arrowp1g'..i]:diffusealpha(0);
						_G['arrowp1l'..i]:diffusealpha(0);
					end
				end
				if mawaru_code_waitp2 <= 0 then
					for i=0,5 do
						if i+1<table.getn(mawaru_code_codes[mawaru_code_codedp2+1])+1 then
							_G['arrowp2g'..i]:diffusealpha(1);
							_G['arrowp2g'..i]:rotationz(mawaru_code_codedirvalues[mawaru_code_codes[mawaru_code_codedp2+1][i+1]]);
							if mawaru_code_codestringp2 >= i+2 then
								_G['arrowp2l'..i]:diffusealpha(1);
							else
								_G['arrowp2l'..i]:diffusealpha(0);
							end
							_G['arrowp2l'..i]:rotationz(mawaru_code_codedirvalues[mawaru_code_codes[mawaru_code_codedp2+1][i+1]]);
						else
							_G['arrowp2g'..i]:diffusealpha(0);
							_G['arrowp2l'..i]:diffusealpha(0);
						end
					end
				else
					for i=0,5 do
						_G['arrowp2g'..i]:diffusealpha(0);
						_G['arrowp2l'..i]:diffusealpha(0);
					end
				end
				
			else
				mawaru_code_codestringp1 = 1
				mawaru_code_codestringp2 = 1
			end
			
			for pn=1,2 do
				
				if mawaru_code_lockinput[pn]>0 then
					mawaru_code_lockinput[pn] = mawaru_code_lockinput[pn]-0.02
				end
			
				local bpn = pn-1;
				
			end
			
			self:sleep(0.02);
			if mawaru_curgame == 16 and mawaru_gamestate == 1 then
				self:queuecommand('Update');
			end
			
		end,
    },
    Def.Quad{
      Name= "actor_qnc",
      InitCommand= function(self) mawaru_code_controller = self end,
    },
    --For all parts, Unconverted x & y pos. -Kid
    Def.Sprite{
      Name= "actor_rnc",
      OnCommand= cmd(x,160;y,240),
      Texture= "bg.png",
    },
    Def.Sprite{
      Name= "actor_snc",
      OnCommand= cmd(x,480;y,240),
      Texture= "bg.png",
    },
    Def.Sprite{
      Name= "actor_tnc",
      Frames= {
        {Frame= 0, Delay= 0.2},
        {Frame= 1, Delay= 0.2},
        {Frame= 2, Delay= 0.2},
        {Frame= 3, Delay= 0.2},
        {Frame= 4, Delay= 0.2},
    },
      OnCommand= cmd(x,85;y,490;skewx,.3;rotationz,10;croptop,0.5;fadetop,0.2;effectclock,"bgm";diffuse,color('0,0,0,.6');zoomy,-.6),
      SFAttack1P1MessageCommand= cmd(finishtweening;diffusealpha,0;sleep,0.25;diffusealpha,.6),
      SFAttack2P1MessageCommand= cmd(finishtweening;diffusealpha,0;sleep,0.25;diffusealpha,.6),
      SFAttack3P1MessageCommand= cmd(finishtweening;diffusealpha,0;sleep,0.25;diffusealpha,.6),
      SFErrorP1MessageCommand= cmd(finishtweening;diffusealpha,0;sleep,0.25;diffusealpha,.6),
      Texture= "./chan_idle 3x2",
    },
    Def.Sprite{
      Name= "actor_unc",
      Frames= {
        {Frame= 0, Delay= 0.1},
        {Frame= 1, Delay= 0.03},
        {Frame= 2, Delay= 0.03},
        {Frame= 3, Delay= 0.03},
        {Frame= 4, Delay= 0.03},
        {Frame= 5, Delay= 0.5},
        {Frame= 6, Delay= 0.1},
        {Frame= 7, Delay= 0.03},
        {Frame= 8, Delay= 0.03},
        {Frame= 9, Delay= 0.03},
        {Frame= 10, Delay= 0.03},
        {Frame= 11, Delay= 0.5},
        {Frame= 12, Delay= 0.1},
        {Frame= 13, Delay= 0.03},
        {Frame= 14, Delay= 0.03},
        {Frame= 15, Delay= 0.03},
        {Frame= 16, Delay= 0.03},
        {Frame= 17, Delay= 0.5},
        {Frame= 18, Delay= 0.1},
        {Frame= 19, Delay= 0.03},
        {Frame= 20, Delay= 0.03},
        {Frame= 21, Delay= 0.03},
        {Frame= 22, Delay= 0.03},
        {Frame= 23, Delay= 0.5},
    },
      OnCommand= cmd(x,85;y,490;skewx,.3;rotationz,10;croptop,0.5;fadetop,0.2;diffusealpha,0;diffuse,color('0,0,0,0');zoomy,-.6),
      SFAttack1P1MessageCommand= cmd(finishtweening;setstate,0;diffusealpha,.6;sleep,0.25;diffusealpha,0),
      SFAttack2P1MessageCommand= cmd(finishtweening;setstate,6;diffusealpha,.6;sleep,0.25;diffusealpha,0),
      SFAttack3P1MessageCommand= cmd(finishtweening;setstate,12;diffusealpha,.6;sleep,0.25;diffusealpha,0),
      SFErrorP1MessageCommand= cmd(finishtweening;setstate,18;diffusealpha,.6;sleep,0.25;diffusealpha,0),
      Texture= "./chan_moves 6x4",
    },
    Def.Sprite{
      Name= "actor_vnc",
      Frames= {
        {Frame= 0, Delay= 0.2},
        {Frame= 1, Delay= 0.2},
        {Frame= 2, Delay= 0.2},
        {Frame= 3, Delay= 0.2},
        {Frame= 4, Delay= 0.2},
    },
      OnCommand= cmd(x,100;y,300;effectclock,"bgm"),
      SFAttack1P1MessageCommand= cmd(finishtweening;diffusealpha,0;sleep,0.25;diffusealpha,1),
      SFAttack2P1MessageCommand= cmd(finishtweening;diffusealpha,0;sleep,0.25;diffusealpha,1),
      SFAttack3P1MessageCommand= cmd(finishtweening;diffusealpha,0;sleep,0.25;diffusealpha,1),
      SFErrorP1MessageCommand= cmd(finishtweening;diffusealpha,0;sleep,0.25;diffusealpha,1),
      Texture= "./chan_idle 3x2",
    },
    Def.Sprite{
      Name= "actor_wnc",
      Frames= {
        {Frame= 0, Delay= 0.1},
        {Frame= 1, Delay= 0.03},
        {Frame= 2, Delay= 0.03},
        {Frame= 3, Delay= 0.03},
        {Frame= 4, Delay= 0.03},
        {Frame= 5, Delay= 0.5},
        {Frame= 6, Delay= 0.1},
        {Frame= 7, Delay= 0.03},
        {Frame= 8, Delay= 0.03},
        {Frame= 9, Delay= 0.03},
        {Frame= 10, Delay= 0.03},
        {Frame= 11, Delay= 0.5},
        {Frame= 12, Delay= 0.1},
        {Frame= 13, Delay= 0.03},
        {Frame= 14, Delay= 0.03},
        {Frame= 15, Delay= 0.03},
        {Frame= 16, Delay= 0.03},
        {Frame= 17, Delay= 0.5},
        {Frame= 18, Delay= 0.1},
        {Frame= 19, Delay= 0.03},
        {Frame= 20, Delay= 0.03},
        {Frame= 21, Delay= 0.03},
        {Frame= 22, Delay= 0.03},
        {Frame= 23, Delay= 0.5},
    },
      OnCommand= cmd(x,100;y,300;diffusealpha,0),
      SFAttack1P1MessageCommand= cmd(finishtweening;setstate,0;diffusealpha,1;sleep,0.25;diffusealpha,0),
      SFAttack2P1MessageCommand= cmd(finishtweening;setstate,6;diffusealpha,1;sleep,0.25;diffusealpha,0),
      SFAttack3P1MessageCommand= cmd(finishtweening;setstate,12;diffusealpha,1;sleep,0.25;diffusealpha,0),
      SFErrorP1MessageCommand= cmd(finishtweening;setstate,18;diffusealpha,1;sleep,0.25;diffusealpha,0),
      Texture= "./chan_moves 6x4",
    },
    Def.Sprite{
      Name= "actor_xnc",
      OnCommand= cmd(x,160+30;y,300-16;diffusealpha,0),
      SFAttack3P1MessageCommand= cmd(finishtweening;diffusealpha,1;x,160+30;linear,0.3;addx,100;diffusealpha,0),
      Texture= "fball.png",
    },
    Def.Sprite{
      Name= "actor_ync",
      Frames= {
        {Frame= 0, Delay= 0.2},
        {Frame= 1, Delay= 0.2},
        {Frame= 2, Delay= 0.2},
        {Frame= 3, Delay= 0.2},
        {Frame= 4, Delay= 0.2},
    },
      OnCommand= cmd(x,405;y,490;skewx,.3;rotationz,10;croptop,0.5;fadetop,0.2;effectclock,"bgm";diffuse,color('0,0,0,.6');zoomy,-.6),
      SFAttack1P2MessageCommand= cmd(finishtweening;diffusealpha,0;sleep,0.25;diffusealpha,.6),
      SFAttack2P2MessageCommand= cmd(finishtweening;diffusealpha,0;sleep,0.25;diffusealpha,.6),
      SFAttack3P2MessageCommand= cmd(finishtweening;diffusealpha,0;sleep,0.25;diffusealpha,.6),
      SFErrorP2MessageCommand= cmd(finishtweening;diffusealpha,0;sleep,0.25;diffusealpha,.6),
      Texture= "./chan_idle 3x2",
    },
    Def.Sprite{
      Name= "actor_znc",
      Frames= {
        {Frame= 0, Delay= 0.1},
        {Frame= 1, Delay= 0.03},
        {Frame= 2, Delay= 0.03},
        {Frame= 3, Delay= 0.03},
        {Frame= 4, Delay= 0.03},
        {Frame= 5, Delay= 0.5},
        {Frame= 6, Delay= 0.1},
        {Frame= 7, Delay= 0.03},
        {Frame= 8, Delay= 0.03},
        {Frame= 9, Delay= 0.03},
        {Frame= 10, Delay= 0.03},
        {Frame= 11, Delay= 0.5},
        {Frame= 12, Delay= 0.1},
        {Frame= 13, Delay= 0.03},
        {Frame= 14, Delay= 0.03},
        {Frame= 15, Delay= 0.03},
        {Frame= 16, Delay= 0.03},
        {Frame= 17, Delay= 0.5},
        {Frame= 18, Delay= 0.1},
        {Frame= 19, Delay= 0.03},
        {Frame= 20, Delay= 0.03},
        {Frame= 21, Delay= 0.03},
        {Frame= 22, Delay= 0.03},
        {Frame= 23, Delay= 0.5},
    },
      OnCommand= cmd(x,405;y,490;skewx,.3;rotationz,10;croptop,0.5;fadetop,0.2;diffuse,color('0,0,0,0');zoomy,-.6),
      SFAttack1P2MessageCommand= cmd(finishtweening;setstate,0;diffusealpha,.6;sleep,0.25;diffusealpha,0),
      SFAttack2P2MessageCommand= cmd(finishtweening;setstate,6;diffusealpha,.6;sleep,0.25;diffusealpha,0),
      SFAttack3P2MessageCommand= cmd(finishtweening;setstate,12;diffusealpha,.6;sleep,0.25;diffusealpha,0),
      SFErrorP2MessageCommand= cmd(finishtweening;setstate,18;diffusealpha,.6;sleep,0.25;diffusealpha,0),
      Texture= "./chan_moves 6x4",
    },
    Def.Sprite{
      Name= "actor_Anc",
      Frames= {
        {Frame= 0, Delay= 0.2},
        {Frame= 1, Delay= 0.2},
        {Frame= 2, Delay= 0.2},
        {Frame= 3, Delay= 0.2},
        {Frame= 4, Delay= 0.2},
    },
      OnCommand= cmd(x,420;y,300;effectclock,"bgm"),
      SFAttack1P2MessageCommand= cmd(finishtweening;diffusealpha,0;sleep,0.25;diffusealpha,1),
      SFAttack2P2MessageCommand= cmd(finishtweening;diffusealpha,0;sleep,0.25;diffusealpha,1),
      SFAttack3P2MessageCommand= cmd(finishtweening;diffusealpha,0;sleep,0.25;diffusealpha,1),
      SFErrorP2MessageCommand= cmd(finishtweening;diffusealpha,0;sleep,0.25;diffusealpha,1),
      Texture= "./chan_idle 3x2",
    },
    Def.Sprite{
      Name= "actor_Bnc",
      Frames= {
        {Frame= 0, Delay= 0.1},
        {Frame= 1, Delay= 0.03},
        {Frame= 2, Delay= 0.03},
        {Frame= 3, Delay= 0.03},
        {Frame= 4, Delay= 0.03},
        {Frame= 5, Delay= 0.5},
        {Frame= 6, Delay= 0.1},
        {Frame= 7, Delay= 0.03},
        {Frame= 8, Delay= 0.03},
        {Frame= 9, Delay= 0.03},
        {Frame= 10, Delay= 0.03},
        {Frame= 11, Delay= 0.5},
        {Frame= 12, Delay= 0.1},
        {Frame= 13, Delay= 0.03},
        {Frame= 14, Delay= 0.03},
        {Frame= 15, Delay= 0.03},
        {Frame= 16, Delay= 0.03},
        {Frame= 17, Delay= 0.5},
        {Frame= 18, Delay= 0.1},
        {Frame= 19, Delay= 0.03},
        {Frame= 20, Delay= 0.03},
        {Frame= 21, Delay= 0.03},
        {Frame= 22, Delay= 0.03},
        {Frame= 23, Delay= 0.5},
    },
      OnCommand= cmd(x,420;y,300;diffusealpha,0),
      SFAttack1P2MessageCommand= cmd(finishtweening;setstate,0;diffusealpha,1;sleep,0.25;diffusealpha,0),
      SFAttack2P2MessageCommand= cmd(finishtweening;setstate,6;diffusealpha,1;sleep,0.25;diffusealpha,0),
      SFAttack3P2MessageCommand= cmd(finishtweening;setstate,12;diffusealpha,1;sleep,0.25;diffusealpha,0),
      SFErrorP2MessageCommand= cmd(finishtweening;setstate,18;diffusealpha,1;sleep,0.25;diffusealpha,0),
      Texture= "./chan_moves 6x4",
    },
    Def.Sprite{
      Name= "actor_Cnc",
      OnCommand= cmd(x,480+30;y,300-16;diffusealpha,0),
      SFAttack3P2MessageCommand= cmd(finishtweening;diffusealpha,1;x,480+30;linear,0.3;addx,100;diffusealpha,0),
      Texture= "fball.png",
    },
    optional_actor(cond_jnc_result,
    Def.BitmapText{
      Name= "actor_Dnc",
      Font= "_eurostile outline",
      OnCommand= cmd(x,30;y,30;horizalign,left),
      Text= "0 points",
      UpdateScorep1MessageCommand= function (self) self:settext(mawaru_code_codedp1..' points'); end,
    }),
    optional_actor(cond_knc_result,
    Def.BitmapText{
      Name= "actor_Enc",
      Font= "_eurostile outline",
      OnCommand= cmd(x,610;y,30;horizalign,right),
      Text= "0 points",
      UpdateScorep2MessageCommand= function (self) self:settext(mawaru_code_codedp2..' points'); end,
    }),
    Def.ActorFrame{
      Name= "actor_Fnc",
      InitCommand= function (self) mawaru_code_codeforp1 = self; self:y(60); end,
      Def.Sprite{
        Name= "actor_aoc",
        InitCommand= function(self) arrowp1g0 = self end,--Removed semicolon because SM5. -Kid
        OnCommand= cmd(x,0;zoom,0.6),
        Texture= "arrowgray.png",
      },
      Def.Sprite{
        Name= "actor_boc",
        InitCommand= function(self) arrowp1g1 = self end,--Removed semicolon because SM5. -Kid
        OnCommand= cmd(x,40*1;zoom,0.6),
        Texture= "arrowgray.png",
      },
      Def.Sprite{
        Name= "actor_coc",
        InitCommand= function(self) arrowp1g2 = self end,--Removed semicolon because SM5. -Kid
        OnCommand= cmd(x,40*2;zoom,0.6),
        Texture= "arrowgray.png",
      },
      Def.Sprite{
        Name= "actor_doc",
        InitCommand= function(self) arrowp1g3 = self end,--Removed semicolon because SM5. -Kid
        OnCommand= cmd(x,40*3;zoom,0.6),
        Texture= "arrowgray.png",
      },
      Def.Sprite{
        Name= "actor_eoc",
        InitCommand= function(self) arrowp1g4 = self end,--Removed semicolon because SM5. -Kid
        OnCommand= cmd(x,40*4;zoom,0.6),
        Texture= "arrowgray.png",
      },
      Def.Sprite{
        Name= "actor_foc",
        InitCommand= function(self) arrowp1g5 = self end,--Removed semicolon because SM5. -Kid
        OnCommand= cmd(x,40*5;zoom,0.6),
        Texture= "arrowgray.png",
      },
      Def.Sprite{
        Name= "actor_goc",
        InitCommand= function(self) arrowp1l0 = self end,--Removed semicolon because SM5. -Kid
        OnCommand= cmd(x,0;zoom,0.6),
        Texture= "arrowlit.png",
      },
      Def.Sprite{
        Name= "actor_hoc",
        InitCommand= function(self) arrowp1l1 = self end,--Removed semicolon because SM5. -Kid
        OnCommand= cmd(x,40*1;zoom,0.6),
        Texture= "arrowlit.png",
      },
      Def.Sprite{
        Name= "actor_ioc",
        InitCommand= function(self) arrowp1l2 = self end,--Removed semicolon because SM5. -Kid
        OnCommand= cmd(x,40*2;zoom,0.6),
        Texture= "arrowlit.png",
      },
      Def.Sprite{
        Name= "actor_joc",
        InitCommand= function(self) arrowp1l3 = self end,--Removed semicolon because SM5. -Kid
        OnCommand= cmd(x,40*3;zoom,0.6),
        Texture= "arrowlit.png",
      },
      Def.Sprite{
        Name= "actor_koc",
        InitCommand= function(self) arrowp1l4 = self end,--Removed semicolon because SM5. -Kid
        OnCommand= cmd(x,40*4;zoom,0.6),
        Texture= "arrowlit.png",
      },
      Def.Sprite{
        Name= "actor_loc",
        InitCommand= function(self) arrowp1l5 = self end,--Removed semicolon because SM5. -Kid
        OnCommand= cmd(x,40*5;zoom,0.6),
        Texture= "arrowlit.png",
      },
    },
    Def.ActorFrame{
      Name= "actor_moc",
      InitCommand= function (self) mawaru_code_codeforp2 = self; self:y(60); end,
      Def.Sprite{
        Name= "actor_noc",
        InitCommand= function(self) arrowp2g0 = self end,--Removed semicolon because SM5. -Kid
        OnCommand= cmd(x,0;zoom,0.6),
        Texture= "arrowgray.png",
      },
      Def.Sprite{
        Name= "actor_ooc",
        InitCommand= function(self) arrowp2g1 = self end,--Removed semicolon because SM5. -Kid
        OnCommand= cmd(x,40*1;zoom,0.6),
        Texture= "arrowgray.png",
      },
      Def.Sprite{
        Name= "actor_poc",
        InitCommand= function(self) arrowp2g2 = self end,--Removed semicolon because SM5. -Kid
        OnCommand= cmd(x,40*2;zoom,0.6),
        Texture= "arrowgray.png",
      },
      Def.Sprite{
        Name= "actor_qoc",
        InitCommand= function(self) arrowp2g3 = self end,--Removed semicolon because SM5. -Kid
        OnCommand= cmd(x,40*3;zoom,0.6),
        Texture= "arrowgray.png",
      },
      Def.Sprite{
        Name= "actor_roc",
        InitCommand= function(self) arrowp2g4 = self end,--Removed semicolon because SM5. -Kid
        OnCommand= cmd(x,40*4;zoom,0.6),
        Texture= "arrowgray.png",
      },
      Def.Sprite{
        Name= "actor_soc",
        InitCommand= function(self) arrowp2g5 = self end,--Removed semicolon because SM5. -Kid
        OnCommand= cmd(x,40*5;zoom,0.6),
        Texture= "arrowgray.png",
      },
      Def.Sprite{
        Name= "actor_toc",
        InitCommand= function(self) arrowp2l0 = self end,--Removed semicolon because SM5. -Kid
        OnCommand= cmd(x,0;zoom,0.6),
        Texture= "arrowlit.png",
      },
      Def.Sprite{
        Name= "actor_uoc",
        InitCommand= function(self) arrowp2l1 = self end,--Removed semicolon because SM5. -Kid
        OnCommand= cmd(x,40*1;zoom,0.6),
        Texture= "arrowlit.png",
      },
      Def.Sprite{
        Name= "actor_voc",
        InitCommand= function(self) arrowp2l2 = self end,--Removed semicolon because SM5. -Kid
        OnCommand= cmd(x,40*2;zoom,0.6),
        Texture= "arrowlit.png",
      },
      Def.Sprite{
        Name= "actor_woc",
        InitCommand= function(self) arrowp2l3 = self end,--Removed semicolon because SM5. -Kid
        OnCommand= cmd(x,40*3;zoom,0.6),
        Texture= "arrowlit.png",
      },
      Def.Sprite{
        Name= "actor_xoc",
        InitCommand= function(self) arrowp2l4 = self end,--Removed semicolon because SM5. -Kid
        OnCommand= cmd(x,40*4;zoom,0.6),
        Texture= "arrowlit.png",
      },
      Def.Sprite{
        Name= "actor_yoc",
        InitCommand= function(self) arrowp2l5 = self end,--Removed semicolon because SM5. -Kid
        OnCommand= cmd(x,40*5;zoom,0.6),
        Texture= "arrowlit.png",
      },
    },
    optional_actor(cond_jnc_result,
    Def.Quad{
      Name= "actor_zoc",
      DoDownCommand= function (self) if mawaru_curgame == 16 then
			if mawaru_code_p1iwaitd<=0 and mawaru_code_waitp1<=0 then
				if mawaru_code_codestringp1 <= table.getn(mawaru_code_codes[mawaru_code_codedp1+1]) and mawaru_code_codes[mawaru_code_codedp1+1][mawaru_code_codestringp1] == 'd' then
					mawaru_code_right(1); mawaru_code_codestringp1 = mawaru_code_codestringp1+1
				else
					Sound('wrong')
					mawaru_code_waitp1 = 0.5
					MESSAGEMAN:Broadcast('SFErrorP1');
					mawaru_code_codestringp1 = 1
				end
				mawaru_code_p1iwaitd = 0.05
			end end
		end,
      DoLeftCommand= function (self) if mawaru_curgame == 16 then
			if mawaru_code_p1iwaitl<=0 and mawaru_code_waitp1<=0 then
				if mawaru_code_codestringp1 <= table.getn(mawaru_code_codes[mawaru_code_codedp1+1]) and mawaru_code_codes[mawaru_code_codedp1+1][mawaru_code_codestringp1] == 'l' then
					mawaru_code_right(1); mawaru_code_codestringp1 = mawaru_code_codestringp1+1
				else
					Sound('wrong')
					mawaru_code_waitp1 = 0.5
					MESSAGEMAN:Broadcast('SFErrorP1');
					mawaru_code_codestringp1 = 1
				end
				mawaru_code_p1iwaitl = 0.05
			end end
		end,
      DoRightCommand= function (self) if mawaru_curgame == 16 then
			if mawaru_code_p1iwaitr<=0 and mawaru_code_waitp1<=0 then
				if mawaru_code_codestringp1 <= table.getn(mawaru_code_codes[mawaru_code_codedp1+1]) and mawaru_code_codes[mawaru_code_codedp1+1][mawaru_code_codestringp1] == 'r' then
					mawaru_code_right(1); mawaru_code_codestringp1 = mawaru_code_codestringp1+1
				else
					Sound('wrong')
					mawaru_code_waitp1 = 0.5
					MESSAGEMAN:Broadcast('SFErrorP1');
					mawaru_code_codestringp1 = 1
				end
				mawaru_code_p1iwaitr = 0.05
			end end
		end,
      DoUpCommand= function (self) if mawaru_curgame == 16 then
			if mawaru_code_p1iwaitu<=0 and mawaru_code_waitp1<=0 then
				if mawaru_code_codestringp1 <= table.getn(mawaru_code_codes[mawaru_code_codedp1+1]) and mawaru_code_codes[mawaru_code_codedp1+1][mawaru_code_codestringp1] == 'u' then
					mawaru_code_right(1); mawaru_code_codestringp1 = mawaru_code_codestringp1+1
				else
					Sound('wrong')
					mawaru_code_waitp1 = 0.5
					MESSAGEMAN:Broadcast('SFErrorP1');
					mawaru_code_codestringp1 = 1
				end
				mawaru_code_p1iwaitu = 0.05
			end end
		end,
      InitCommand= cmd(visible,false),
      StepDownP1MessageCommand= cmd(queuecommand,"DoDown"),
      StepLeftP1MessageCommand= cmd(queuecommand,"DoLeft"),
      StepP1DownPressMessageCommand= cmd(queuecommand,"DoDown"),
      StepP1DownPressedMessageCommand= cmd(queuecommand,"DoDown"),
      StepP1LeftPressMessageCommand= cmd(queuecommand,"DoLeft"),
      StepP1LeftPressedMessageCommand= cmd(queuecommand,"DoLeft"),
      StepP1RightPressMessageCommand= cmd(queuecommand,"DoRight"),
      StepP1RightPressedMessageCommand= cmd(queuecommand,"DoRight"),
      StepP1UpPressMessageCommand= cmd(queuecommand,"DoUp"),
      StepP1UpPressedMessageCommand= cmd(queuecommand,"DoUp"),
      StepRightP1MessageCommand= cmd(queuecommand,"DoRight"),
      StepUpP1MessageCommand= cmd(queuecommand,"DoUp"),
    }),
    optional_actor(cond_knc_result,
    Def.Quad{
      Name= "actor_Aoc",
      DoDownCommand= function (self) if mawaru_curgame == 16 then
			if mawaru_code_p2iwaitd<=0 and mawaru_code_waitp2<=0 then
				if mawaru_code_codestringp2 <= table.getn(mawaru_code_codes[mawaru_code_codedp2+1]) and mawaru_code_codes[mawaru_code_codedp2+1][mawaru_code_codestringp2] == 'd' then
					mawaru_code_right(2); mawaru_code_codestringp2 = mawaru_code_codestringp2+1
				else
					Sound('wrong')
					mawaru_code_waitp2 = 0.5
					MESSAGEMAN:Broadcast('SFErrorP2');
					mawaru_code_codestringp2 = 1
				end
				mawaru_code_p2iwaitd = 0.05
			end end
		end,
      DoLeftCommand= function (self) if mawaru_curgame == 16 then
			if mawaru_code_p2iwaitl<=0 and mawaru_code_waitp2<=0 then
				if mawaru_code_codestringp2 <= table.getn(mawaru_code_codes[mawaru_code_codedp2+1]) and mawaru_code_codes[mawaru_code_codedp2+1][mawaru_code_codestringp2] == 'l' then
					mawaru_code_right(2); mawaru_code_codestringp2 = mawaru_code_codestringp2+1
				else
					Sound('wrong')
					mawaru_code_waitp2 = 0.5
					MESSAGEMAN:Broadcast('SFErrorP2');
					mawaru_code_codestringp2 = 1
				end
				mawaru_code_p2iwaitl = 0.05
			end end
		end,
      DoRightCommand= function (self) if mawaru_curgame == 16 then
			if mawaru_code_p2iwaitr<=0 and mawaru_code_waitp2<=0 then
				if mawaru_code_codestringp2 <= table.getn(mawaru_code_codes[mawaru_code_codedp2+1]) and mawaru_code_codes[mawaru_code_codedp2+1][mawaru_code_codestringp2] == 'r' then
					mawaru_code_right(2); mawaru_code_codestringp2 = mawaru_code_codestringp2+1
				else
					Sound('wrong')
					mawaru_code_waitp2 = 0.5
					MESSAGEMAN:Broadcast('SFErrorP2');
					mawaru_code_codestringp2 = 1
				end
				mawaru_code_p2iwaitr = 0.05
			end end
		end,
      DoUpCommand= function (self) if mawaru_curgame == 16 then
			if mawaru_code_p2iwaitu<=0 and mawaru_code_waitp2<=0 then
				if mawaru_code_codestringp2 <= table.getn(mawaru_code_codes[mawaru_code_codedp2+1]) and mawaru_code_codes[mawaru_code_codedp2+1][mawaru_code_codestringp2] == 'u' then
					mawaru_code_right(2); mawaru_code_codestringp2 = mawaru_code_codestringp2+1
				else
					Sound('wrong')
					mawaru_code_waitp2 = 0.5
					MESSAGEMAN:Broadcast('SFErrorP2');
					mawaru_code_codestringp2 = 1
				end
				mawaru_code_p2iwaitu = 0.05
			end end
		end,
      InitCommand= cmd(visible,false),
      StepDownP2MessageCommand= cmd(queuecommand,"DoDown"),
      StepLeftP2MessageCommand= cmd(queuecommand,"DoLeft"),
      StepP2DownPressMessageCommand= cmd(queuecommand,"DoDown"),
      StepP2DownPressedMessageCommand= cmd(queuecommand,"DoDown"),
      StepP2LeftPressMessageCommand= cmd(queuecommand,"DoLeft"),
      StepP2LeftPressedMessageCommand= cmd(queuecommand,"DoLeft"),
      StepP2RightPressMessageCommand= cmd(queuecommand,"DoRight"),
      StepP2RightPressedMessageCommand= cmd(queuecommand,"DoRight"),
      StepP2UpPressMessageCommand= cmd(queuecommand,"DoUp"),
      StepP2UpPressedMessageCommand= cmd(queuecommand,"DoUp"),
      StepRightP2MessageCommand= cmd(queuecommand,"DoRight"),
      StepUpP2MessageCommand= cmd(queuecommand,"DoUp"),
    }),
    Def.Quad{
      Name= "actor_Boc",
      OnCommand= cmd(x,320;y,240;zoomto,6,480;diffuse,color('0,0,0,1')),
    },
    optional_actor(cond_lnc_result,
    Def.Quad{
      Name= "actor_Coc",
      OnCommand= cmd(x,640*0.25;y,240;zoomto,640/2,480;diffuse,color('0,0,0,1')),
    }),
    optional_actor(cond_mnc_result,
    Def.Quad{
      Name= "actor_Doc",
      OnCommand= cmd(x,640*0.75;y,240;zoomto,640/2,480;diffuse,color('0,0,0,1')),
    }),
    Def.Sprite{
      Name= "actor_Eoc",--Reverse-converted x & y pos. -Kid
      OnCommand= cmd(diffusealpha,0;zoom,3;vibrate;effectmagnitude,1,1,1;x,320;y,240),
      StartCommand= cmd(finishtweening;diffusealpha,0;zoom,3;linear,0.2;zoom,0.6;diffusealpha,.6;sleep,2.5),
      Texture= "inst.png",
    },
  },
}
