- Joined
- Dec 12, 2012
- Messages
- 40
- Reaction score
- 0
- First Language
- English
I've set up this script to change the screen tint after checking the very first comment command on every event within the current map.
It works just fine whenever I move to a new map, it checks the comments again; but what if I wanted to check the comments again
after I've changed event pages, and thus changing the map's tint?
I've tried calling the method: kg_setup_notes() again from various other methods. Currently it's from Game_Map refresh().
I always get the same error when I change the event page
ERROR: Script **Elysia Core** line 57:NoMethodError occurred.
undefined method '[]' for nil::NilClass
Is there any better way of checking if an event's page has changed?
The tags I'm using are these: Page1 <grph tint: night> ; Page2 <grph tint: twilight>
Full Script Below
It works just fine whenever I move to a new map, it checks the comments again; but what if I wanted to check the comments again
after I've changed event pages, and thus changing the map's tint?
I've tried calling the method: kg_setup_notes() again from various other methods. Currently it's from Game_Map refresh().
I always get the same error when I change the event page
ERROR: Script **Elysia Core** line 57:NoMethodError occurred.
undefined method '[]' for nil::NilClass
Is there any better way of checking if an event's page has changed?
The tags I'm using are these: Page1 <grph tint: night> ; Page2 <grph tint: twilight>
Full Script Below
Code:
=begin#==============================================================================# ╔════════════════════════════════════════════=═════=═══╤═══════╤═══════════╗ ║ Elysia Core Script │version│ updated ║ ║ By: KieronGryph │ 1.0 │ 1/17/14 ║ ╚═════════════════════════════════════════════════=════╧═══════╧═══════════╝#-------------------------------------------------------------------------------# Changelog #---------------------------------------------------------------------------------=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=-- --------------- #Event Comment Tags # ---------------*NOTICE* Event Comment Tags will only work if the comment is the event's very first command. Set map's default tint: <grph tint: tint name> Adding this to an event's comment will set the current map's tint to one specified here by it's name. It will also prevent the changing of the time from affecting the tint for the current map. Tint can still be temporally changed using the Tint Screen event command, until you leave the map.--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--#==============================================================================#=end Graphics.resize_screen(640,480)class Game_Map#==============================================================================# * Public Instance Variables#============================================================================== attr_accessor :tint_name attr_accessor :can_change_tone attr_reader :comment#------------------------------------------------------------------------------- alias kg_core_game_map_old_setup_kg setup def setup(map_id) kg_core_game_map_old_setup_kg(map_id) init_attr() kg_setup_notes() end #alias setup alias kg_core_old_game_map_refresh_kg refresh def refresh() kg_core_old_game_map_refresh_kg#**********************# #*********************# #**********************# kg_setup_notes() #comment this out and the script runs just fine.#**********************# #*********************# #**********************# end #alias refresh def init_attr() @tint_name = "" @can_change_tone = true @comment = "" end #init_attr def get_first_comment(event_id) if events[event_id].list[0].code == 108 text = [] index = 0 text.push(events[event_id].list[index].parameters[0]) while events[event_id].list[index + 1].code == 408 index += 1 text.push(events[event_id].list[index].parameters[0]) end #while return text end #if return "" end #get_first_comment def kg_setup_notes()#~ for event in events #~ id = event[0] @map.events.each do |i, event| id = i p(id) if get_first_comment(id) != "" p("Skye") @comment = get_first_comment(id) tint_note(id) end #if end #.each do end #setup_notes def tint_note(id) for i in @comment i.match(/<grph tint:\s*(\w+)>/i) @can_change_tone = false unless $1 == nil || $1 == "" @tint_name = $1 unless $1 == nil || $1 == "" screen_tinter(@tint_name) unless $1 == nil || $1 == "" end #for end #tint_note #$game_map.screen_tinter("name", duration) def screen_tinter(tint, duration = 60) if tint == "dawn" $game_map.screen.start_tone_change(Tone.new(-34,-34,34, 0), duration) elsif tint == "midday" $game_map.screen.start_tone_change(Tone.new(0,0,0, 0), duration) elsif tint == "dusk" $game_map.screen.start_tone_change(Tone.new(51,-25,-34, 0), duration) elsif tint == "twilight" $game_map.screen.start_tone_change(Tone.new(0,-68,-25, 68), duration) elsif tint == "night" $game_map.screen.start_tone_change(Tone.new(-68,-68,0, 68), duration) elsif tint == "volcanic" $game_map.screen.start_tone_change(Tone.new(34,-68,-34, 0), duration) end #if end #screen_tinterend #Game_Map

