# Script Inputter
# (Scripter's tool)
# Just press F4 and type!
# Also close by pressing F4
module Mm12
SCRIPTER_FONT = "Courier New"
SCRIPTER_COLOR= Color.new(0,0,0)
# Don't touch below
SHIFTED_KEYS = {"0"=>")","1"=>"!","2"=>"@","3"=>"#","4"=>"$","5"=>"%","6"=>"^",
"7"=>"&","8"=>"*","9"=>"(","*"=>"*","+"=>"+","-"=>"-","."=>">","/"=>"?",
"`"=>"~","="=>"+",","=>"<","-"=>"_","\\"=>"|","\'"=>"\"","["=>"{","]"=>"}",";"=>":"}
OEC_KEYS = {106=>"*",107=>"+",109=>"-",110=>".",111=>"/",186=>";",187=>"=",
188=>",",189=>"-",190=>".",191=>"/",192=>"`",219=>"[",220=>"\\",221=>"]",
222=>"\'"}
end
class Scene_Map < Scene_Base
attr_accessor :spriteset;include Mm12
alias mm12_scripting_start start
alias mm12_scripting_update update
def start
mm12_scripting_start
shdw=([SCRIPTER_COLOR.red,SCRIPTER_COLOR.blue,SCRIPTER_COLOR.green].max>100)
@ins_wait = 20
@scripting = false
@text_sprite=@text_sprite2=@ins_sprite=Sprite.new
@text_sprite.bitmap=@text_sprite1.bitmap=@ins_sprite.bitmap=Bitmap.new(544,30)
@text_sprite.bitmap.font.shadow=@text_sprite2.bitmap.font.shadow=
@ins_sprite.bitmap.font.shadow=shdw
@text_sprite.bitmap.font.name=@text_sprite2.bitmap.font.name=
@ins_sprite.bitmap.font.name=SCRIPTER_FONT
@text_sprite.bitmap.font.color=@text_sprite2.bitmap.font.color=
@ins_sprite.bitmap.font.color=SCRIPTER_COLOR
@text_sprite.z = 60000
@text_sprite.oy = -200
@text_sprite.bitmap.font.bold = true
@ins_sprite.z = 60000
@ins_sprite.oy = -200
@ins_sprite.bitmap.font.bold = false
@text = "@> "
@text_sprite2.z = 60001
@text_sprite2.oy = -230
@text_sprite2.ox = -30
@text_sprite2.bitmap.font.bold = true
end
def update
mm12_scripting_update
update_input if@scripting
update_text if@scripting
@text_sprite.visible = @scripting
if Input.trigger?(Input::Fkeys[4])
@scripting=!@scripting;@scripttext_need_update=true;end
end
def update_text
@ins_wait-= 1
if @ins_wait<=0;@ins_sprite.visible=!(@ins_sprite.visible);@ins_wait=20;end
if @scripttext_need_update == true
@text_sprite.bitmap.clear
@printed_text = @text
@text_sprite.bitmap.draw_text(0,0,544,30,@printed_text)
width = @text_sprite.bitmap.text_size(@text).width
@ins_sprite.bitmap.clear
@ins_sprite.bitmap.draw_text(width-2,0,544,30,"|")
@scripttext_need_update = false
end
end
def update_input
if Input.press?(Input::Shift)
for i in 1..256
if Input.repeat?(i)
case i
when 48..57; @text += SHIFTED_KEYS[Input::KEYS_NAMES[i]]
when 65..90; @text += Input::KEYS_NAMES[i]
when 106..111, 186..192, 219..222; @text += SHIFTED_KEYS[OEC_KEYS[i]]
when 32; @text += " "
when 8; @text[-1] = "" unless @text == "@> "
when 9; @text += " "
when 13,45; enter_text
end
@scripttext_need_update = true
return
end
end
else
for i in 1..256
if Input.repeat?(i)
case i
when 48..57,65..90;@text+=Input::KEYS_NAMES[i].downcase
when 106..111,186..192,219..222;@text+=OEC_KEYS[i]
when 32;@text+=" "
when 8;@text[-1]=""unless@text=="@> "
when 9;@text+=" "
when 13,45;enter_text
end
@scripttext_need_update = true
return
end
end
end
end
def enter_text
@text[0,3]=""
begin
@gets=Kernel.eval(@text).inspect
rescue
@gets=sprintf("ERR: %s\n",$!)
end
@text="@> ";@scripttext_need_update=true;draw_output
end
def draw_output
@text_sprite2.bitmap.clear
@text_sprite2.bitmap.draw_text(0,0,416,314,"=> #{@gets}")
@ins_sprite.bitmap.clear
@ins_sprite.bitmap.draw_text(-2,0,544,30," |")
end
end