setelah mendapat sedikit pencerahan dari sebuah bukau akhirnya aku coba untuk menulis script rgss2 pertamaku dan hasilnya adalah seperti ini.
code start here
#——————————————————————————
# Language select
#——————————————————————————
# scene buat milih bahasa
# game message dibuat dengan conditional branch if switch 002=on textnya ditulis dalam
# bahasa inggris trus kalo switch 003=on textnya ditulis dalam bahas indo, trus
# scwith 002 dan 003 diubah via script di scene_Option
#——————————————————————————
module NO2
NO2::ENG = “English”
NO2::IND = “Bahasa Indonesia”
end
#==============================================================================
# ** Scene_Option
#——————————————————————————
# Option milih bahasa.
#==============================================================================
class Window_Lang_Title < Window_Base
#————————————————————————–
# ? window help
#————————————————————————–
def initialize
super(0, 0, 640, 56)
refresh
end
#————————————————————————–
# ? window title text
#————————————————————————–
def refresh
text1 = “Chose your langguage”
text2 = NO2::ENG
text3 = NO2::IND
self.contents.clear
self.contents.font.color = normal_color
self.contents.draw_text(220, 0, 420, WLH, text1, 0)
end
end
#—————————————————————————-
# language indicator window
#—————————————————————————-
class Window_Lang_active < Window_Base
#————————————————————————–
# ? window help
#————————————————————————–
def initialize
super(0, 56, 640, 56)
refresh
end
#————————————————————————–
# ? window active text
#————————————————————————–
def refresh
text1 = “Curent language”
text2 = NO2::ENG
text3 = NO2::IND
self.contents.clear
self.contents.font.color = normal_color
self.contents.draw_text(20, 0, 420, WLH, text1, 0)
end
# nampilin bahasa yang active masih bingung, kalo scriptnya dalam bahsa indonesia
# kayak gini: jika switch 002 on maka tulis NO2::ENG di (220,0,420) jika yang on
# swith 003 maka tulis NO2::ENG di (220,0,420) ##elseif??## trus biar bisa update
# secara real time ketika pilihan english ato indonesia di pilih gimana ya??
end
class Scene_Lang < Scene_Base
#————————————————————————–
# * Start processing
#————————————————————————–
def start
super
create_menu_background
create_command_window
@help_window = Window_Lang_Title.new
@Lang_Active = Window_Lang_active.new
end
#————————————————————————–
# * Post-Start Processing
#————————————————————————–
def post_start
super
open_command_window
end
#————————————————————————–
# * Pre-termination Processing
#————————————————————————–
def pre_terminate
super
close_command_window
end
#————————————————————————–
# * Termination Processing
#————————————————————————–
def terminate
super
dispose_command_window
dispose_menu_background
@help_window.dispose
@Lang_Active.dispose
end
#————————————————————————–
# * Return to Original Screen
#————————————————————————–
def return_scene
$scene = Scene_Option.new #$scene = Scene_menu.new(0)
end
#————————————————————————–
# * Frame Update
#————————————————————————–
def update
super
update_menu_background
@command_window.update
if Input.trigger?(Input::B)
Sound.play_cancel
return_scene
elsif Input.trigger?(Input::C)
case @command_window.index
when 0 # ENG
lang_ENG
when 1 # INA
lang_IND
when 2 # cancel
command_cancel
end
end
end
#————————————————————————–
# * Update Background for Menu Screen
#————————————————————————–
def update_menu_background
super
@menuback_sprite.tone.set(0, 0, 0, 128)
end
#————————————————————————–
# * Create Command Window
#————————————————————————–
def create_command_window
s1 = NO2::ENG
s2 = NO2::IND
s3 = Vocab::cancel
@command_window = Window_Command.new(172, [s1, s2, s3])
@command_window.x = 224
@command_window.y = (480 – @command_window.height) / 2
@command_window.openness = 0
end
#————————————————————————–
# * Dispose of Command Window
#————————————————————————–
def dispose_command_window
@command_window.dispose
end
#————————————————————————–
# * Open Command Window
#————————————————————————–
def open_command_window
@command_window.open
begin
@command_window.update
Graphics.update
end until @command_window.openness == 255
end
#————————————————————————–
# * Close Command Window
#————————————————————————–
def close_command_window
@command_window.close
begin
@command_window.update
Graphics.update
end until @command_window.openness == 0
end
#————————————————————————–
# english on indonesia off
#————————————————————————–
def lang_ENG
Sound.play_decision
RPG::BGM.fade(800)
RPG::BGS.fade(800)
RPG::ME.fade(800)
$game_switches[002] = true
$game_switches[003] = false
end
#————————————————————————–
# english off indonesia on
#————————————————————————–
def lang_IND
Sound.play_decision
RPG::BGM.fade(800)
RPG::BGS.fade(800)
RPG::ME.fade(800)
$game_switches[002] = false
$game_switches[003] = true
end
#————————————————————————–
# * Process When Choosing [Cancel] Command
#————————————————————————–
def command_cancel
Sound.play_decision
return_scene
end
end
sebenarnya nih cuman script simple buat bikin scene option yang ntar ditambahin di menu.
so basicly script ini adalah sebuah script yang berisi command untuk menghidupkan switch 002 dan mematikan switch 003 saat user milih pilihan “english” serta sebaliknya jika user memilih “indonesia” aku masih mau menambah beberapa fitur sederhana lagi pada nih scrip yaitu indikator untuk memperlihatkan switch mana yang sedang active
Note: sebagian codenya banyak yang gak efektif dan sebenarnya masih bisa di trim lebih banyak tapi berhubung aku masih belajar jadi ntar aja deh
setelah di test hasilnya adalah
he he he keliatan banget kan betpa sederhananya script ini dan masih banyak kurangnya pula


Recent Comments