1

Sonntag, 22. Februar 2015, 01:44

Variablen in CSCA-Toast Manager anzeigen?

Hallo Leute 0/
Ich habe mal wieder ein Problem mit einem Skript.
Dieses Mal geht es um den "CSCA Toast Manager" von Casper Gaming.
In dem Skript geht es einfach darum, einfache "Toasts", also aufploppende Messageboxen zu kreieren.
An sich funktioniert alles tadellos, aber ich bekomme es einfach nicht hin, eine Variable in so einem Toast anzeigen zu lassen - Daher meine Frage: Ist dies möglich? Und falls nicht, würde sich jemand erbarmen, mir dies einzusetzen? Auf der Homepage steht auch, das modifizieren der Ressourcen erlaubt ist.
Spoiler: Das Skript

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
=begin
CSCA Toast Manager
version: 1.1.1 (Released: April 27, 2013)
Created by: Casper Gaming (http://www.caspergaming.com/)
 
Compatibility:
Made for RPGVXAce
IMPORTANT: ALL CSCA Scripts should be compatible with each other unless
otherwise noted.
Requires CSCA Core Script v1.0.4+
Suggested order: Paste below CSCA Core script, but above all other CSCA Scripts.
 
FFEATURES
Creates an easy-to-use toast system. Mainly a scripting tool, but you can create
and call your own basic toasts as well. More information on how to do so in the
script call section below.
 
SETUP
Set up required. Instructions below.
 
Scripters: it is recommended to alias and add your custom display codes in the
refresh method of CSCA_Window_Toast. If relying on this script to display toasts
in your own script, please link to original CSCA Toast Manager script topic on
rpgmakervxace.net
================================================================================
UPDATES:
Version 1.0.0
-Original Script
 
Version 1.1.0
-Toasts now global (not confined to the map scene). Certain scenes are excluded.
 
Version 1.1.1
-Toasts now have a z value of 1000.
================================================================================
CREDIT:
Free to use in noncommercial games if credit is given to:
Casper Gaming (http://www.caspergaming.com/)
 
To use in a commercial game, please purchase a license here:
http://www.caspergaming.com/licenses.html
 
TERMS:
http://www.caspergaming.com/terms_of_use.html
=end
module CSCA
  module TOASTS
#==============================================================================
# ** Important Script Calls
#==============================================================================
# bt_reserve_toast(text1, text2)
# Reserves a toast with 2 lines of centered text on it.
# text1 is the first line, text2 is the second line.
#==============================================================================
# ** Begin Setup
#==============================================================================
    SHOW_COUNT = 160 # Amount of frames to show each toast. Recommended 160.
    FADE_SPEED = 16 # Speed of fade in/out. Recommended 16.
#==============================================================================
# ** End Setup
#==============================================================================
  end
end
$imported = {} if $imported.nil?
$imported["CSCA-ToastManager"] = true
#==============================================================================
# ** Game_Interpreter
#------------------------------------------------------------------------------
#  Adds basic toast reservation method for non-scripters
#==============================================================================
class Game_Interpreter
  #--------------------------------------------------------------------------
  # Basic Text toast reservation, creates a toast with 2 lines of text.
  #--------------------------------------------------------------------------
  def bt_reserve_toast(text1, text2)
    $csca.reserve_toast([:csca_bt, text1, text2])
  end
end
#==============================================================================
# ** CSCA_Window_Toast
#------------------------------------------------------------------------------
# This window handles toast data.
#==============================================================================
class CSCA_Window_Toast < Window_Base
  attr_reader :show_count
  attr_reader :toast_gone
  #--------------------------------------------------------------------------
  # Object Initialization
  #--------------------------------------------------------------------------
  def initialize(order)
    x = Graphics.width / 4
    width = Graphics.width / 2
    height = line_height * 3
    y = ((Graphics.height - (height * 2)) / 2) + line_height * get_order_modifier(order)
    super(x, y, width, height)
    self.opacity = 0
    self.contents_opacity = 0
    self.z = 1000
    @show_count = 0
    @toast_gone = true
  end
  #--------------------------------------------------------------------------
  # Get order height modifier
  #--------------------------------------------------------------------------
  def get_order_modifier(order)
    return case order
    when :bottom; 6
    when :middle; 3
    when :top; 0
    end
  end
  #--------------------------------------------------------------------------
  # Frame Update
  #--------------------------------------------------------------------------
  def update
    super
    if @show_count > 0
      update_fadein
      @show_count -= 1
    else
      update_fadeout unless @toast_gone
    end
  end
  #--------------------------------------------------------------------------
  # Update Fadein
  #--------------------------------------------------------------------------
  def update_fadein
    self.opacity += CSCA::TOASTS::FADE_SPEED
    self.contents_opacity += CSCA::TOASTS::FADE_SPEED
  end
  #--------------------------------------------------------------------------
  # Update Fadeout
  #--------------------------------------------------------------------------
  def update_fadeout
    self.opacity -= CSCA::TOASTS::FADE_SPEED
    self.contents_opacity -= CSCA::TOASTS::FADE_SPEED
    @toast_gone = true if self.opacity <= 0 && self.contents_opacity <= 0
  end
  #--------------------------------------------------------------------------
  # Writer method
  #--------------------------------------------------------------------------
  def show_count=(amount)
    @show_count = amount
    @toast_gone = false
  end
  #--------------------------------------------------------------------------
  # Refresh
  #--------------------------------------------------------------------------
  def refresh(params)
    contents.clear
    if params[0] == :csca_bt
      draw_text(0,0,contents.width,line_height,params[1],1)
      draw_text(0,line_height,contents.width,line_height,params[2],1)
    end
  end
end
#==============================================================================
# ** CSCA_Core
#------------------------------------------------------------------------------
# Handles toast data.
#Aliases: initialize
#==============================================================================
class CSCA_Core
  attr_reader :toasts
  #--------------------------------------------------------------------------
  # Alias Method; object initialization
  #--------------------------------------------------------------------------
  alias :csca_toast_init :initialize
  def initialize
    csca_toast_init
    @toasts = []
  end
  #--------------------------------------------------------------------------
  # Reserve Toast for display
  #--------------------------------------------------------------------------
  def reserve_toast(params)
    return if SceneManager.no_toast_scene?
    @toasts.push(params)
  end
end
#==============================================================================
# ** SceneManager
#------------------------------------------------------------------------------
# Determines if the scene creates toasts.
#==============================================================================
module SceneManager
  #--------------------------------------------------------------------------
  # Don't create toasts?
  #--------------------------------------------------------------------------
  def self.no_toast_scene?
    scene_is?(Scene_Title) || scene_is?(Scene_Gameover) || scene_is?(Scene_Debug) ||
    scene_is?(Scene_File) || scene_is?(Scene_Save) || scene_is?(Scene_Load) ||
    scene_is?(Scene_End) || scene_is?(Scene_Name)
  end
end
#==============================================================================
# ** Scene_Map
#------------------------------------------------------------------------------
# Handles display of toasts
#Aliases: create_all_windows, update
#==============================================================================
class Scene_Base
  #--------------------------------------------------------------------------
  # Alias Method; Create All Windows
  #--------------------------------------------------------------------------
  alias :csca_create_toast_windows :start
  def start
    csca_create_toast_windows
    create_toast_windows unless SceneManager.no_toast_scene?
  end
  #--------------------------------------------------------------------------
  # Alias Method; Frame Update
  #--------------------------------------------------------------------------
  alias :csca_toast_update :update
  def update
    csca_toast_update
    update_toasts
  end
  #--------------------------------------------------------------------------
  # Create Toast Windows
  #--------------------------------------------------------------------------
  def create_toast_windows
    @toast_bottom = CSCA_Window_Toast.new(:bottom)
    @toast_middle = CSCA_Window_Toast.new(:middle)
    @toast_top = CSCA_Window_Toast.new(:top)
    @toast_list = [@toast_bottom, @toast_middle, @toast_top]
    @toast_bottom.viewport = @viewport
    @toast_middle.viewport = @viewport
    @toast_top.viewport = @viewport
  end
  #--------------------------------------------------------------------------
  # Update Toast Display
  #--------------------------------------------------------------------------
  def update_toasts
    $csca.toasts.each do |params|
      break if params.nil? || no_toast_possible?
      create_toast(params)
    end
  end
  #--------------------------------------------------------------------------
  # Check if all 3 toasts in use
  #--------------------------------------------------------------------------
  def no_toast_possible?
    return !@toast_bottom.toast_gone && !@toast_middle.toast_gone && !@toast_top.toast_gone
  end
  #--------------------------------------------------------------------------
  # Create Toast
  #--------------------------------------------------------------------------
  def create_toast(params)
    $csca.toasts.delete(params)
    for toast in @toast_list.each
      if toast.toast_gone
        toast.refresh(params)
        toast.show_count = CSCA::TOASTS::SHOW_COUNT
        break
      end
    end
  end
end
zum Lesen den Text mit der Maus markieren


Spoiler: Das CSCA-Core (Das wird für das Skript benötigt)

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
=begin
CSCA Core Script
version: 1.0.7
Created by: Casper Gaming (http://www.caspergaming.com/)
 
Scripts that REQUIRE this script to work:
CSCA Colosseum
CSCA Dungeon Tools
CSCA Achievements
CSCA Encyclopedia
CSCA Treasure Maps
CSCA Menu MOD
CSCA SaveFile Plus
CSCA Vehicle System
CSCA Sidequests
CSCA Professions
 
Version History:
1.0.1 - Adds CSCA_Item class, used by scripts to get information about an item.
1.0.2 - Adds CSCA_Fish class, used by Vehicle System to get fishing data.
1.0.3 - Adds Window_HorzCommand fix to allow unlimited horizontal commands.
1.0.4 - Adds CSCA_Core class, used for csca script data that needs to be saved.
1.0.5 - Adds shorter access to variables/switches in Event script command.
1.0.6 - Adds troubleshooting error/warning reports.
1.0.7 - Adds vowel detection for strings.
 
COMPATIBILITY
PLACE THIS SCRIPT ABOVE ALL OTHER CSCA SCRIPTS!
Compatible only for VXAce.
IMPORTANT: ALL CSCA Scripts should be compatible with each other unless
otherwise noted.
 
FFEATURES
This script includes classes and functions used by other CSCA Scripts.
 
SETUP
Plug n play. Make sure this script is ABOVE all other CSCA Scripts.
 
CREDIT:
Free to use in noncommercial games if credit is given to:
Casper Gaming (http://www.caspergaming.com/)
 
To use in a commercial game, please purchase a license here:
http://www.caspergaming.com/licenses.html
 
TERMS:
http://www.caspergaming.com/terms_of_use.html
=end
$imported = {} if $imported.nil?
$imported["CSCA-Core"] = true
#==============================================================================
# ** DataManager
#------------------------------------------------------------------------------
# Handles csca class data.
# Aliases: make_save_contents, create_game_objects, extract_save_contents
#==============================================================================
module DataManager
  #--------------------------------------------------------------------------
  # alias method
  #--------------------------------------------------------------------------
  class <<self; alias csca_core_create_game_objects create_game_objects; end
  def self.create_game_objects
    csca_core_create_game_objects
    $csca = CSCA_Core.new
  end
  #--------------------------------------------------------------------------
  # overwrite method
  #--------------------------------------------------------------------------
  class <<self; alias csca_core_save_contents make_save_contents; end
  def self.make_save_contents
    contents = csca_core_save_contents
    contents[:csca] = $csca
    contents
  end
  #--------------------------------------------------------------------------
  # alias method
  #--------------------------------------------------------------------------
  class <<self; alias csca_core_extract_save_contents extract_save_contents; end
  def self.extract_save_contents(contents)
    csca_core_extract_save_contents(contents)
    $csca = contents[:csca]
  end
end
#==============================================================================
# ** CSCA_Window_Header
#------------------------------------------------------------------------------
# This window displays the header window, used by many CSCA Scripts.
#==============================================================================
class CSCA_Window_Header < Window_Base
  #--------------------------------------------------------------------------
  # Object Initialization
  #--------------------------------------------------------------------------
  def initialize(x, y, width = Graphics.width, height = line_height*2, text)
    super(x, y, width, height)
    refresh(text)
  end
  #--------------------------------------------------------------------------
  # Refresh
  #--------------------------------------------------------------------------
  def refresh(text)
    contents.clear
    draw_text(0, 0, contents.width, line_height, text, 1)
  end
end
#==============================================================================
# ** Game_Map
#------------------------------------------------------------------------------
# Easy csca access to the map's note.
#==============================================================================
class Game_Map
  #--------------------------------------------------------------------------
  # Get Map Note
  #--------------------------------------------------------------------------
  def csca_map_note; @map.note; end
end
#==============================================================================
# ** Window_HorzCommand
#------------------------------------------------------------------------------
# Allow unlimited horizontal commands.
# Overwrites: top_col=
#==============================================================================
class Window_HorzCommand < Window_Command
  #--------------------------------------------------------------------------
  # Overwrite Method
  #--------------------------------------------------------------------------
  def top_col=(col)
    col = 0 if col < 0
    self.ox = col * (item_width + spacing)
  end
end
#==============================================================================
# ** Game_Interpreter
#------------------------------------------------------------------------------
#  Shorter access to variables and switches.
#==============================================================================
class Game_Interpreter
  #--------------------------------------------------------------------------
  # Get variables
  #--------------------------------------------------------------------------
  def csca_v(var)
    $game_variables[var]
  end
  #--------------------------------------------------------------------------
  # Get switches
  #--------------------------------------------------------------------------
  def csca_s(swi)
    $game_switches[swi]
  end
end
#==============================================================================
# ** CSCA_Item
#------------------------------------------------------------------------------
# CSCA Items, used as rewards/wagers in various scripts.
#==============================================================================
class CSCA_Item
  attr_reader :id
  attr_reader :amount
  attr_reader :type
  #--------------------------------------------------------------------------
  # Initialize
  #--------------------------------------------------------------------------
  def initialize(amount,id,type)
    @id = id
    @amount = amount
    @type = type
  end
end
#==============================================================================
# ** CSCA_Fish
#------------------------------------------------------------------------------
# CSCA Fish, used to specify data about fish.
#==============================================================================
class CSCA_Fish
  attr_reader :item_id
  attr_reader :water_type
  attr_reader :weight
  attr_reader :region
  #--------------------------------------------------------------------------
  # Initialize
  #--------------------------------------------------------------------------
  def initialize(id, water, weight, region = 0)
    @item_id = id
    @water_type = water
    @weight = weight
    @region = region
  end
end
#==============================================================================
# ** CSCA_Core
#------------------------------------------------------------------------------
# Used to provide global methods for csca scripts. Data is included in save.
#==============================================================================
class CSCA_Core
  #--------------------------------------------------------------------------
  # Initialize
  #--------------------------------------------------------------------------
  def initialize
  end
  #--------------------------------------------------------------------------
  # Report wrong setup
  #--------------------------------------------------------------------------
  def report_error(error, script, suggestion, warning = false)
    string1 = warning ? "Warning: " : "Error: "
    msgbox(string1 + error + "\nOccurred in: " + script + "\nRecommended fix: " + suggestion)
  end
  #--------------------------------------------------------------------------
  # Split number into millions, thousands, hundreds
  #--------------------------------------------------------------------------
  def split_number(start)
    number = []
    number[0] = start / 1000 / 1000
    number[1] = start / 1000 % 1000
    number[2] = start % 1000
    return number
  end
  #--------------------------------------------------------------------------
  # Split number into hours, minutes, seconds
  #--------------------------------------------------------------------------
  def split_playtime(start)
    number = []
    number[0] = start / 60 / 60
    number[1] = start / 60 % 60
    number[2] = start % 60
    return number
  end
  #--------------------------------------------------------------------------
  # Determine if letter is a vowel or not
  #--------------------------------------------------------------------------
  def is_a_vowel(letter, space = false)
    letter.upcase
    return letter == "A" || letter == "E" || letter == "I" || letter == "O" || letter == "U" || (letter == "X" && space == true)
  end
end
zum Lesen den Text mit der Maus markieren


Ich hoffe auf eine positive Antwort,
-Der Chesra
Alle Infos zu meinem aktuellen RPGMaker VX Ace-Projekt Jäger - Licht & Schatten gibt es auf meiner Homepage zu finden, sobald eine spielbare Demo released wird, wird es Projekt-Vorstellungen in allen gängigen Foren geben. Die Informationen auf der Homepage sind noch nicht final.

2

Montag, 23. Februar 2015, 15:28

Die simpelste Variante wäre einfach in der refresh Methode nicht draw_text zu verwenden, sondern die Methode die auch das Dialogfenster benutzt:

Ruby Quellcode

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
#----------------------------------------------------------------------------
# ** CSCA_Window_Toast Abänderung durch Playm
#   Beim Zeichnen des Texts wird wie in ShowText verfahren. Text ist auto-
#   matisch linksbündig, und Steuerzeichen wie \c und \v werden ersetzt.
#----------------------------------------------------------------------------
class CSCA_Window_Toast
  #--------------------------------------------------------------------------
  # Refresh
  #--------------------------------------------------------------------------
  def refresh(params)
    contents.clear
    if params[0] == :csca_bt
      draw_text_ex( 0, 0          , params[1] )
      draw_text_ex( 0, line_height, params[2] )
    end
  end
end
Aber dann ist der Text nichtmehr zentriert, bzw. es müssten erst noch ein paar Rechnungen ergänzt werden, ab welcher Stelle der Text gezeichnet werden soll, damit er zentriert ist. Dadurch das draw_text_ex(...) den Text zeichenweise interpretiert ist es nicht möglich ihn links oder rechtsbündig oder zentriert auszurichten, bzw. dies erfordert noch eigenen Code.
Wenn dich das aber garnicht stört, sollte obriger Skriptschnippsel als neues Skript unterhalb deines Toast-Skripts das bieten was Du möchtest.

3

Montag, 23. Februar 2015, 18:24

Eigentlich ist das für mich kein Problem, da man die Inhalte ja auch mit Leerzeichen an einen mittigen Punkt bringen kann.
Jedoch scheint das mit den Variablen nicht wirklich zu funktionieren, obwohl ich deinen Part unter das Hauptscript eingefügt habe.

-Der Chesra
Alle Infos zu meinem aktuellen RPGMaker VX Ace-Projekt Jäger - Licht & Schatten gibt es auf meiner Homepage zu finden, sobald eine spielbare Demo released wird, wird es Projekt-Vorstellungen in allen gängigen Foren geben. Die Informationen auf der Homepage sind noch nicht final.

4

Montag, 23. Februar 2015, 18:48

Du musst die Strings in einfache Anführungszeichen setzen, oder statt '\v[8]' "\\v[8]" schreiben, da in doppelten Anführungszeichen Ruby einfache Backslash selber als Steuerzeichen interpretiert und sie deswegen niemals beim Skript ankommen - in doppelten Anführungszeichen deswegen \\ um Ruby klar zu machen ich will da einen Backslash und dir damit keinen Befehl erteilen.

Ich empfehle dir, einfach die einfachen Anführungszeichen im CallSkript zu benutzen.

5

Montag, 23. Februar 2015, 21:24

Vielen Dank,
Nun scheint alles zu funktionieren. :)
Alle Infos zu meinem aktuellen RPGMaker VX Ace-Projekt Jäger - Licht & Schatten gibt es auf meiner Homepage zu finden, sobald eine spielbare Demo released wird, wird es Projekt-Vorstellungen in allen gängigen Foren geben. Die Informationen auf der Homepage sind noch nicht final.

Ähnliche Themen

Social Bookmarks