Night.png);">
Apprendre


Vous êtes
nouveau sur
Oniromancie?

Visite guidée
du site


Découvrir
RPG Maker

RM 95
RM 2000/2003
RM XP
RM VX/VX Ace
RM MV/MZ

Apprendre
RPG Maker

Tutoriels
Guides
Making-of

Dans le
Forum

Section Entraide

Tutos: Checklist de la composition (...) / Sorties: Dread Mac Farlane - episode 8 / Sorties: Dread Mac Farlane - episode 7 / Jeux: Ce qui vit Dessous / News: Quoi de neuf sur Oniromancie (...) / Chat

Bienvenue
visiteur !




publicité RPG Maker!

Statistiques

Liste des
membres


Contact

Mentions légales

459 connectés actuellement

29381482 visiteurs
depuis l'ouverture

5 visiteurs
aujourd'hui



Barre de séparation

Partenaires

Indiexpo

Akademiya RPG Maker

Blog Alioune Fall

Fairy Tail Constellations

ConsoleFun

Le Temple de Valor

RPG Fusion

Lumen

Tous nos partenaires

Devenir
partenaire



forums

Index du forum > Entraide > [RESOLU] [RPG Maker XP] Script de timer avancé


Voximilien - posté le 15/03/2017 à 01:48:20 (128 messages postés)

❤ 0

Domaine concerné: Script
Logiciel utilisé: RPG Maker XP
Salut !

Je suis à la recherche d'un script depuis un moment pour la version XP de RPG Maker. Le timer est quelque peu limité et avoir plus d'options serait un gros plus.

J'ai déjà trouvé des scripts plus ou moins avancés pour les versions VX Ace et MV, mais pas grand chose de très folichon pour XP.

Je m'explique. Ce que j'essaye d'avoir dans ce script, ce sont des options où on peut :
• Figer/défiger le minuteur (avec une option qui permet de laisser afficher le minuteur quand il est en pause),
• Avoir la possibilité de mettre les millisecondes et que le décompte soit fluide,
• Ajouter/enlever X temps sans forcément réinitialiser le minuteur à chaque fois,
• Avoir la possibilité d'attribuer une image de fond pour le minuteur qui change d'opacité (en même temps que le minuteur) quand le joueur passe sur le même coin de l'écran pour plus de lisibilité.

(Les millisecondes c'est le truc bonus, tant pis si ça ne marche pas pour XP.)

Est-ce qu'un tel script existe pour XP ? Est-ce qu'un script avec ces options est réalisable pour la version XP ou est-ce que le RGSS1 est trop faible pour gérer ça ?


Voici ce que j'ai trouvé pour les versions VX Ace et MV.
VX Ace :

Portion de code : Tout sélectionner

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
#------------------------------------------------------------------------------#
#  Galv's Variable Timer Functions
#------------------------------------------------------------------------------#
#  For: RPGMAKER VX ACE
#  Version 1.2
#------------------------------------------------------------------------------#
#  2012-10-24 - Version 1.2 - updated alias names for compatibility
#  2012-09-28 - Version 1.1 - Timer sprites now dispose when invisible.
#                             (thanks to Falcao's advice to do so)
#  2012-09-28 - Version 1.0 - release
#------------------------------------------------------------------------------#
#
#  This script allows a bit more control over the timer and how it looks
#  - Use a custom graphic for the timer
#  - Change font, text size and colour of numbers
#  - Variable speed that can count up or down
#  - Additional script calls for functionality (see below)
#
#
#  The below can be used in event script calls.
#------------------------------------------------------------------------------#
#  To freeze the timer:
#  $game_timer.freeze
#------------------------------------------------------------------------------#
#  To unfreeze the timer:
#  $game_timer.unfreeze
#------------------------------------------------------------------------------#
#  To increase time (x is number of seconds):
#  $game_timer.increase(x)
#------------------------------------------------------------------------------#
#  To decrease time (x is number of seconds):
#  $game_timer.decrease(x)
#------------------------------------------------------------------------------#
#  To set timer to equal a variable (y is variable ID to use):
#  $game_timer.set(y)
#------------------------------------------------------------------------------#
#  To increase timer by a variable (y is variable ID to use):
#  $game_timer.increase_var(y)
#------------------------------------------------------------------------------#
#  To decrease timer by a variable (y is variable ID to use):
#  $game_timer.decrease_var(y)
#------------------------------------------------------------------------------#
#
#  Event commands for the timer still work.
#  eg. (start, stop, conditional branch, set variable to timer)
#
#------------------------------------------------------------------------------#
 
#------------------------------------------------------------------------------#  
#  !!!!! WARNING - I am a learning scripter. Use this at your own risk!!!!!!
#------------------------------------------------------------------------------#
 
$imported = {} if $imported.nil?
$imported["Variable_Timer"] = true
 
module Variable_Timer
 
#------------------------------------------------------------------------------#
#  SCRIPT SETUP OPTIONS
#------------------------------------------------------------------------------#
 
  TIME_SPEED_VAR = 1    # The ID of the variable that sets the timer speed.
                        # Change this variable in-game to the speed per second.
                        # Negatives count down, positives count up. 0 pauses.
 
  HIDE_TIMER_SWITCH = 1       # Switch ID to turn on/off the timer visibility.
 
  ABORT_BATTLE = false        # When timer reached 0 in battle it would abort 
                              # the combat. Choose if that's true or false.
   
 
  TIMER_GRAPHIC = "timer"     # Graphic in /Graphics/System folder to use.
                              # put "" If you don't want a graphic.
 
  TIMER_FONT = "Arial"        # Font of timer numbers. Make it "" for default.
 
  TEXT_SIZE = 28              # Size of timer numbers.
 
  R = 0                       # Colour of numbers using RGB values
  G = 255                     # (red, green, blue)
  B = 0
 
#------------------------------------------------------------------------------#
#  END SCRIPT SETUP OPTIONS
#------------------------------------------------------------------------------#
 
end
 
class Game_Timer
 
  #--------------------------------------------------------------------------
  # * OVERWRITE Update
  #--------------------------------------------------------------------------
  def update
    return if @freeze_time
    if @working && @count > 0
        @count += $game_variables[Variable_Timer::TIME_SPEED_VAR]
      on_expire if @count == 0 && Variable_Timer::ABORT_BATTLE
    end
    if @working && @count < 0
      @count = 0
    end
  end
   
  def freeze
    @freeze_time = true
  end
 
  def unfreeze
    @freeze_time = false
  end
   
  def increase(time)
    @count += time * Graphics.frame_rate
  end
 
  def decrease(time)
    @count -= time * Graphics.frame_rate
  end
   
  def set(var)
    @count = $game_variables[var] * Graphics.frame_rate
  end
   
  def increase_var(var)
    @count += $game_variables[var] * Graphics.frame_rate
  end
   
  def decrease_var(var)
    @count -= $game_variables[var] * Graphics.frame_rate
  end
 
end # Game_Timer
 
 
class Sprite_Timer < Sprite
 
  alias galv_vartimer_dispose dispose
  def dispose
    @timer_sprite.dispose if !@timer_sprite.nil?
    galv_vartimer_dispose
  end
 
  def create_timer_sprite
    @timer_sprite = Sprite.new
    @timer_sprite.bitmap = Cache.system(Variable_Timer::TIMER_GRAPHIC)
    @timer_sprite.opacity = 255
    @timer_sprite.x = Graphics.width - @timer_sprite.bitmap.width
  end
   
  alias galv_vartimer_create_bitmap create_bitmap
  def create_bitmap
    galv_vartimer_create_bitmap
    self.bitmap.font.name = Variable_Timer::TIMER_FONT unless Variable_Timer::TIMER_FONT == ""
    self.bitmap.font.size = Variable_Timer::TEXT_SIZE
    self.bitmap.font.color.set(Variable_Timer::R, Variable_Timer::G, Variable_Timer::B)
  end
 
  alias galv_vartimer_update_visibility update_visibility
  def update_visibility
    galv_vartimer_update_visibility
    if $game_timer.working? && !$game_switches[Variable_Timer::HIDE_TIMER_SWITCH]
      create_timer_sprite if @timer_sprite.nil? || @timer_sprite.disposed?
    else
      @timer_sprite.dispose if !@timer_sprite.nil?
      self.visible = false
    end
  end
   
end # Sprite_Timer < Sprite



MV :


(Je sais que MV est en Java et que c'est différent de VX et XP.)

Portion de code : Tout sélectionner

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
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
/*:
 * @plugindesc Gives developers move control over the visual and mechanical aspects of the game's timer system.
 * @author SumRndmDde
 *
 * @param Timer Format
 * @desc The format of the timer text. Use the following codes:
 *   %1 - hours | %2 - minutes | %3 - seconds | %4 - frames
 * @default %2:%3:%4
 *
 * @param Timer Position
 * @desc The position of the timer.            TOP-L  TOP  TOP-R
 * Use the following position codes.     BOT-L  BOT  BOT-R
 * @default TOP
 *
 * @param Timer Start SE
 * @desc The sound effect played when a timer starts. Leave blank to disallow. Use the format: file, volume, pitch, pan
 * @default
 *
 * @param Timer Expire SE
 * @desc The sound effect played when a timer expires. Leave blank to disallow. Use the format: file, volume, pitch, pan
 * @default Bell3, 80, 100, 0
 *
 * @param Pause Color
 * @desc This is the color of the text when the timer is paused.
 * @default #FFFF00
 *
 * @param Use Background
 * @desc If 'true', a subtle background will be used for the timer to help it become more readable.
 * @default true
 *
 * @param == Auto Settings ==
 * @default
 *
 * @param Use Auto-Stop
 * @desc If 'true', then the timer will automatically stop itself and leave the screen when finished.
 * @default true
 *
 * @param Use Auto-Pause
 * @desc If 'true', then the timer will automatically pause while events are running.
 * @default true
 *
 * @param Auto-Pause Opacity
 * @desc This is the opacity of the timer during automatic pausing.
 * @default 120
 *
 * @param Use Auto-Abort
 * @desc If 'true', then battles will be automatically aborted when the timer ends.
 * @default true
 *
 * @param == Label Settings ==
 * @default
 *
 * @param Default Label
 * @desc This is the text of the label by default. Leave blank to use no label.
 * @default
 *
 * @param Label Font Size
 * @desc The font size of the text used for the label.
 * @default 22
 *
 * @param == Font Settings ==
 * @default
 *
 * @param Timer Font
 * @desc The font used for the timer's text.
 * @default GameFont
 *
 * @param Timer Font Size
 * @desc The size of the font used for the timer.
 * @default 32
 *
 * @param Timer Italic
 * @desc If 'true', then the timer's text will be italicized.
 * @default false
 *
 * @param Timer Text Color
 * @desc The color of the timer's text.
 * @default #ffffff
 *
 * @param Timer Outline Color
 * @desc The color of the timer's outline.
 * @default rgba(0, 0, 0, 0.5)
 *
 * @help
 *
 * Timer Upgrade
 * Version 1.01
 * SumRndmDde
 *
 *
 * This plugin gives developers move control over the visual and mechanical 
 * aspects of the game's timer system.
 *
 *
 * ==============================================================================
 *  Plugin Commands
 * ==============================================================================
 *
 * The following Plugin Commands can be used to manipulate the extra mechanics
 * of the upgraded timer:
 *
 *
 *
 *   SetTimer [frames] [seconds] [minutes] [hours]
 *
 * Using this command, the frames, seconds, minutes, and hours can be set on the
 * game timer. This allows users to surpass the default settings for the MV
 * engine and specify the count down to frames.
 *
 * For example, if you wish to set the timer to 3 minutes, you would do:
 *   SetTimer 0 0 3 0
 *
 * If you wished to set the timer to 30 frames and 60 seconds, do:
 *   SetTimer 30 60 0 0
 *
 *
 *
 *   AddTimer [frames] [seconds] [minutes] [hours]
 *
 * Using this command, frames, seconds, minutes, and hours can be added to the 
 * game timer. Instead of replacing the timer value, this command adds to the 
 * current value.
 *
 * For example, if you wanted to add 5 minutes to the timer, you would do:
 *   AddTimer 0 0 5 0
 *
 * If you wanted to add 30 frames and 1 hour, you would do:
 *   AddTimer 30 0 0 1
 *
 *
 *
 *   PauseTimer
 *
 * Using this command, the timer can be paused. This keeps the timer at its
 * current position until unpaused or restarted.
 *
 *
 *
 *   UnpauseTimer
 *
 * Using this command, the timer can be unpaused. This will let the timer 
 * continue from when it was paused.
 *
 *
 *
 *   SetExpireCommonEvent [id]
 *
 * Using this command, the expire Common Event can be set up. This is a Common
 * Event that will automatically play once the Timer ends. Once the Common
 * Event has been played, it will no longer be the expire Common Event.
 *
 *
 *
 *   SetTimerLabel [text]
 *
 * This command allows you to change the timer label in the middle of the game.
 * Setting this to blank would remove the label.
 *
 *
 * ==============================================================================
 *  End of Help File
 * ==============================================================================
 * 
 * Welcome to the bottom of the Help file.
 *
 *
 * Thanks for reading!
 * If you have questions, or if you enjoyed this Plugin, please check
 * out my YouTube channel!
 *
 * https://www.youtube.com/c/SumRndmDde
 *
 *
 * Until next time,
 *   ~ SumRndmDde
 */
 
var SRD = SRD || {};
SRD.TimerUpgrade = SRD.TimerUpgrade || {};
SRD.PluginCommands = SRD.PluginCommands || {};
 
var Imported = Imported || {};
Imported["SumRndmDde Timer Upgrade"] = 1.01;
 
(function(_, $) {
 
"use strict";
 
//-----------------------------------------------------------------------------
// SRD.TimerUpgrade
//-----------------------------------------------------------------------------
 
const params = PluginManager.parameters('SRD_TimerUpgrade');
 
_.format = String(params['Timer Format']);
_.pos = String(params['Timer Position']);
_.start = String(params['Timer Start SE']);
_.stop = String(params['Timer Expire SE']);
_.pauseColor = String(params['Pause Color']);
_.back = String(params['Use Background']).trim().toLowerCase() === 'true';
 
_.autoStop = String(params['Use Auto-Stop']).trim().toLowerCase() === 'true';
_.autoPause = String(params['Use Auto-Pause']).trim().toLowerCase() === 'true';
_.autoOpacity = parseInt(params['Auto-Pause Opacity']);
_.abort = String(params['Use Auto-Abort']).trim().toLowerCase() === 'true';
 
_.default = String(params['Default Label']);
_.labelSize = parseInt(params['Label Font Size']);
 
_.font = String(params['Timer Font']);
_.size = parseInt(params['Timer Font Size']);
_.italic = String(params['Timer Italic']).trim().toLowerCase() === 'true';
_.color = String(params['Timer Text Color']);
_.outline = String(params['Timer Outline Color']);
 
_.updateBooleans = function() {
        this.usesHours = !!(this.format.match(/%1/));
        this.usesMinutes = !!(this.format.match(/%2/));
        this.usesSeconds = !!(this.format.match(/%3/));
        this.usesFrames = !!(this.format.match(/%4/));
};
 
_.getLowestType = function() {
        if(this.usesFrames) return 0;
        else if(this.usesSeconds) return 1;
        else if(this.usesMinutes) return 2;
        return 3;
};
 
_.setupPosition = function() {
        this.vert = (!!this.pos.match(/top/i)) ? 0 : 1;
        if(!!this.pos.match(/-l/i)) {
                this.horz = -1;
        } else if(!!this.pos.match(/-r/i)) {
                this.horz = 1;
        } else {
                this.horz = 0;
        }
};
 
_.setupSoundEffects = function() {
        if(this.start) {
                const info = this.start.split(/\s*,\s*/);
                this.start = {
                        name: info[0], 
                        volume: parseInt(info[1]),
                        pitch: parseInt(info[2]),
                        pan: parseInt(info[3])
                }
        }
        if(this.stop) {
                const info = this.stop.split(/\s*,\s*/);
                this.stop = {
                        name: info[0], 
                        volume: parseInt(info[1]),
                        pitch: parseInt(info[2]),
                        pan: parseInt(info[3])
                }
        }
};
 
_.updateBooleans();
_.setupPosition();
_.setupSoundEffects();
 
//-----------------------------------------------------------------------------
// SRD.PluginCommands
//-----------------------------------------------------------------------------
 
$['settimer'] = function(args) {
        const v = $gameVariables._data;
        let result = eval(args[0]);
        if(args[1]) result += (eval(args[1]) * 60);
        if(args[2]) result += (eval(args[2]) * 60 * 60);
        if(args[3]) result += (eval(args[3]) * 60 * 60 * 60);
        $gameTimer.start(result);
};
 
$['addtimer'] = function(args) {
        const v = $gameVariables._data;
        let result = $gameTimer.getFrames();
        if(args[0]) result += (eval(args[0]));
        if(args[1]) result += (eval(args[1]) * 60);
        if(args[2]) result += (eval(args[2]) * 60 * 60);
        if(args[3]) result += (eval(args[3]) * 60 * 60 * 60);
        if(result < 0) result = 0;
        $gameTimer.start(result);
};
 
$['pausetimer'] = function(args) {
        $gameTimer.pause();
};
 
$['unpausetimer'] = function(args) {
        $gameTimer.unpause();
};
 
$['setexpirecommonevent'] = function(args) {
        $gameTimer.setExpireCommonEvent(parseInt(args[0]));
};
 
$['settimerlabel'] = function(args) {
        if(args.length === 0) {
                $gameTimer.setLabel('');
        } else {
                let text = '';
                for(let i = 0; i < args.length; i++) {
                        text += String(args[i]) + " ";
                }
                $gameTimer.setLabel(text);
        }
};
 
//-----------------------------------------------------------------------------
// Game_Interpreter
//-----------------------------------------------------------------------------
 
if(!SRD.Game_Interpreter_pluginCommand) {
 
SRD.Game_Interpreter_pluginCommand = Game_Interpreter.prototype.pluginCommand;
Game_Interpreter.prototype.pluginCommand = function(command, args) {
        const com = command.trim().toLowerCase();
        if($[com]) {
                $[com].call(this, args);
                return;
        }
        SRD.Game_Interpreter_pluginCommand.apply(this, arguments);
};
 
}
 
//-----------------------------------------------------------------------------
// Game_Timer
//-----------------------------------------------------------------------------
 
_.Game_Timer_initialize = Game_Timer.prototype.initialize;
Game_Timer.prototype.initialize = function() {
        _.Game_Timer_initialize.apply(this, arguments);
        this._onExpireCommonEvent = 0;
        this._isPaused = false;
        this._label = _.default;
};
 
_.Game_Timer_update = Game_Timer.prototype.update;
Game_Timer.prototype.update = function(sceneActive) {
        if(!this._isPaused && !this.isAutoPaused()) {
                _.Game_Timer_update.apply(this, arguments);
        }
};
 
Game_Timer.prototype.isAutoPaused = function() {
        return _.autoPause && $gameMap.isEventRunning() && SceneManager._scene.constructor === Scene_Map;
};
 
Game_Timer.prototype.getCount = function(type) {
        switch(type) {
                case 0: return this._frames;
                case 1: return Math.floor(this._frames / 60);
                case 2: return Math.floor(this._frames / (60 * 60));
                case 3: return Math.floor(this._frames / (60 * 60 * 60));
        }
};
 
Game_Timer.prototype.getLabel = function() {
        if(!this._label) return '';
        let text = this._label;
        text = text.replace(/\\V\[(\d+)\]/gi, function() {
                return $gameVariables.value(parseInt(arguments[1]));
        }.bind(this));
        return text;
};
 
Game_Timer.prototype.setLabel = function(label) {
        this._label = label;
};
 
_.Game_Timer_start = Game_Timer.prototype.start;
Game_Timer.prototype.start = function(count) {
        _.Game_Timer_start.apply(this, arguments);
        if(_.start) AudioManager.playSe(_.start);
        this.unpause();
};
 
_.Game_Timer_stop = Game_Timer.prototype.stop;
Game_Timer.prototype.stop = function(count) {
        _.Game_Timer_stop.apply(this, arguments);
        this.unpause();
};
 
Game_Timer.prototype.getFrames = function() {
        return this._frames;
};
 
Game_Timer.prototype.setExpireCommonEvent = function(id) {
        this._onExpireCommonEvent = id;
};
 
Game_Timer.prototype.onExpire = function() {
        if(_.abort) BattleManager.abort();
        if(_.stop) AudioManager.playSe(_.stop);
        this.playExpireCommonEvent();
        if(_.autoStop) this.stop();
};
 
Game_Timer.prototype.playExpireCommonEvent = function() {
        if(this._onExpireCommonEvent !== 0) {
                $gameTemp.reserveCommonEvent(this._onExpireCommonEvent);
                this._onExpireCommonEvent = 0;
        }
};
 
Game_Timer.prototype.pause = function() {
        this._isPaused = true;
};
 
Game_Timer.prototype.unpause = function() {
        this._isPaused = false;
};
 
Game_Timer.prototype.isPaused = function() {
        return this._isPaused;
};
 
//-----------------------------------------------------------------------------
// Scene_Base
//-----------------------------------------------------------------------------
 
Scene_Base.prototype.createTimer = Spriteset_Base.prototype.createTimer;
 
//-----------------------------------------------------------------------------
// Scene_Map
//-----------------------------------------------------------------------------
 
_.Scene_Map_createSpriteset = Scene_Map.prototype.createSpriteset;
Scene_Map.prototype.createSpriteset = function() {
    _.Scene_Map_createSpriteset.apply(this, arguments);
    this.createTimer()
};
 
//-----------------------------------------------------------------------------
// Scene_Battle
//-----------------------------------------------------------------------------
 
_.Scene_Battle_createSpriteset = Scene_Battle.prototype.createSpriteset;
Scene_Battle.prototype.createSpriteset = function() {
    _.Scene_Battle_createSpriteset.apply(this, arguments);
    this.createTimer();
};
 
//-----------------------------------------------------------------------------
// Spriteset_Base
//-----------------------------------------------------------------------------
 
Spriteset_Base.prototype.createTimer = function() {};
 
//-----------------------------------------------------------------------------
// Sprite_Timer
//-----------------------------------------------------------------------------
 
_.Sprite_Timer_initialize = Sprite_Timer.prototype.initialize;
Sprite_Timer.prototype.initialize = function() {
        this.initMembers();
        _.Sprite_Timer_initialize.apply(this, arguments);
        this.createBackground();
        this.createLabel();
        this.addChildren();
        this.redraw();
};
 
Sprite_Timer.prototype.initMembers = function() {
        this._lowestType = _.getLowestType();
        this._count = 0;
        this._paused = false;
        this._label = $gameTimer.getLabel();
};
 
Sprite_Timer.prototype.createBackground = function() {
        const width = this.numBitmap.width * (1.5);
        let height = this.numBitmap.height;
        if(this._label) height += _.labelSize + 16;
        this.background = new Sprite(new Bitmap(width, height));
        if(_.back) {
                if(_.horz) {
                        this.background.bitmap.gradientFillRect(0, 0, width, height, 'rgba(0, 0, 0, 0)', 'rgba(0, 0, 0, 1)', false);
                        this.background.scale.x = _.horz;
                } else {
                        this.background.bitmap = new Bitmap(width * 2, height);
                        this.background.bitmap.gradientFillRect(0, 0, width, height, 'rgba(0, 0, 0, 0)', 'rgba(0, 0, 0, 1)', false);
                        this.background.bitmap.gradientFillRect(width, 0, width, height, 'rgba(0, 0, 0, 1)', 'rgba(0, 0, 0, 0)', false);
                        this.background.anchor.x = 0.5;
                }
        }
};
 
Sprite_Timer.prototype.createLabel = function() {
        this.label = new Sprite(new Bitmap(this.numBitmap.width, _.labelSize + 16));
        this.label.bitmap.fontFace = _.font;
        this.label.bitmap.fontSize = _.labelSize;
        this.label.bitmap.fontItalic = _.italic;
        this.label.bitmap.textColor = _.color;
        this.label.bitmap.outlineColor = _.outline;
        this.refreshLabel();
};
 
Sprite_Timer.prototype.refreshLabel = function() {
        const bit = this.label.bitmap;
        bit.clear();
        if(this._label) {
                bit.drawText(this._label, 0, 0, bit.width, bit.height, 'center');
        }
};
 
Sprite_Timer.prototype.removeChildren = function() {
        this.removeChild(this.background);
        this.removeChild(this.numbers);
        this.removeChild(this.label);
};
 
Sprite_Timer.prototype.addChildren = function() {
        this.addChild(this.background);
        this.addChild(this.numbers);
        this.addChild(this.label);
};
 
Sprite_Timer.prototype.createBitmap = function() {
        const fontSize = _.size;
        const bitmap = new Bitmap(1, 1);
        bitmap.fontFace = _.font;
        bitmap.fontSize = fontSize;
        bitmap.fontItalic = _.italic;
        const newWidth = bitmap.measureTextWidth(this.timerText()) + 16;
        const newHeight = fontSize + 16;
 
        this.numbers = new Sprite(new Bitmap(newWidth, newHeight));
        this.numBitmap = this.numbers.bitmap;
        this.numBitmap.fontFace = _.font;
        this.numBitmap.fontSize = fontSize;
        this.numBitmap.fontItalic = _.italic;
        this.numBitmap.textColor = _.color;
        this.numBitmap.outlineColor = _.outline;
};
 
_.Sprite_Timer_update = Sprite_Timer.prototype.update;
Sprite_Timer.prototype.update = function() {
        _.Sprite_Timer_update.apply(this, arguments);
        this.updatePause();
        this.updateLabel();
};
 
Sprite_Timer.prototype.updateBitmap = function() {
        if(this._count !== $gameTimer.getCount(this._lowestType)) {
                this._count = $gameTimer.getCount(this._lowestType);
                this.redraw();
        }
};
 
Sprite_Timer.prototype.updatePause = function() {
        if(this._paused !== $gameTimer.isPaused()) {
                this._paused = $gameTimer.isPaused();
                if(this._paused) this.redrawForPause();
                else this.redraw();
        }
};
 
Sprite_Timer.prototype.updateLabel = function() {
        if(this._label !== $gameTimer.getLabel()) {
                const refreshChildren = (!!this._label !== !!$gameTimer.getLabel());
                this._label = $gameTimer.getLabel();
                this.refreshLabel();
                if(refreshChildren) {
                        this.removeChildren();
                        this.createBackground();
                        this.addChildren();
                }
        }
};
 
Sprite_Timer.prototype.redraw = function() {
        if(this._paused) return;
        const text = this.timerText();
        const width = this.numBitmap.width;
        const height = this.numBitmap.height;
        this.numBitmap.clear();
        this.numBitmap.drawText(text, 0, 0, width, height, 'center');
};
 
Sprite_Timer.prototype.redrawForPause = function() {
        const text = this.timerText();
        const width = this.numBitmap.width;
        const height = this.numBitmap.height;
        const color = this.numBitmap.textColor;
        this.numBitmap.clear();
        this.numBitmap.textColor = _.pauseColor;
        this.numBitmap.drawText(text, 0, 0, width, height, 'center');
        this.numBitmap.textColor = color;
};
 
Sprite_Timer.prototype.timerText = function() {
        let result = _.format;
        const frames = $gameTimer.getFrames();
        const seconds = Math.floor(frames / 60);
        const minutes = Math.floor(frames / (60 * 60));
        const frm = frames % 60;
        const sec = seconds % 60;
        const min = minutes % 60;
        const hur = Math.floor(minutes / 60) % 60;
        if(_.usesFrames) result = result.replace(/%4/, frm.padZero(2));
        if(_.usesSeconds) result = result.replace(/%3/, sec.padZero(2));
        if(_.usesMinutes) result = result.replace(/%2/, min.padZero(2));
        if(_.usesHours) result = result.replace(/%1/, hur.padZero(2));
        return result;
};
 
Sprite_Timer.prototype.updateVisibility = function() {
        if($gameTimer.isWorking()) {
                this.opacity = ($gameTimer.isAutoPaused()) ? _.autoOpacity : 255;
        } else {
                this.opacity = 0;
        }
};
 
Sprite_Timer.prototype.updatePosition = function() {
        if(!this.background) return;
        this.updateVertical();
        this.updateCountPosition();
        this.updateHorizontal();
};
 
Sprite_Timer.prototype.updateVertical = function() {
        if(_.vert === 1) {
                this.y = Graphics.boxHeight - this.background.height;
        } else {
                this.y = 0;
        }
};
 
Sprite_Timer.prototype.updateCountPosition = function() {
        if(this._label) {
                this.numbers.y = _.labelSize + 16;
        } else {
                this.numbers.y = 0;
        }
};
 
Sprite_Timer.prototype.updateHorizontal = function() {
        if(_.horz === 1) {
                this.x = Graphics.boxWidth - this.numBitmap.width;
                this.background.x = this.numBitmap.width - this.background.bitmap.width;
        } else if(_.horz === -1) {
                this.x = 0;
                this.background.x = this.background.bitmap.width;
        } else {
                this.x = (Graphics.boxWidth - this.numBitmap.width) / 2;
                this.background.x = this.numBitmap.width / 2;
        }
};
 
})(SRD.TimerUpgrade, SRD.PluginCommands);




Si quelqu'un a une solution pour moi, ce serait très sympa ! J'vous donne un câlin si vous voulez en récompense. :3

» Liste de scripts | » XP - Options


Derp - posté le 15/03/2017 à 18:46:04 (10 messages postés)

❤ 0

fuk dat lil muz cuz ima albatraoz

Ce serait faisable en événements... voire même en script mais ça me prendrait plus de temps (il faudrait que je tatônne ; ce n'est qu'une question de waits, de texte à afficher et quelques fonctions...).

En tout cas, go MP. Au grand dam du forum, je n'ai aucun intérêt à publier une solution miracle ici.

(Je suis intéressé par le câlin).

José Carioca


Voximilien - posté le 16/03/2017 à 15:11:03 (128 messages postés)

❤ 0

Salut !

Non, non, pas besoin de développer un script pour moi ! Je te remercie, mais je ne veux pas demander à quelqu'un de me faire quelque chose comme ça.

En fait, je voulais juste savoir si quelqu'un avait un script comme celui-ci qui traîne sur son PC, puisque que beaucoup de ressources pour XP ont disparus.

Ou simplement savoir si avec de la bidouille, on peut faire un script qui fonctionne en RGSS1.

» Liste de scripts | » XP - Options


Derp - posté le 16/03/2017 à 18:10:27 (10 messages postés)

❤ 0

fuk dat lil muz cuz ima albatraoz

Citation:

Ou simplement savoir si avec de la bidouille, on peut faire un script qui fonctionne en RGSS1.



Bien sûr. :)

Maintenant, tu sais.

José Carioca


Voximilien - posté le 17/03/2017 à 15:47:46 (128 messages postés)

❤ 0

Okay, merci ! :)
Je vais essayer de bidouiller un truc de mon coté.

Je vais aussi continuer de chercher si il existe un script ou des bouts de scripts à assembler.

» Liste de scripts | » XP - Options


Voximilien - posté le 06/04/2017 à 08:39:05 (128 messages postés)

❤ 0

J'avais trouvé un script avec ce que je cherchais mais qui avait un bug assez important. J'ai essayé de le bidouiller pour le corriger, en vain. C'était le script de Eron qui se nommait Sprite Timer Mejorado.

Puis, en retournant sur la page quelques jours après, j'ai pu constater que l'Admin a publié un post pas plus tard qu'hier avec sa version du script qui est totalement fonctionnelle ! Et avec quelques caractéristiques que je cherchais, dont les millisecondes et la pause.

C'est un script de Wecoc :
Source : http://mundo-maker.foroactivo.com/t13819-xp-wecoc-s-timer-upgrade-v1-0

Script :

Portion de code : Tout sélectionner

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
#==============================================================================
    # ** Wecoc's Timer Upgrade v1.0
    #------------------------------------------------------------------------------
    # Autor: Wecoc
    # Adaptación del "Sprite_Timer Mejorado" de Eron
    #------------------------------------------------------------------------------
    # Para usarlo a parte de con los comandos de siempre,
    # desde Llamar Script podéis usar éstos métodos directamente:
 
    # timer.set(time, x, y, show_numbers, font_name, font_size, font_color)
    #    Ejemplo 1: timer.set(5)
    #    Ejemplo 2: timer.set(10, 0, 0)
    #    Ejemplo 3: timer.set(5, 5, 5, true, "Verdana", 35, Color.new(255, 200, 20))
 
    # timer.time
    # timer.hour      |   timer.h
    # timer.min       |   timer.m
    # timer.sec       |   timer.s
    # timer.milisec   |   timer.ms
 
    # timer.play
    # timer.pause
    # timer.stop
    # timer.reset
 
    # timer.pause?
 
    # timer.add_time(time)
 
    # timer.x
    # timer.y
    # timer.z
    # timer.font
    # timer.size
    # timer.color
 
    # timer.hpos = value # 0: Izquierda, 1: Centro, 2: Derecha
    # timer.vpos = value # 0: Arriba, 1: Centro, 2: Abajo
 
    # timer.x = x
    # timer.y = y
    # timer.z = z
    # timer.font = font
    # timer.size = size
    # timer.color = color
 
    # timer.show_numbers
    # timer.show_numbers = true / false
 
    # timer.forward
    # timer.forward = true / false
 
    # timer.format
    # timer.format = [format, [parameters]]
 
    # timer.speed
    # timer.speed = speed
 
    #==============================================================================
 
    class Scene_Map         ;   attr_reader :spriteset      ;   end
    class Scene_Battle      ;   attr_reader :spriteset      ;   end
    class Spriteset_Map     ;   attr_reader :timer_sprite   ;   end
    class Spriteset_Battle  ;   attr_reader :timer_sprite   ;   end
 
    #==============================================================================
 
    class Interpreter
      def timer
        return $scene.spriteset.timer_sprite
      end
      def command_124
        @parameters[0] == 0 ? timer.set(@parameters[1]) : timer.stop
      end
    end
 
    class Game_System
      attr_accessor :timer_font_name
      attr_accessor :timer_font_size
      attr_accessor :timer_font_color
      attr_accessor :timer_format
      attr_accessor :timer_x
      attr_accessor :timer_y
      attr_accessor :timer_z
      attr_accessor :timer_counter
      attr_accessor :timer_reset_time
      attr_accessor :timer_speed
      attr_accessor :timer_show_numbers
      attr_accessor :timer_pause
      attr_accessor :timer_forward
      #--------------------------------------------------------------------------
      # * Initialize
      #--------------------------------------------------------------------------
      alias wecoc_timer_ini initialize unless $@
      def initialize
        wecoc_timer_ini
        @timer_font_name = "Arial"
        @timer_font_size = 32
        @timer_font_color = Color.new(255,255,255)
        @timer_format = ["%02d:%02d", ['m', 's']] # 00:00
        @timer_x = 552
        @timer_y = 8
        @timer_z = 500
        @timer_counter = -1
        @timer_reset_time = -1
        @timer_speed = 1.0
        @timer_show_numbers = true
        @timer_pause = false
        @timer_forward = false
      end
    end
 
    #==============================================================================
 
    class Sprite_Timer < Sprite
      #--------------------------------------------------------------------------
      # * Initialize
      #--------------------------------------------------------------------------
      def initialize
        super
        self.x = $game_system.timer_x
        self.y = $game_system.timer_y
        self.z = $game_system.timer_z
        get_bitmap_size
      end
      #--------------------------------------------------------------------------
      # * Dispose
      #--------------------------------------------------------------------------
      def dispose
        self.bitmap.dispose if self.bitmap != nil
        super
      end
      #--------------------------------------------------------------------------
      # * Obtener tamaño de la bitmap
      #--------------------------------------------------------------------------
      def get_bitmap_size
        self.bitmap = Bitmap.new(1,1)
        refresh_font
        text_array = []
        format = $game_system.timer_format
        format[1].size.times { text_array.push(0) }
        text = sprintf(format[0], *text_array)
        w = self.bitmap.text_size(text).width + 16
        h = self.bitmap.text_size(text).height
        self.bitmap = Bitmap.new(w, h)
        refresh_font
      end
      #--------------------------------------------------------------------------
      # * Refresh
      #--------------------------------------------------------------------------
      def refresh
        self.bitmap.clear
        counter = $game_system.timer_counter
        speed = $game_system.timer_speed.to_f
        @ms = (counter.to_f * (60 * speed) / Graphics.frame_rate).to_i
        @s = (@ms.to_f / 60).floor
        @m = (@s.to_f / 60).floor
        @h = (@m.to_f / 60).floor
        @ms %= 60
        @s %= 60
        @m %= 60
        @h %= 24
        if $game_system.timer_show_numbers == true
          refresh_font
          draw_current_time
        end
      end
      #--------------------------------------------------------------------------
      # * Obtener fuente actual
      #--------------------------------------------------------------------------
      def refresh_font
        self.bitmap.font.name  = $game_system.timer_font_name
        self.bitmap.font.size  = $game_system.timer_font_size
        self.bitmap.font.color = $game_system.timer_font_color
      end
      #--------------------------------------------------------------------------
      # * Dibujar el tiempo en la pantalla
      #--------------------------------------------------------------------------
      def draw_current_time
        text_array = []
        format = $game_system.timer_format
        for i in 0...format[1].size
          case format[1][i]
            when 'ms' then text_array.push @ms
            when 's'  then text_array.push @s
            when 'm'  then text_array.push @m
            when 'h'  then text_array.push @h
          end
        end
        text = sprintf(format[0], *text_array)
        self.bitmap.draw_text(self.bitmap.rect, text, 1)
      end
      #--------------------------------------------------------------------------
      # * Definir tiempo
      #--------------------------------------------------------------------------
      def set(time, x=self.x, y=self.y, show=$game_system.timer_show_numbers,
        name=$game_system.timer_font_name, size=$game_system.timer_font_size,
        color=$game_system.timer_font_color)
        $game_system.timer_working = true
        $game_system.timer_counter = time * Graphics.frame_rate
        $game_system.timer_reset_time = time
        $game_system.timer_show_numbers = show
        self.x, self.y = x, y
        self.font = name if name != $game_system.timer_font_name
        self.size = size if size != $game_system.timer_font_size
        self.color = color if color != $game_system.timer_font_color
        refresh
      end
      #--------------------------------------------------------------------------
      # * Obtener tiempo actual (en segundos)
      #--------------------------------------------------------------------------
      def time
        return @s + (@m * 60) + (@h * 60 * 24)
      end
      #--------------------------------------------------------------------------
      # * Obtener parámetros de tiempo
      #--------------------------------------------------------------------------
      attr_reader :h, :m, :s, :ms
      def hour    ; return @h   ; end
      def min     ; return @m   ; end
      def sec     ; return @s   ; end
      def milisec ; return @ms  ; end
      #--------------------------------------------------------------------------
      # * Definir X
      #--------------------------------------------------------------------------
      def x=(x)
        super(x)
        $game_system.timer_x = x
      end
      #--------------------------------------------------------------------------
      # * Definir Y
      #--------------------------------------------------------------------------
      def y=(y)
        super(y)
        $game_system.timer_y = y
      end
      #--------------------------------------------------------------------------
      # * Definir Z
      #--------------------------------------------------------------------------
      def z=(z)
        super(z)
        $game_system.timer_z = z
      end
      #--------------------------------------------------------------------------
      # * Definir posición horizontal
      #--------------------------------------------------------------------------
      def hpos=(value)
        case value
        when 0 # Izquierda
          self.x = 8
        when 1 # Centro
          self.x = 640 / 2 - self.bitmap.width / 2
        when 2 # Derecha
          self.x = 640 - self.bitmap.width - 8
        end
      end
      #--------------------------------------------------------------------------
      # * Definir posición vertical
      #--------------------------------------------------------------------------
      def vpos=(value)
        case value
        when 0 # Arriba
          self.y = 8
        when 1 # Centro
          self.y = 480 / 2 - self.bitmap.height / 2
        when 2 # Abajo
          self.y = 480 - self.bitmap.height - 8
        end
      end
      #--------------------------------------------------------------------------
      # * Empezar temporizador
      #--------------------------------------------------------------------------
      def play
        $game_system.timer_pause = false
      end
      #--------------------------------------------------------------------------
      # * Parar temporizador
      #--------------------------------------------------------------------------
      def pause
        $game_system.timer_pause = true
      end
      #--------------------------------------------------------------------------
      # * Comprobar si el temporizador está pausado
      #--------------------------------------------------------------------------
      def pause?
        return $game_system.timer_pause
      end
      #--------------------------------------------------------------------------
      # * Terminar temporizador
      #--------------------------------------------------------------------------
      def stop
        $game_system.timer_counter = -1
        $game_system.timer_working = false
        return
      end
      #--------------------------------------------------------------------------
      # * Volver a iniciar temporizador
      #--------------------------------------------------------------------------
      def reset
        set($game_system.timer_reset_time)
      end
      #--------------------------------------------------------------------------
      # * Añadir tiempo (en segundos, puede ser valor negativo)
      #--------------------------------------------------------------------------
      def add_time(value)
        $game_system.timer_counter += (value) * Graphics.frame_rate
        $game_system.timer_counter = [0, $game_system.timer_counter].max
        refresh
      end
      #--------------------------------------------------------------------------
      # * Nombre de la fuente
      #--------------------------------------------------------------------------
      def font
        return $game_system.timer_font_name
      end
      #--------------------------------------------------------------------------
      def font=(name)
        $game_system.timer_font_name = name
        self.bitmap.font.name = name
        get_bitmap_size
      end
      #--------------------------------------------------------------------------
      # * Tamaño de la fuente
      #--------------------------------------------------------------------------
      def size
        return $game_system.timer_font_size
      end
      #--------------------------------------------------------------------------
      def size=(size)
        $game_system.timer_font_size = size
        self.bitmap.font.size = size
        get_bitmap_size
      end
      #--------------------------------------------------------------------------
      # * Color de la fuente
      #--------------------------------------------------------------------------
      def color
        return $game_system.timer_font_color
      end
      #--------------------------------------------------------------------------
      def color=(color)
        $game_system.timer_font_color = color
        self.bitmap.font.color = color
      end
      #--------------------------------------------------------------------------
      # * Formato del texto
      #--------------------------------------------------------------------------
      def format
        return $game_system.timer_format
      end
      #--------------------------------------------------------------------------
      def format=(format)
        $game_system.timer_format = format
        get_bitmap_size
        refresh
      end
      #--------------------------------------------------------------------------
      # * Mostrar números
      #--------------------------------------------------------------------------
      def show_numbers
        return $game_system.timer_show_numbers
      end
      #--------------------------------------------------------------------------
      def show_numbers=(show_numbers)
        $game_system.timer_show_numbers = show_numbers
      end
      #--------------------------------------------------------------------------
      # * Modo forward
      #--------------------------------------------------------------------------
      def forward
        return $game_system.timer_forward
      end
      #--------------------------------------------------------------------------
      def forward=(forward)
        $game_system.timer_forward = forward
      end
      #--------------------------------------------------------------------------
      # * Definir velocidad
      #--------------------------------------------------------------------------
      def speed
        return $game_system.timer_speed
      end
      #--------------------------------------------------------------------------
      def speed=(speed)
        $game_system.timer_speed = speed.to_f
      end
      #--------------------------------------------------------------------------
      # * Update
      #--------------------------------------------------------------------------
      def update
        super
        self.visible = $game_system.timer_working
        if self.visible == true && $game_system.timer_counter >= 0
          if !self.pause?
            $game_system.timer_counter += $game_system.timer_forward ? 1 : -1
            $game_system.timer_counter = [$game_system.timer_counter, 0].max
          end
          refresh
        end
      end
    end



Ses add-ons :

Portion de code : Tout sélectionner

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
#==============================================================================
# ** Wecoc's Timer Upgrade AddOns
#------------------------------------------------------------------------------
# Autor: Wecoc
# Éste script requiere el Wecoc's Timer Upgrade
# Es una colección de Add-Ons independientes para Sprite_Timer
#==============================================================================
 
#==============================================================================
# * 1. Bold & Italic
#------------------------------------------------------------------------------
# Permite poner los números en negrita o cursiva
#   timer.bold = true/false
#   timer.italic = true/false
#==============================================================================
 
class Game_System
  attr_accessor :timer_font_bold
  attr_accessor :timer_font_italic
  #--------------------------------------------------------------------------
  alias timer_addons_font_ini initialize unless $@
  def initialize
    timer_addons_font_ini
    @timer_font_bold = false
    @timer_font_italic = false
  end
end
 
#==============================================================================
 
class Sprite_Timer < Sprite
  #--------------------------------------------------------------------------
  alias addons_font_bold_italic refresh_font unless $@
  def refresh_font
    addons_font_bold_italic
    self.bitmap.font.bold = $game_system.timer_font_bold
    self.bitmap.font.italic = $game_system.timer_font_italic
  end
  #--------------------------------------------------------------------------
  def bold
    return $game_system.timer_font_bold
  end
  #--------------------------------------------------------------------------
  def bold=(bold)
    self.bitmap.font.bold = bold
    $game_system.timer_font_bold = bold
    get_bitmap_size
  end
  #--------------------------------------------------------------------------
  def italic
    return $game_system.timer_font_italic
  end
  #--------------------------------------------------------------------------
  def italic=(italic)
    self.bitmap.font.italic = italic
    $game_system.timer_font_italic = italic
    get_bitmap_size
  end
end
 
#==============================================================================
# * 2. Label
#------------------------------------------------------------------------------
# Permite asignar un texto encima del contador
#   table.label = ""
#   table.label = "Título"
#   table.label = ["V: %1", ["$game_variables[10]"]]
#==============================================================================
 
class Game_System
  attr_accessor :timer_label, :timer_label_data, :timer_label_size
  #--------------------------------------------------------------------------
  alias timer_addons_label_ini initialize unless $@
  def initialize
    timer_addons_label_ini
    @timer_label = ""       # Título por defecto
    @timer_label_data = []  # Datos almacenados en el título
    @timer_label_size = 20  # Tamaño de la fuente del label
  end
end
 
#==============================================================================
 
class Sprite_Timer < Sprite
  #--------------------------------------------------------------------------
  def label
    return $game_system.timer_label
  end
  #--------------------------------------------------------------------------
  def label_data
    return $game_system.timer_label_data
  end
  #--------------------------------------------------------------------------
  def get_label
    return "" if self.label == ""
    label_text = self.label.clone
    n = 0
    loop do
      if label_text.include?("%")
        label_text.gsub!("%#{(n+1).to_s}", eval(self.label_data[n]).to_s)
        n += 1
      else
        break
      end
    end
    return label_text
  end
  #--------------------------------------------------------------------------
  def label=(label)
    label = "" if label == nil
    if label.is_a?(Array)
      $game_system.timer_label      = label[0]
      $game_system.timer_label_data = label[1]
    else
      $game_system.timer_label = label
    end
    get_bitmap_size
    refresh
  end
  #--------------------------------------------------------------------------
  def get_bitmap_size
    self.bitmap = Bitmap.new(1,1)
    refresh_font
    text_array = []
    format = $game_system.timer_format
    format[1].size.times { text_array.push(0) }
    text = sprintf(format[0], *text_array)
    w = self.bitmap.text_size(text).width + 16
    h = self.bitmap.text_size(text).height
    if self.label != ""
      self.bitmap.font.size = $game_system.timer_label_size
      label_text = self.get_label
      lw = self.bitmap.text_size(label_text).width + 32
      lh = self.bitmap.text_size(label_text).height
      w = [w, lw].max
      h = h + lh + 8
    end
    self.bitmap = Bitmap.new(w, h)
    refresh_font
  end
  #--------------------------------------------------------------------------
  def draw_current_time
    text_array = []
    format = $game_system.timer_format
    for i in 0...format[1].size
      case format[1][i]
        when 'ms' then text_array.push @ms
        when 's'  then text_array.push @s
        when 'm'  then text_array.push @m
        when 'h'  then text_array.push @h
      end
    end
    text = sprintf(format[0], *text_array)
    if self.label != ""
      self.bitmap.font.size = $game_system.timer_label_size
      label_text = self.get_label
      lh = self.bitmap.text_size(label_text).height
      lrect = Rect.new(0, 4, self.bitmap.width, lh)
      self.bitmap.draw_text(lrect, label_text, 1)
      self.bitmap.font.size = $game_system.timer_font_size
      rect = Rect.new(0, lh, self.bitmap.width, self.bitmap.height - lh)
    else
      rect = Rect.new(0, 0, self.bitmap.width, self.bitmap.height)
    end
    self.bitmap.draw_text(rect, text, 1)
  end
end
 
#==============================================================================
# * 3. Back Color
#------------------------------------------------------------------------------
# Permite asignar un color de fondo
#   timer.back_color = color
#==============================================================================
 
class Game_System
  attr_accessor :timer_back_color
  #--------------------------------------------------------------------------
  alias timer_addons_back_ini initialize unless $@
  def initialize
    timer_addons_back_ini
    @timer_back_color = Color.new(0, 0, 0, 0) # Color por defecto
  end
end
 
#==============================================================================
 
class Sprite_Timer < Sprite
  #--------------------------------------------------------------------------
  def back_color
    return $game_system.timer_back_color
  end
  #--------------------------------------------------------------------------
  def back_color=(color)
    $game_system.timer_back_color = color
  end
  #--------------------------------------------------------------------------
  alias addons_back_color_draw draw_current_time unless $@
  def draw_current_time
    self.bitmap.fill_rect(self.bitmap.rect, $game_system.timer_back_color)
    addons_back_color_draw
  end
end
 
#==============================================================================
# * 4. Sound Effects
#------------------------------------------------------------------------------
# Permite asignar un sonido para cada segundo, así como uno cada n segundos
# y uno cuando llega a 00:00
#   $game_system.timer_sound_effects = true/false
#==============================================================================
 
class Game_System
  attr_accessor :timer_sound_effects
  #--------------------------------------------------------------------------
  alias timer_addons_sound_ini initialize unless $@
  def initialize
    timer_addons_sound_ini
    @timer_sound_effects = true
  end
end
 
#==============================================================================
 
class Sprite_Timer < Sprite
  alias addons_sound_upd update unless $@
  def update
    sec = self.sec
    addons_sound_upd
    if $game_system.timer_sound_effects == true
      if $game_system.timer_counter >= 0 && !self.pause?
        new_sec = self.sec
        if new_sec != sec
          # Sonido al cambiar segundo (opcional)
          Audio.se_play("Audio/SE/032-Switch01", 50, 100)
          if new_sec > 0 && new_sec % 5 == 0
            # Sonido cada 5 segundos (opcional)
            Audio.se_play("Audio/SE/032-Switch01", 40, 80)
          end
        end
        if $game_system.timer_counter == 1
          # Sonido al llegar a 00:00 (opcional)
          Audio.se_play("Audio/SE/057-Wrong01", 100, 100)
        end
      end
    end
  end
end
 
#==============================================================================
# * 5. Auto-pause
#------------------------------------------------------------------------------
# Para el reloj automáticamente cuando estás interactuando con un evento de mapa
#   $game_system.timer_auto_pause = true/false
#==============================================================================
 
class Game_System
  attr_accessor :timer_auto_pause
  #--------------------------------------------------------------------------
  alias timer_auto_pause_ini initialize unless $@
  def initialize
    timer_auto_pause_ini
    @timer_auto_pause = true
  end
end
 
#==============================================================================
 
class Game_Temp
  attr_accessor :timer_auto_paused
  #--------------------------------------------------------------------------
  alias timer_auto_pause_ini initialize unless $@
  def initialize
    timer_auto_pause_ini
    @timer_auto_paused = false
  end
end
 
#==============================================================================
 
class Sprite_Timer < Sprite
  #--------------------------------------------------------------------------
  def pause?
    return $game_system.timer_pause || $game_temp.timer_auto_paused
  end
  #--------------------------------------------------------------------------
  alias timer_auto_pause_upd update unless $@
  def update
    timer_auto_pause_upd
    if $game_system.timer_auto_pause && $game_system.map_interpreter.running?
      $game_temp.timer_auto_paused = true
    else
      $game_temp.timer_auto_paused = false
    end
  end
end
 
#==============================================================================
# * 6. Pause Color & Opacity
#------------------------------------------------------------------------------
# Permite asignar un color y opacidad especiales al texto cuando el reloj
# está pausado
#==============================================================================
 
class Sprite_Timer < Sprite
  alias addons_font_paused refresh_font unless $@
  def refresh_font
    addons_font_paused
    if self.pause?
      # Color del texto en modo pausado (opcional)
      self.bitmap.font.color = Color.new(255, 255, 50, 200)
    end
  end
  
  alias addons_font_paused_upd update unless $@
  def update
    addons_font_paused_upd
    self.opacity = 255
    if self.pause?
      # Opacidad de la bitmap en modo pausado (opcional)
      self.opacity = 128
    end
  end
end



» Liste de scripts | » XP - Options

Index du forum > Entraide > [RESOLU] [RPG Maker XP] Script de timer avancé

repondre up

Suite à de nombreux abus, le post en invités a été désactivé. Veuillez vous inscrire si vous souhaitez participer à la conversation.

Haut de page

Merci de ne pas reproduire le contenu de ce site sans autorisation.
Contacter l'équipe - Mentions légales

Plan du site

Communauté: Accueil | Forum | Chat | Commentaires | News | Flash-news | Screen de la semaine | Sorties | Tests | Gaming-Live | Interviews | Galerie | OST | Blogs | Recherche
Apprendre: Visite guidée | RPG Maker 95 | RPG Maker 2003 | RPG Maker XP | RPG Maker VX | RPG Maker MV | Tutoriels | Guides | Making-of
Télécharger: Programmes | Scripts/Plugins | Ressources graphiques / sonores | Packs de ressources | Midis | Eléments séparés | Sprites
Jeux: Au hasard | Notre sélection | Sélection des membres | Tous les jeux | Jeux complets | Le cimetière | RPG Maker 95 | RPG Maker 2000 | RPG Maker 2003 | RPG Maker XP | RPG Maker VX | RPG Maker VX Ace | RPG Maker MV | Autres | Proposer
Ressources RPG Maker 2000/2003: Chipsets | Charsets | Panoramas | Backdrops | Facesets | Battle anims | Battle charsets | Monstres | Systems | Templates
Ressources RPG Maker XP: Tilesets | Autotiles | Characters | Battlers | Window skins | Icônes | Transitions | Fogs | Templates
Ressources RPG Maker VX: Tilesets | Charsets | Facesets | Systèmes
Ressources RPG Maker MV: Tilesets | Characters | Faces | Systèmes | Title | Battlebacks | Animations | SV/Ennemis
Archives: Palmarès | L'Annuaire | Livre d'or | Le Wiki | Divers