Esse script permite que você adicione uma lanterna no seu jogo. No script você precisa de um item representando a lanterna, outro para representar a bateria e um switch que controle se está escuro o suficiente para ligar a lanterna.
O script não é meu mas decidi colocar ele aqui pois achei ele muito bom. Script de Gousenfire
#=============================================================================#
#======================# #======================#
#======================# Flashlight BG #======================#
#======================# by #======================#
#======================# Gousenfire #======================#
#======================# Versão: 1.2 #======================#
#=============================================================================#
#=============================================================================#
# #
# Configurações #
# #
#=============================================================================#
module FlashlightModule
# Opacidade da imagem da lanterna 0 = Transparente / 255 = Preto
Opacity = 220
# Switch que mostra que está de noite
Switch1 = 1
# Nome da imagem na pasta pictures
Image = "Lantern"
# ID, no database, do item que representa as pilhas
Batery = 2
# ID, no database, do item que representa a lanterna
FlashL = 1
# Botão que liga a lanterna
Buttom = :L # Aperte F1 ao iniciar o jogo para ver a lista de botoes
# Tempo (em frames) para se perder uma pilha
Time = 120 # 60 framses = 1 segundo
# SE tocada quando ocorre algum erro
SEE = "Buzzer1"
# SE tocada quando liga a lanterna
SET = "Cursor2"
# Ficar escuro quando a Switch1 estiver ligada?
Dark = true
end
#=============================================================================#
# #
# Código Fonte #
# (Não altere essa parte sem a permissão do criador) #
#=============================================================================#
class Spriteset_Map
include FlashlightModule
alias fl_initialize initialize
alias fl_update update
alias fl_dispose dispose
def initialize
@laternIMG, @laternIMG.bitmap = Sprite.new, Cache.picture(Image)
@laternIMG.z = 998
@laternIMG.opacity = Opacity
@laternIMG.visible = false
@darkBM, @darkBM.bitmap = Sprite.new
@darkBM.bitmap = Bitmap.new(1088,1200)
@darkBM.x = 0
@darkBM.y = 0
@darkBM.z = 999
@darkBM.bitmap.fill_rect(@darkBM.bitmap.rect, Color.new(0, 0, 0))
@darkBM.opacity = Opacity
@darkBM.visible = false
@darkBM.update
@lanterOnOrOff = false # variable that controlls if the lantern is on or off
@isDark = false # variable that controlls if is dark or not
@haveEnoughtBaterys = false # variable that controll if the player have enought baterys to turn on the lantern
@haveTheLanter # variable that check if the player has the item Lanter
fl_initialize
end
def update
# if the buttun is pressed change the variable to the opisit
if Input.trigger?(Buttom)
if @lanterOnOrOff
@lanterOnOrOff = false
Audio.se_play("Audio/SE/" + SET, 70, 100)
else
if @isDark && @haveEnoughtBaterys && @haveTheLanter
@lanterOnOrOff = true
Audio.se_play("Audio/SE/" + SET, 70, 100)
else
Audio.se_play("Audio/SE/" + SEE, 70, 100)
end
end
end
if @lanterOnOrOff && (!@isDark || !@haveEnoughtBaterys || !@haveTheLanter)
@lanterOnOrOff = false
Audio.se_play("Audio/SE/" + SET, 70, 100)
end
# check if the player has the item lanter in the inventory
if $game_party.item_number($data_items[FlashL]) > 0
@haveTheLanter = true
else
@haveTheLanter = false
end
# Check if the player has batery in the inventory
if $game_party.item_number($data_items[Batery]) > 0
@haveEnoughtBaterys = true
else
@haveEnoughtBaterys = false
end
# transform the switch in a variable
if $game_switches[Switch1]
@isDark = true
if Dark
if !@lanterOnOrOff
dark_the_sky
else
light_up_yhe_sky
end
end
else
@isDark = false
if Dark
light_up_yhe_sky
end
end
# call the right met
if @lanterOnOrOff
lanter_is_on
else
latern_is_off
end
fl_update # call update
end
def lanter_is_on
@laternIMG.visible = true
if Graphics.frame_count % Time == 0
$game_party.lose_item($data_items[Batery], 1)
end
case $game_player.direction
when 2
@laternIMG.angle, @coord = 0, [544, 586]
when 8
@laternIMG.angle, @coord = 180, [-544, -565]
when 6
@laternIMG.angle, @coord = 90, [576, -522]
when 4
@laternIMG.angle, @coord = 270, [-576, 570]
end
@laternIMG.x = $game_player.screen_x - @coord[0]
@laternIMG.y = $game_player.screen_y - @coord[1]
@laternIMG.update
end
def latern_is_off
@laternIMG.visible = false
@lanterOnOrOff = false
@laternIMG.update
end
def dark_the_sky
@darkBM.visible = true
@darkBM.update
end
def light_up_yhe_sky
@darkBM.visible = false
@darkBM.update
end
def dispose
latern_is_off
light_up_yhe_sky
fl_dispose
end
end
Instruções:
1) Na tela do RPG Maker VX Ace aperte F11;
2) Procure na biblioteca de script um script com o nome "( insira scripts aqui )";
3) Clique com o botão direito do mause sobre ele e selecione "Inserir Script";
4) Copie e cole TODO o conteúdo da parte "Script" deste tópico nesse novo script que você criou;
5) Entre na pasta do seu jogo: Graphics\Pictures e adicione a imagem que deseja para a lanterna;
6) Copie o nome do arquivo e no script cole o nome na linha 20 (depois de "Image = ", deixe entre aspas o nome do arquivo);
7) Pronto! Faça bom uso do script e não se esqueça de ver os Termos e Condições de Uso;
Lanterna imagem: http://i60.tinypic.com/2njda38.jpg
Olá sou iniciante e se puder disponibilizar um projeto com esse sistema agradeço.
Ótimo script Karpa.