eragon 55100
Member
This should be pretty simple, I believe it is already scripted into the default RMXP Main script, but, I can't for the life of me get it to work with the Pokemon Essentials Main script. What I want to do is close a socket connection when the window is closed. I already put it in the position I thought best :
But it doesn't appear to work. Any help?
Thanks in advance.
Code:
=begin
Graphics.frame_rate=40
window=Window.new
window.x=0
window.y=0
window.width=200
window.height=200
window.windowskin=Bitmap.new("Graphics/Windowskins/Window.png")
window.openness=255
loop do
window.openness=(Graphics.frame_count*2)&0xFF
Graphics.update
end
exit
=end
def pbCallTitle
if $DEBUG
return Scene_Connect.new
else
# First parameter is an array of images in the Titles
# directory without a file extension, to show before the
# actual title screen. Second parameter is the actual
# title screen filename, also in Titles with no extension.
return Scene_Intro.new(['Pic_1'], 'Pic_2')
end
end
def mainFunction
if $DEBUG
pbCriticalCode { mainFunctionDebug }
else
mainFunctionDebug
end
return 1
end
def mainFunctionDebug
begin
getCurrentProcess=Win32API.new("kernel32.dll","GetCurrentProcess","","l")
setPriorityClass=Win32API.new("kernel32.dll","SetPriorityClass",%w(l i),"")
getPriorityClass=Win32API.new("kernel32.dll","GetPriorityClass",%w(l),"l")
getCurrentThread=Win32API.new("kernel32.dll","GetCurrentThread","","l")
setThreadPriority=Win32API.new("kernel32.dll","SetThreadPriority",%w(l i),"")
setPriorityClass.call(getCurrentProcess.call(),32768) # "Above normal" priority class
$data_animations = pbLoadRxData("Data/Animations")
$data_tilesets = pbLoadRxData("Data/Tilesets")
$data_common_events = pbLoadRxData("Data/CommonEvents")
$data_system = pbLoadRxData("Data/System")
$game_system = Game_System.new
setScreenBorderName("border.png")
Graphics.update
Graphics.freeze
$scene = pbCallTitle
$mouse = Game_Mouse.new
while $scene != nil
$scene.main
end
[size=5][u][b]Network::Main.close_socket[/b][/u] [/size]
Graphics.transition(25)
rescue Hangup
pbEmergencySave
raise
Network::Main.close_socket
end
end
loop do
retval=mainFunction
if retval==0 # failed
loop do
Graphics.update
end
elsif retval==1 # ended successfully
break
end
end
Thanks in advance.