Save-Point
Help editing a script - Printable Version

+- Save-Point (https://www.save-point.org)
+-- Forum: Games Development (https://www.save-point.org/forum-4.html)
+--- Forum: Code Support (https://www.save-point.org/forum-20.html)
+--- Thread: Help editing a script (/thread-4940.html)



Help editing a script - Iqus - 12-25-2013

Hi people! I have a script that allows short messages to appear in the lower-right corner without pausing the game action, making the gameplay smoother. I decided to add an Icon to make it nicer, however, due to my lack of expertise in RGSS, the icon always appears and I want it to appear AND disappear along with the text, I think it's a very easy scripting but I do not know how to do it :v

The code:


Code:
#:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=
#|Autor: RD12| Mensagens na Tela v1.5
#-------------------------------------------------------------------
#Chame o script: Msg_txt("Texto", cor) onde cor = red, blue..
#É opcional por a cor, se você não por, ficará branca.
#--------------------------------------------------------------------

module WIN_MSG
X = 373
Y = 0
L = 300#largura
Windowskin = "windowskin" #"001-blue01"
#Tempo em segundos para ir deletando as mensagens
Clear_Time = 7
end

#::Cores::
def red; return Color.new(255, 0, 0); end
def green; return Color.new(0, 255, 0); end
def blue; return Color.new(0, 0, 255); end
def black; return Color.new(0, 0, 0); end
def white; return Color.new(255, 255, 255); end

class Window_Msg < Window_Base

def initialize
super(WIN_MSG::X,WIN_MSG::Y,WIN_MSG::L,30*2)
self.contents = Bitmap.new(width - 32, height - 32)
self.back_opacity = 126
self.windowskin = RPG::Cache.windowskin(WIN_MSG::Windowskin)
color = Color.new(255, 255, 255)
$Msg_log = [["", color], ["", color], ["", color], ["", color]]
self.y = 420
Msg_txt("")
refresh
end

def refresh
self.contents.clear
self.contents.font.name = "Corbel"
self.contents.font.size = 15
#::Escrever as Mensagens::
bitmap = RPG::Cache.icon("info.png")
self.contents.blt(0, 0, bitmap, Rect.new(0, 0, 24, 24), 255)
self.contents.font.color = $Msg_log[$Msg_log.size-1][1]
self.contents.draw_text(40, 0, 310, 32, "#{$Msg_log[$Msg_log.size-1][0]}")
end

end

def Msg_txt(text, color=Color.new(255, 255, 255))
$Msg_log << [text, color]
end

class Scene_Map
alias me_main main
def main
@win_msg = Window_Msg.new
me_main
@win_msg.dispose
end
alias msg_update update
def update
msg_update
@win_msg.refresh
if Graphics.frame_count % (40*WIN_MSG::Clear_Time) == 0
Msg_txt("")
end
end
end

and an image:
[Image: obci.png]


RE: Help editing a script - MechanicalPen - 12-25-2013

try adding a 'refresh' after 'if Graphics.frame_count % (40*WIN_MSG::Clear_Time) == 0
Msg_txt("")'

also next time, when posting code, use the
Code:
[code]
[/code] tags.


RE: Help editing a script - Iqus - 02-16-2014

It didn't work but I replaced the script with a new one, thanks anyway! ^^


RE: Help editing a script - JayRay - 02-17-2014

DerVVulfman and I cooperatively created a GameLog window that worked for pretty much just what you want to do. and I believe with a little tweaking you should be able to get it to recognize icons in the messages too. You should be able to find the Lycan ABS 4.7 here somewhere, and in the addons, JayRay's Lycan GameLog is available. The best thing about that one, is it works without the rest of the scripts as far as I know.