• Anmelden

1

Samstag, 2. Februar 2013, 09:53

Show Event Name - Script ausschalten

Hallo,
Ich benutze das Script "Show Event Name" von LiTTleDRAgo und habe nun folgendes Problem: Ich möchte, dass das Script an bestimmten Stellen ausgeschaltet und später wieder eingeschaltet wird. Außerdem soll per Callscript der Name eines bestimmten Events nicht mehr angezeigt werden, wenn es eine neue Eventseite erreicht hat.
Hier ist das Script:
Spoiler

Ruby Quellcode

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
#:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:
# [Xp/Vx] Show Event Name
# Version: 4.20
# Author : LiTTleDRAgo 
#:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:
#
# Explanation:
#
#   - This script shows event name in map
#
# Instructions:
#
#   - Setup the few configurations below.   
#
#
#   - Insert the event name
#     <Name=X>       X = Name showed in map
#     <SizeX>        X = Size the font
#     <Bold>         Toggle Bold
#     <Italic>       Toggle Italic
#     <Font[X]>      X = Font name
#     <ColorX,X,X,X> X,X,X,X = Color the font(in RGB)
#
#   - Or use call script to show the event name
#     
#     $game_map.events[2].show_name = x
#     $game_player.show_name = x
#
#     where x is a string
#
#   That's all
#
#  Press Z and C together to turn on the name on / off
#
#:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:
 
module EventName
 
  FONT        = ['Georgia',16]   # Font Name and Font Size
 
  BOLD        = true             # Toggle Bold
  ITALIC      = true             # Toggle Italic
 
  SWITCH      = 50               # Switch for Disable Show Event Name
  PRESS_BTN   = [Input::A,       # (Z Keyboard XP) (Shift Keyboard VX)
                 Input::C]       # (C/Enter Keyboard XP) (Z/Enter Keyboard VX)
 
  COLOR       = Color.new(255,255,255,255) # Color Default
  POSITION    = "A"                  # A = Above, B = Below
  RANGE       = 2                    # Range from character to show the name
 
  USEPICT     = nil       # Show background for event name (in folder Pictures)
                          # leave nil if you don't want to
 
end
 
 
 
 
if true
#==============================================================================
# ** Sprite_EventName
#------------------------------------------------------------------------------
#  This sprite is used to display Event Name. It observes a instance of the
# Game_Character class and automatically changes sprite conditions.
#==============================================================================
class Sprite_EventName < RPG::Sprite
 
  FONT          = EventName::FONT
  BOLD          = EventName::BOLD
  ITALIC        = EventName::ITALIC
  DIS_EV_SWITCH = EventName::SWITCH
  PRESS_BTN     = EventName::PRESS_BTN
  COLOR         = EventName::COLOR
  POS           = EventName::POSITION 
  RANGE         = EventName::RANGE
  USEPICT       = EventName::USEPICT
  #--------------------------------------------------------------------------
  # * Public Instance Variables
  #--------------------------------------------------------------------------
  attr_accessor :character
  #--------------------------------------------------------------------------
  # * Object Initialization
  #     viewport  : viewport
  #     character : character (Game_Character)
  #--------------------------------------------------------------------------
  def initialize(v,character)
    super(v)
    @character = character
    @character.load_name
    @name_event = Sprite.new
    @name_event.bitmap = Bitmap.new(200,280)
    if USEPICT
      @back = Sprite.new
      @back.bitmap = RPG::Cache.picture(USEPICT)
      @back.visible = false
    end
    @name_event.visible = true
    refresh_name
    update
  end
  #--------------------------------------------------------------------------
  # * Coloring
  #--------------------------------------------------------------------------
  def coloring
    size, name, bold, italic, color = FONT[1], FONT[0], BOLD, ITALIC, COLOR 
    size   = @character.fontsize if @character.fontsize
    bold   = @character.bold 
    italic = @character.italic
    color  = @character.color if @character.color
    name   = @character.font if @character.font
      if $xrxs_xas
        @char.gsub!(/<Enemy(\d+)>/i) do color = Color.new(255,0,0,240) end
      elsif $BlizzABS && @character.is_a?(Map_Battler)
        case @character.ai.group
        when 1 then color = Color.new(0  , 0  , 255, 240)
        when 2 then color = Color.new(255, 0  , 0  , 240)
        when 3 then color = Color.new(128, 128, 128, 240)
        when 4 then color = Color.new(128, 128, 128, 240)
        when 5 then color = Color.new(255, 255, 0  , 240)
        when 6 then color = Color.new(0  , 255, 0  , 240)
        end
      end
      @char.gsub!(/<Size(\d+)>/)      do size   = $1.to_i  end
      @char.gsub!(/<Bold>/i)          do bold   = true     end
      @char.gsub!(/<Italic>/i)        do italic = true     end
      @char.gsub!(/<Font\[(.*?)\]>/) do name   = $1.to_s  end
      @char.gsub!(/<Color(\d+),(\d+),(\d+),(\d+)>/) do
        color = Color.new($1.to_i,$2.to_i,$3.to_i,$4.to_i) end 
    @name_event.bitmap.font.name   = name
    @name_event.bitmap.font.bold   = bold
    @name_event.bitmap.font.italic = italic
    @name_event.bitmap.font.size   = size
    @name_event.bitmap.font.color  = color
  end
  #--------------------------------------------------------------------------
  # * Check Name
  #--------------------------------------------------------------------------
  def event_name_check
    @char.gsub!(/<V([0-9]+)>/){ $game_variables[$1.to_i] }
    @char.gsub!(/<A([0-9]+)>/){ !$game_actors[$1.to_i].nil? ? 
                                $game_actors[$1.to_i].name : ''}
    @char.gsub!(/<Size(\d+)>/)    {''}
    @char.gsub!(/<Bold>/i)        {''}
    @char.gsub!(/<Italic>/i)      {''}
    @char.gsub!(/<Font\[(.*?)\]>/){''}
    @char.gsub!(/<Color(\d+),(\d+),(\d+),(\d+)>/) {''}
    @char.gsub!(/<Enemy(\d+)>/i) { !$data_enemies[$1.to_i].nil? ? 
                                    $data_enemies[$1.to_i].name : ''}
    @char.gsub!(/<\[(.*?)\]>/) do @char = $1.to_s end
  end
  #--------------------------------------------------------------------------
  # * Update
  #--------------------------------------------------------------------------
  def update
    super
    if @show_name != @character.show_name 
      @show_name = @character.show_name
      refresh_name 
    end
    update_event_name
    update_back
  end
 
  #--------------------------------------------------------------------------
  # * Refresh
  #--------------------------------------------------------------------------
  def refresh_name 
    return if @name_event.nil? or @name_event.bitmap.nil? or 
      @name_event.disposed? or !@name_event.visible or 
      @character.show_name.nil? or @show_name.nil?
    @name_event.bitmap.clear
    @show_name.each {|@char|  coloring; event_name_check  }
    draw_name
    conf_position
  end
  #--------------------------------------------------------------------------
  # * Conf Position
  #--------------------------------------------------------------------------
  def conf_position
    @x_frame, @y_frame = 4, 4 
    if POS == "A"
      bit = RPG::Cache.character(@character.character_name,
          @character.character_hue)
      @cw = ((bit.width / @x_frame) + @char.length)/2
      @ch = bit.height / @y_frame + 15
      if $xrxs_xas
        @cw = ((@name_event.bitmap.width / @x_frame) + @char.length)/2
        @ch = @name_event.bitmap.height / @y_frame - 5
      end
      @ch += 5 if USEPICT
    else
      @cw = @name_event.bitmap.width / @x_frame / 2
      @ch = @name_event.bitmap.height / @y_frame - 40
    end
  end
  #--------------------------------------------------------------------------
  # * Draw Name
  #--------------------------------------------------------------------------
  def draw_name
    if defined? Bitmap.draw_hemming_text
      @name_event.bitmap.draw_hemming_text(0, 0, 100, 20, @char ,4)
    else
      @name_event.bitmap.draw_text(0, 0, 100, 20, @char ,4)
    end
  end
  #--------------------------------------------------------------------------
  # * Dispose
  #--------------------------------------------------------------------------
  def dispose
    super
    [@name_event, @back].each {|i| i.dispose if !i.nil? && !i.disposed? }
  end
  #--------------------------------------------------------------------------
  # * Visibility
  #--------------------------------------------------------------------------
  def visibility
    pressed = Input.press?(PRESS_BTN[0]) && Input.trigger?(PRESS_BTN[1])
    if RANGE != nil && !@pressed
      x = ($game_player.x-@character.x).abs+($game_player.y-@character.y).abs
      @name_event.visible = (x <= RANGE)
    end
    if !@pressed && pressed
      @name_event.visible, @pressed = false, true
    elsif @pressed && pressed
      @name_event.visible, @pressed = true, false
    end
  end  
  #--------------------------------------------------------------------------
  # * Update Event Name
  #--------------------------------------------------------------------------
  def update_event_name 
    return @name_event.visible = false if !DIS_EV_SWITCH.nil? and
       (@character.opacity < 50 or $game_switches[DIS_EV_SWITCH])
    visibility if !PRESS_BTN.nil?
    if @name_event.visible 
      @name_event.x = @character.screen_x - (@cw.nil? ? 0 : @cw)
      @name_event.y = @character.screen_y - (POS == 'A' ? @ch.nil? ? 0 : @ch : 0)
 
      @name_event.z = 1 
      @name_event.opacity    = @character.opacity
      @name_event.blend_type = @character.blend_type
      @name_event.bush_depth = @character.bush_depth
    end
  end
  #--------------------------------------------------------------------------
  # * Update Back
  #--------------------------------------------------------------------------
  def update_back
    return if !USEPICT
    @back.visible = @name_event.visible && !@char.nil? && 
      !@char.empty? && @char != ' '
    if @back.visible
      @back.opacity = @name_event.opacity - 100
      @back.x = @name_event.x - 5
      @back.y = @name_event.y - 5
      @back.z = @name_event.z - 1 
    end
  end
end
 
#==============================================================================
# ** Game_Character 
#------------------------------------------------------------------------------
#  This class deals with characters. It's used as a superclass for the
#  Game_Player and Game_Event classes.
#==============================================================================
class Game_Character
  #--------------------------------------------------------------------------
  # * Public Instance Variables
  #--------------------------------------------------------------------------
  attr_accessor :show_name,:fontsize,:bold,:italic,:font,:color
  #--------------------------------------------------------------------------
  # * Show Name
  #--------------------------------------------------------------------------
  def show_name=(v= ' ')
    @show_name=v
    record_name
  end
  #--------------------------------------------------------------------------
  # * Record Name
  #--------------------------------------------------------------------------
  def record_name
    if self == $game_player
      $game_system.player_name = @show_name
    end
  end
  #--------------------------------------------------------------------------
  # * Load Name
  #--------------------------------------------------------------------------
  def load_name
    if self == $game_player
      if !$game_system.player_name.nil?
        @show_name = $game_system.player_name
      end
    end
  end
  #--------------------------------------------------------------------------
  # * Clear Name
  #--------------------------------------------------------------------------
  def clear_name
    @show_name = ' '
    if self == $game_player
      $game_system.player_name = @show_name
    end
  end
  #--------------------------------------------------------------------------
  # * Clear every Name
  #--------------------------------------------------------------------------
  def clear_every_name
    $game_system.record_name = {}
    $game_system.player_name = nil
  end
end
 
#==============================================================================
# ** Game_Event
#------------------------------------------------------------------------------
#  This class deals with events. It handles functions including event page 
#  switching via condition determinants, and running parallel process events.
#  It's used within the Game_Map class.
#==============================================================================
class Game_Event < Game_Character
  #--------------------------------------------------------------------------
  # * Alias listing
  #--------------------------------------------------------------------------
  alias erase_show_name erase
  alias init_event_name initialize
  #--------------------------------------------------------------------------
  # * Public Instance Variables
  #--------------------------------------------------------------------------
  attr_reader   :event
  #--------------------------------------------------------------------------
  # * Object Initialization
  #--------------------------------------------------------------------------
  def initialize(map_id, event)
    if event.name =~ /<Name=(.*?)>/i
      @show_name = $1.to_s
    end
    if event.name =~ /<Size(\d+)>/i
      @fontsize = $1.to_i
    end
    @bold   = event.name =~ /<Bold>/i
    @italic = event.name =~ /<Italic>/i
    if event.name =~ /<Font\[(.*?)\]>/i
      @font = $1.to_s
    end
    if event.name =~ /<Color(\d+),(\d+),(\d+),(\d+)>/
      @color = Color.new($1.to_i,$2.to_i,$3.to_i,$4.to_i)
    end
    init_event_name(map_id, event)
  end
  #--------------------------------------------------------------------------
  # * Record Name
  #--------------------------------------------------------------------------
  def record_name
    key = [@map_id, @event.id]
    clear_every_name if  $game_system.record_name.nil?
    $game_system.record_name[key]=[@show_name]
  end
  #--------------------------------------------------------------------------
  # * Load Name
  #--------------------------------------------------------------------------
  def load_name
    key = [@map_id, @event.id]
    clear_every_name if  $game_system.record_name.nil?
    if $game_system.record_name[key] != nil
      @show_name=$game_system.record_name[key][0]
    end
  end
  #--------------------------------------------------------------------------
  # * Clear Name
  #--------------------------------------------------------------------------
  def clear_name
    super
    key = [@map_id, @event.id]
    if $game_system.record_name[key] != nil
      $game_system.record_name[key] = nil
    end
  end
  #--------------------------------------------------------------------------
  # * Temporarily Erase
  #--------------------------------------------------------------------------
  def erase
    clear_name
    erase_show_name
  end
end
 
#==============================================================================
# ** Game_Map
#------------------------------------------------------------------------------
#  This class handles the map. It includes scrolling and passable determining
#  functions. Refer to "$game_map" for the instance of this class.
#==============================================================================
class Game_Map
  #--------------------------------------------------------------------------
  # * Alias listing
  #--------------------------------------------------------------------------
  alias setup_record setup
  #--------------------------------------------------------------------------
  # * Setup
  #     map_id : map ID
  #--------------------------------------------------------------------------
  def setup(map_id)
    setup_record (map_id)
    @map.events.keys.each {|i| @events[i].load_name if !events[i].nil?}
  end
end
 
#==============================================================================
# ** Game_System
#------------------------------------------------------------------------------
#  This class handles data surrounding the system. Backround music, etc.
#  is managed here as well. Refer to "$game_system" for the instance of 
#  this class.
#==============================================================================
class Game_System
  #--------------------------------------------------------------------------
  # * Public Instance Variables
  #--------------------------------------------------------------------------
  attr_accessor :player_name, :record_name
end
 
#==============================================================================
# ** Kernel
#==============================================================================
module Kernel; def rpgvx?() (defined? Graphics.resize_screen) end  end
Cache = RPG::Cache if !defined? Cache
 
#==============================================================================
# ** Spriteset_Map
#------------------------------------------------------------------------------
#  This class brings together map screen sprites, tilemaps, etc. It's used
# within the Scene_Map class.
#==============================================================================
class Spriteset_Map
 
  PRESS_BTN     = EventName::PRESS_BTN
  #--------------------------------------------------------------------------
  # * Public Instance Variables
  #--------------------------------------------------------------------------
  attr_accessor :eventname
  #--------------------------------------------------------------------------
  # * Main Processing
  #--------------------------------------------------------------------------
  def init_eventname
    @eventname = []
    @eventname[0] = Sprite_EventName.new(@viewport1,$game_player)  
    ($game_map.events.keys.sort).each {|i|
      @eventname[i] = Sprite_EventName.new(@viewport1,$game_map.events[i])}
  end
  #--------------------------------------------------------------------------
  # * Frame Update
  #--------------------------------------------------------------------------
  alias update_eventname_earlier update
  def update
    @eventname.nil? ? init_eventname : @eventname.each {|i|i.update if !i.nil?} 
    update_eventname_earlier 
  end  
  #--------------------------------------------------------------------------
  # * Dispose
  #--------------------------------------------------------------------------
  alias dispose_eventname dispose
  def dispose
    @eventname.each {|i| i.dispose if !i.nil?}
    dispose_eventname
  end
end
#--------------------------------------------------------------------------
# SDK Check End
#--------------------------------------------------------------------------
end 
#--------------------------------------------------------------------------
# END OF SCRIPT
#--------------------------------------------------------------------------
zum Lesen den Text mit der Maus markieren

Zego

Krieger

Motto: Ein gesunder Mensch hat 1000 Wünsche, doch ein kranker nur einen!

  • Nachricht senden

2

Samstag, 2. Februar 2013, 10:32

Hm mal übers Script geguckt, habe ich dort gefunden:

Ruby Quellcode

1
SWITCH      = 50               # Switch for Disable Show Event Name
Zeile 44
Das sollte also schon gelöst sein!?

Edit Für das andere musste auf die Profis warten, da kann ich dir leider nicht helfen ;)
  • :music: Bushido

    Bild
  • :balloon-smiley: Lustige Zitate

    • :thumb-up: Zitat 1
      <Noone> Kann mir vielleicht jemand bei ner Deutschhausaufgabe helfen? Komm damit nicht zurecht :/
      <Siegertyp> Ja aber beeil dich, ich muss gleich los. Ich kann dir nur eine Frage beantworten.
      <Noone> Nur eine?
      <Siegertyp> Ja
      * Siegertyp has quit IRC (quit)
    • :thumb-up: Zitat 2
      <fusion> Hast du ein paar Nacktfotos deiner Freundin?
      <chrzan> nö :/
      <fusion> Willst du welche haben? :>
    • :thumb-up: Zitat 3
      <MMM> Ich glaub ich lache nie wieder so laut...göttlich heute morgen in Bio. wir haben jeweils unseren eigenen speichel mikroskopiert. Auf einmal die eine ganz aufgeregt "Hier bewegt sich was!!" Alle werden still, Prof guckt sich das kurz an, guckt nochmal hin "Oh, ja das ist definitv eine lebende Spermazelle" Ich glaub das Mädchen wäre am liebsten gestorben ;)
    • :thumb-up: Zitat 4
      <Wretched> Religionskriege sind Konflikte zwischen erwachsenen Menschen, bei denen es darum geht, wer den cooleren, imaginaeren Freund hat
      <D3nY0> looool :D wie geil
    • :thumb-up: Zitat 5
      <HDStyle> Ist dir schonmal aufgefallen, dass irgendwie nie Amokläufe an Hauptschulen stattfinden? o.o
      <Crytek> Ja ist klar. Da schießen ja auch alle zurück.
    • :thumb-up: Zitat 6
      <RAP|TaliFecT> Meine Freundin meint ich wäre neugierig ... zumindestens steht das in ihrem Tagebuch

3

Samstag, 2. Februar 2013, 10:37

Vielen Dank...

Zitat von »mir«

Außerdem soll per Callscript der Name eines bestimmten Events nicht mehr angezeigt werden, wenn es eine neue Eventseite erreicht hat.

4

Samstag, 2. Februar 2013, 15:15

Hey.

Also ich denke so läuft es sehr komfortabel.
Wenn du willst, dass der Name bei einer bestimmten aktiven Eventseite nicht angezeigt wird, schreibst an die erste Position der Kommandliste ein Comment mit "noName".

Hier die kleine Modifikation dazu:
Die attr_reader kannst direkt in die entsprechenden Klassen eintragen

Ruby Quellcode

1
2
3
class Game_Event < Game_Character
  attr_reader   :event
end

Ruby Quellcode

1
2
3
class Game_Event < Game_Character
  attr_reader   :page
end

Füge das hier ganz oben in update_event_name ein:

Ruby Quellcode

1
2
3
4
5
6
# Hide name if a comment at the very top of active event page says "noName"
    if hideNameEventSite
      @name_event.opacity = 0
      return
    end
    # Go on...

Und diese Methode setzt du drunter:

Ruby Quellcode

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
  #--------------------------------------------------------------------------
  # * Check if a comment at the very top of active event page says "noName"
  #--------------------------------------------------------------------------
  def hideNameEventSite
    if @character != $game_player
      if @character.event != nil
        checknote = @character.page.list[0]
        # Check if the first line is a comment
        if checknote.code == 108
          # Check the first comment line for string "noName"
          firstline = checknote.parameters[0]
          if firstline[/noName/] != nil
            return true
          end
        end
      end
    end
    return false
  end


Sag mir, wenn es so nicht (zu deiner Zufriedenheit) klappt.

LG ~DeadJack 8)

Dieser Beitrag wurde bereits 1 mal editiert, zuletzt von »Dead Jack« (2. Februar 2013, 15:15)


5

Samstag, 2. Februar 2013, 15:24

Hey,
Klappt perfekt. Habe zwar anfangs verstanden erstmal das hier reinschreiben:

Ruby Quellcode

1
2
3
4
    if hideNameEventSite
      @name_event.opacity = 0
      return
    end

und dadrunter die Method, aber das hat dann nicht geklappt. Als ich die beiden Codes vertauscht habe, hats dann geklappt. Vielen Dank! :)

Edit Kann geclosed werden, bevor noch weitere hier reinschreiben ;)

6

Samstag, 2. Februar 2013, 15:43

Hey,

hätte nur einen kleinen Verbesserungsvorschlag, nämlich würde ich dir aus Performancegründen und der "Sauberkeit" wegen raten die Überprüfung nur beim Laden der Eventpage durchzuführen. Also sprich:

Ruby Quellcode

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
class Game_Event < Game_Character
 
  attr_reader :hide_name
 
  alias init_later initialize
  def initialize(map_id,event)
    @hide_name = false
    init_later
  end
 
  alias refresh_later refresh
  def refresh
    refresh_later
    checknote = @page.list[0]
    # Check if the first line is a comment
    @hide_name = false
    if checknote.code == 108
      # Check the first comment line for string "noName"
      firstline = checknote.parameters[0]
      if firstline[/noName/] != nil
        @hide_name = true
      end
    end
  end
 
end


Dann muss noch der folgen Code ganz an den Schluss der "def refresh"-methode vom Game_Event, sofern du kein Script hast was die überschreibt wie z.B. das XAS ist das unter "Game_Event" zu finden:

Dann passt du die "hideNameEventSite"-Methode an:

Ruby Quellcode

1
2
3
4
5
6
7
  def hideNameEventSite
    if @character.is_a?(Game_Event)
      return @character.hide_name
    else
      return false
     end
  end


Vorteil ist halt dass die eigentlich Überprüfung nun nur noch beim Wechseln der Event-Page durchgeführt wird, außerdem sollte die Sprite-Klasse selber sowas nicht verwalten. Die attr_reader kannst du dir dann auch schenken :)

EDIT: Ging sogar noch nen Stück leichter^^
Terranigma 2 - Episode I - Open Beta out now!

RPC - Rpg-Maker Community Platform - Spielübergreifende Erfolge und mehr!

7

Samstag, 2. Februar 2013, 16:08

@The King: Kannst du bitte mal das komplette Script posten? Ich bin gerade ein wenig verwirrt, da bei deiner Lösung nur Fehler auftauchen. Wäre deshalb echt nett, wenn du das fertige Script posten würdest.

8

Samstag, 2. Februar 2013, 16:12

Argh, ich mach immer denselben Fehler -.-

Ruby Quellcode

1
2
3
4
def initialize(map_id,event)
    @hide_name = false
    init_later
  end


ändere das in


Ruby Quellcode

1
2
3
4
def initialize(map_id,event)
    @hide_name = false
    init_later(map_id,event)
  end


Gehts jetzt? Ansonsten gibts nicht viel mehr zu posten, der Rest müsste gehen^^
Terranigma 2 - Episode I - Open Beta out now!

RPC - Rpg-Maker Community Platform - Spielübergreifende Erfolge und mehr!

9

Samstag, 2. Februar 2013, 16:18

Nein klappt nicht. Ich weiß auch nicht wohin ich die Method kopieren soll. Deshalb meinte ich, dass es sinnvoller wäre, wenn du das fertige Script zeigen kannst.

10

Samstag, 2. Februar 2013, 16:25

Ok, dann mal alles auf einmal:
Spoiler

Ruby Quellcode

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
#:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:
# [Xp/Vx] Show Event Name
# Version: 4.20
# Author : LiTTleDRAgo 
#:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:
#
# Explanation:
#
#   - This script shows event name in map
#
# Instructions:
#
#   - Setup the few configurations below.   
#
#
#   - Insert the event name
#     <Name=X>       X = Name showed in map
#     <SizeX>        X = Size the font
#     <Bold>         Toggle Bold
#     <Italic>       Toggle Italic
#     <Font[X]>      X = Font name
#     <ColorX,X,X,X> X,X,X,X = Color the font(in RGB)
#
#   - Or use call script to show the event name
#     
#     $game_map.events[2].show_name = x
#     $game_player.show_name = x
#
#     where x is a string
#
#   That's all
#
#  Press Z and C together to turn on the name on / off
#
#:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:
 
module EventName
 
  FONT        = ['Georgia',16]   # Font Name and Font Size
 
  BOLD        = true             # Toggle Bold
  ITALIC      = true             # Toggle Italic
 
  SWITCH      = 50               # Switch for Disable Show Event Name
  PRESS_BTN   = [Input::A,       # (Z Keyboard XP) (Shift Keyboard VX)
                 Input::C]       # (C/Enter Keyboard XP) (Z/Enter Keyboard VX)
 
  COLOR       = Color.new(255,255,255,255) # Color Default
  POSITION    = "A"                  # A = Above, B = Below
  RANGE       = 2                    # Range from character to show the name
 
  USEPICT     = nil       # Show background for event name (in folder Pictures)
                          # leave nil if you don't want to
 
end
 
 
 
 
if true
#==============================================================================
# ** Sprite_EventName
#------------------------------------------------------------------------------
#  This sprite is used to display Event Name. It observes a instance of the
# Game_Character class and automatically changes sprite conditions.
#==============================================================================
class Sprite_EventName < RPG::Sprite
 
  FONT          = EventName::FONT
  BOLD          = EventName::BOLD
  ITALIC        = EventName::ITALIC
  DIS_EV_SWITCH = EventName::SWITCH
  PRESS_BTN     = EventName::PRESS_BTN
  COLOR         = EventName::COLOR
  POS           = EventName::POSITION 
  RANGE         = EventName::RANGE
  USEPICT       = EventName::USEPICT
  #--------------------------------------------------------------------------
  # * Public Instance Variables
  #--------------------------------------------------------------------------
  attr_accessor :character
  #--------------------------------------------------------------------------
  # * Object Initialization
  #     viewport  : viewport
  #     character : character (Game_Character)
  #--------------------------------------------------------------------------
  def initialize(v,character)
    super(v)
    @character = character
    @character.load_name
    @name_event = Sprite.new
    @name_event.bitmap = Bitmap.new(200,280)
    if USEPICT
      @back = Sprite.new
      @back.bitmap = RPG::Cache.picture(USEPICT)
      @back.visible = false
    end
    @name_event.visible = true
    refresh_name
    update
  end
  #--------------------------------------------------------------------------
  # * Coloring
  #--------------------------------------------------------------------------
  def coloring
    size, name, bold, italic, color = FONT[1], FONT[0], BOLD, ITALIC, COLOR 
    size   = @character.fontsize if @character.fontsize
    bold   = @character.bold 
    italic = @character.italic
    color  = @character.color if @character.color
    name   = @character.font if @character.font
      if $xrxs_xas
        @char.gsub!(/<Enemy(\d+)>/i) do color = Color.new(255,0,0,240) end
      elsif $BlizzABS && @character.is_a?(Map_Battler)
        case @character.ai.group
        when 1 then color = Color.new(0  , 0  , 255, 240)
        when 2 then color = Color.new(255, 0  , 0  , 240)
        when 3 then color = Color.new(128, 128, 128, 240)
        when 4 then color = Color.new(128, 128, 128, 240)
        when 5 then color = Color.new(255, 255, 0  , 240)
        when 6 then color = Color.new(0  , 255, 0  , 240)
        end
      end
      @char.gsub!(/<Size(\d+)>/)      do size   = $1.to_i  end
      @char.gsub!(/<Bold>/i)          do bold   = true     end
      @char.gsub!(/<Italic>/i)        do italic = true     end
      @char.gsub!(/<Font\[(.*?)\]>/) do name   = $1.to_s  end
      @char.gsub!(/<Color(\d+),(\d+),(\d+),(\d+)>/) do
        color = Color.new($1.to_i,$2.to_i,$3.to_i,$4.to_i) end 
    @name_event.bitmap.font.name   = name
    @name_event.bitmap.font.bold   = bold
    @name_event.bitmap.font.italic = italic
    @name_event.bitmap.font.size   = size
    @name_event.bitmap.font.color  = color
  end
  #--------------------------------------------------------------------------
  # * Check Name
  #--------------------------------------------------------------------------
  def event_name_check
    @char.gsub!(/<V([0-9]+)>/){ $game_variables[$1.to_i] }
    @char.gsub!(/<A([0-9]+)>/){ !$game_actors[$1.to_i].nil? ? 
                                $game_actors[$1.to_i].name : ''}
    @char.gsub!(/<Size(\d+)>/)    {''}
    @char.gsub!(/<Bold>/i)        {''}
    @char.gsub!(/<Italic>/i)      {''}
    @char.gsub!(/<Font\[(.*?)\]>/){''}
    @char.gsub!(/<Color(\d+),(\d+),(\d+),(\d+)>/) {''}
    @char.gsub!(/<Enemy(\d+)>/i) { !$data_enemies[$1.to_i].nil? ? 
                                    $data_enemies[$1.to_i].name : ''}
    @char.gsub!(/<\[(.*?)\]>/) do @char = $1.to_s end
  end
  #--------------------------------------------------------------------------
  # * Update
  #--------------------------------------------------------------------------
  def update
    super
    if @show_name != @character.show_name 
      @show_name = @character.show_name
      refresh_name 
    end
    update_event_name
    update_back
  end
 
  #--------------------------------------------------------------------------
  # * Refresh
  #--------------------------------------------------------------------------
  def refresh_name 
    return if @name_event.nil? or @name_event.bitmap.nil? or 
      @name_event.disposed? or !@name_event.visible or 
      @character.show_name.nil? or @show_name.nil?
    @name_event.bitmap.clear
    @show_name.each {|@char|  coloring; event_name_check  }
    draw_name
    conf_position
  end
  #--------------------------------------------------------------------------
  # * Conf Position
  #--------------------------------------------------------------------------
  def conf_position
    @x_frame, @y_frame = 4, 4 
    if POS == "A"
      bit = RPG::Cache.character(@character.character_name,
          @character.character_hue)
      @cw = ((bit.width / @x_frame) + @char.length)/2
      @ch = bit.height / @y_frame + 15
      if $xrxs_xas
        @cw = ((@name_event.bitmap.width / @x_frame) + @char.length)/2
        @ch = @name_event.bitmap.height / @y_frame - 5
      end
      @ch += 5 if USEPICT
    else
      @cw = @name_event.bitmap.width / @x_frame / 2
      @ch = @name_event.bitmap.height / @y_frame - 40
    end
  end
  #--------------------------------------------------------------------------
  # * Draw Name
  #--------------------------------------------------------------------------
  def draw_name
    if defined? Bitmap.draw_hemming_text
      @name_event.bitmap.draw_hemming_text(0, 0, 100, 20, @char ,4)
    else
      @name_event.bitmap.draw_text(0, 0, 100, 20, @char ,4)
    end
  end
  #--------------------------------------------------------------------------
  # * Dispose
  #--------------------------------------------------------------------------
  def dispose
    super
    [@name_event, @back].each {|i| i.dispose if !i.nil? && !i.disposed? }
  end
  #--------------------------------------------------------------------------
  # * Visibility
  #--------------------------------------------------------------------------
  def visibility
    pressed = Input.press?(PRESS_BTN[0]) && Input.trigger?(PRESS_BTN[1])
    if RANGE != nil && !@pressed
      x = ($game_player.x-@character.x).abs+($game_player.y-@character.y).abs
      @name_event.visible = (x <= RANGE)
    end
    if !@pressed && pressed
      @name_event.visible, @pressed = false, true
    elsif @pressed && pressed
      @name_event.visible, @pressed = true, false
    end
  end  
  #--------------------------------------------------------------------------
  # * Update Event Name
  #--------------------------------------------------------------------------
  def update_event_name 
    if hideNameEventSite
      @name_event.opacity = 0
      return
    end
    return @name_event.visible = false if !DIS_EV_SWITCH.nil? and
       (@character.opacity < 50 or $game_switches[DIS_EV_SWITCH])
    visibility if !PRESS_BTN.nil?
    if @name_event.visible 
      @name_event.x = @character.screen_x - (@cw.nil? ? 0 : @cw)
      @name_event.y = @character.screen_y - (POS == 'A' ? @ch.nil? ? 0 : @ch : 0)
 
      @name_event.z = 1 
      @name_event.opacity    = @character.opacity
      @name_event.blend_type = @character.blend_type
      @name_event.bush_depth = @character.bush_depth
    end
  end
 
  def hideNameEventSite
    if @character.is_a?(Game_Event)
      return @character.hide_name
    else
      return false
     end
  end
  #--------------------------------------------------------------------------
  # * Update Back
  #--------------------------------------------------------------------------
  def update_back
    return if !USEPICT
    @back.visible = @name_event.visible && !@char.nil? && 
      !@char.empty? && @char != ' '
    if @back.visible
      @back.opacity = @name_event.opacity - 100
      @back.x = @name_event.x - 5
      @back.y = @name_event.y - 5
      @back.z = @name_event.z - 1 
    end
  end
end
 
#==============================================================================
# ** Game_Character 
#------------------------------------------------------------------------------
#  This class deals with characters. It's used as a superclass for the
#  Game_Player and Game_Event classes.
#==============================================================================
class Game_Character
  #--------------------------------------------------------------------------
  # * Public Instance Variables
  #--------------------------------------------------------------------------
  attr_accessor :show_name,:fontsize,:bold,:italic,:font,:color
  #--------------------------------------------------------------------------
  # * Show Name
  #--------------------------------------------------------------------------
  def show_name=(v= ' ')
    @show_name=v
    record_name
  end
  #--------------------------------------------------------------------------
  # * Record Name
  #--------------------------------------------------------------------------
  def record_name
    if self == $game_player
      $game_system.player_name = @show_name
    end
  end
  #--------------------------------------------------------------------------
  # * Load Name
  #--------------------------------------------------------------------------
  def load_name
    if self == $game_player
      if !$game_system.player_name.nil?
        @show_name = $game_system.player_name
      end
    end
  end
  #--------------------------------------------------------------------------
  # * Clear Name
  #--------------------------------------------------------------------------
  def clear_name
    @show_name = ' '
    if self == $game_player
      $game_system.player_name = @show_name
    end
  end
  #--------------------------------------------------------------------------
  # * Clear every Name
  #--------------------------------------------------------------------------
  def clear_every_name
    $game_system.record_name = {}
    $game_system.player_name = nil
  end
end
 
#==============================================================================
# ** Game_Event
#------------------------------------------------------------------------------
#  This class deals with events. It handles functions including event page 
#  switching via condition determinants, and running parallel process events.
#  It's used within the Game_Map class.
#==============================================================================
class Game_Event < Game_Character
  #--------------------------------------------------------------------------
  # * Alias listing
  #--------------------------------------------------------------------------
  alias erase_show_name erase
  alias init_event_name initialize
  #--------------------------------------------------------------------------
  # * Public Instance Variables
  #--------------------------------------------------------------------------
  attr_reader   :event
  #--------------------------------------------------------------------------
  # * Object Initialization
  #--------------------------------------------------------------------------
  def initialize(map_id, event)
    if event.name =~ /<Name=(.*?)>/i
      @show_name = $1.to_s
    end
    if event.name =~ /<Size(\d+)>/i
      @fontsize = $1.to_i
    end
    @bold   = event.name =~ /<Bold>/i
    @italic = event.name =~ /<Italic>/i
    if event.name =~ /<Font\[(.*?)\]>/i
      @font = $1.to_s
    end
    if event.name =~ /<Color(\d+),(\d+),(\d+),(\d+)>/
      @color = Color.new($1.to_i,$2.to_i,$3.to_i,$4.to_i)
    end
    init_event_name(map_id, event)
  end
  #--------------------------------------------------------------------------
  # * Record Name
  #--------------------------------------------------------------------------
  def record_name
    key = [@map_id, @event.id]
    clear_every_name if  $game_system.record_name.nil?
    $game_system.record_name[key]=[@show_name]
  end
  #--------------------------------------------------------------------------
  # * Load Name
  #--------------------------------------------------------------------------
  def load_name
    key = [@map_id, @event.id]
    clear_every_name if  $game_system.record_name.nil?
    if $game_system.record_name[key] != nil
      @show_name=$game_system.record_name[key][0]
    end
  end
  #--------------------------------------------------------------------------
  # * Clear Name
  #--------------------------------------------------------------------------
  def clear_name
    super
    key = [@map_id, @event.id]
    if $game_system.record_name[key] != nil
      $game_system.record_name[key] = nil
    end
  end
  #--------------------------------------------------------------------------
  # * Temporarily Erase
  #--------------------------------------------------------------------------
  def erase
    clear_name
    erase_show_name
  end
end
 
#==============================================================================
# ** Game_Map
#------------------------------------------------------------------------------
#  This class handles the map. It includes scrolling and passable determining
#  functions. Refer to "$game_map" for the instance of this class.
#==============================================================================
class Game_Map
  #--------------------------------------------------------------------------
  # * Alias listing
  #--------------------------------------------------------------------------
  alias setup_record setup
  #--------------------------------------------------------------------------
  # * Setup
  #     map_id : map ID
  #--------------------------------------------------------------------------
  def setup(map_id)
    setup_record (map_id)
    @map.events.keys.each {|i| @events[i].load_name if !events[i].nil?}
  end
end
 
#==============================================================================
# ** Game_System
#------------------------------------------------------------------------------
#  This class handles data surrounding the system. Backround music, etc.
#  is managed here as well. Refer to "$game_system" for the instance of 
#  this class.
#==============================================================================
class Game_System
  #--------------------------------------------------------------------------
  # * Public Instance Variables
  #--------------------------------------------------------------------------
  attr_accessor :player_name, :record_name
end
 
#==============================================================================
# ** Kernel
#==============================================================================
module Kernel; def rpgvx?() (defined? Graphics.resize_screen) end  end
Cache = RPG::Cache if !defined? Cache
 
#==============================================================================
# ** Spriteset_Map
#------------------------------------------------------------------------------
#  This class brings together map screen sprites, tilemaps, etc. It's used
# within the Scene_Map class.
#==============================================================================
class Spriteset_Map
 
  PRESS_BTN     = EventName::PRESS_BTN
  #--------------------------------------------------------------------------
  # * Public Instance Variables
  #--------------------------------------------------------------------------
  attr_accessor :eventname
  #--------------------------------------------------------------------------
  # * Main Processing
  #--------------------------------------------------------------------------
  def init_eventname
    @eventname = []
    @eventname[0] = Sprite_EventName.new(@viewport1,$game_player)  
    ($game_map.events.keys.sort).each {|i|
      @eventname[i] = Sprite_EventName.new(@viewport1,$game_map.events[i])}
  end
  #--------------------------------------------------------------------------
  # * Frame Update
  #--------------------------------------------------------------------------
  alias update_eventname_earlier update
  def update
    @eventname.nil? ? init_eventname : @eventname.each {|i|i.update if !i.nil?} 
    update_eventname_earlier 
  end  
  #--------------------------------------------------------------------------
  # * Dispose
  #--------------------------------------------------------------------------
  alias dispose_eventname dispose
  def dispose
    @eventname.each {|i| i.dispose if !i.nil?}
    dispose_eventname
  end
end
#--------------------------------------------------------------------------
# SDK Check End
#--------------------------------------------------------------------------
end 
#--------------------------------------------------------------------------
# END OF SCRIPT
#--------------------------------------------------------------------------
 
class Game_Event < Game_Character
 
  attr_reader :hide_name
 
  alias init_later initialize
  def initialize(map_id,event)
    @hide_name = false
    init_later(map_id,event)
  end
 
  alias refresh_later refresh
  def refresh
    refresh_later
    checknote = @page.list[0]
    # Check if the first line is a comment
    @hide_name = false
    if checknote.code == 108
      # Check the first comment line for string "noName"
      firstline = checknote.parameters[0]
      if firstline[/noName/] != nil
        @hide_name = true
      end
    end
  end
 
end
zum Lesen den Text mit der Maus markieren


Hättest die Klasse, also was im Script ganz unten steht einfach nur in ein leeres Script über main einfügen müssen, den Rest dahin editieren wo du eh schon die methoden hattest, und im letzten Post von mir hättest du nur aus meinem Script die Methode ersetzen müssen ;)
Terranigma 2 - Episode I - Open Beta out now!

RPC - Rpg-Maker Community Platform - Spielübergreifende Erfolge und mehr!

Social Bookmarks