赞 | 4 |
VIP | 0 |
好人卡 | 0 |
积分 | 6 |
经验 | 1359 |
最后登录 | 2022-6-16 |
在线时间 | 244 小时 |
Lv2.观梦者
- 梦石
- 0
- 星屑
- 635
- 在线时间
- 244 小时
- 注册时间
- 2010-9-9
- 帖子
- 472
|
加入我们,或者,欢迎回来。
您需要 登录 才可以下载或查看,没有帐号?注册会员
x
本帖最后由 EngShun 于 2010-12-6 12:48 编辑
最近脑残的爱上拿别人的脚本来改了,导致现在我只有两个原创作品:L
比如说,物品分类,武器打造,都是拿别人的脚本来改的T.T
一直拿别人的脚本来改总是不会有出息的
但是我还是拿别人的脚本来改,那天我拿滚动字幕来改,
改到乱七八糟,最后自己都嫌乱丢了:L
昨天无意间看到七夕小雨的RM计算器,
输入1 / 0 之后出了问题,解决此问题后一时兴起就这样栽了下去
结果出了以下这个强化版(注释嫌太麻烦杀光了 )- #==========================================================================
- # RM计算机……无用产物之一
- # 脚本作者 by 七夕小雨
- # 强化 by EngShun
- # 注释被 EngShun 杀光了 (-_-||)
- #============================================================================
- class Window_Command_Calculator < Window_Selectable
- def initialize(width, commands, column=1)
- row = commands.size / column
- rowrem = commands.size % column
- if rowrem != 0
- row +=1
- end
- super(0, 0, width, row * 32 + 32)
- @item_max = commands.size
- @commands = commands
- @row = row
- @width_txt = (width-32)/column
- @column_max = column
- self.contents = Bitmap.new(width-32, @row * 32)
- refresh
- self.index = 0
- end
- def refresh
- self.contents.clear
- self.contents.font.size = 18
- for i in 0...@item_max
- draw_item(i, normal_color)
- end
- end
- def draw_item(index, color)
- self.contents.font.color = color
- row_index = index / @column_max
- for y in 0...@column_max
- if index % @column_max == y
- rect = Rect.new(y * @width_txt, 32 * row_index , @width_txt, 32)
- self.contents.fill_rect(rect, Color.new(0, 0, 0, 0))
- self.contents.draw_text(rect, @commands[index],1)
- break
- end
- end
- end
- def update_cursor_rect
- if @index < 0
- self.cursor_rect.empty
- return
- end
- row = @index / @column_max
- if row < self.top_row
- self.top_row = row
- end
- if row > self.top_row + (self.page_row_max - 1)
- self.top_row = row - (self.page_row_max - 1)
- end
- cursor_width = @width_txt
- x = @index % @column_max * cursor_width
- y = @index / @column_max * 32 - self.oy
- self.cursor_rect.set(x, y, @width_txt, 32)
- end
- end
- class Window_Calculator < Window_Base
- def initialize
- super(250, 101, 180, 64)
- self.contents = Bitmap.new(width - 32, height - 32)
- @welcome_text = "RM CALCULATOR"
- set_text(@welcome_text)
- end
- def set_text(text)
- self.contents.clear
- @text = text
- self.contents.font.color = normal_color
- if @text == "MATH ERROR"
- self.contents.font.color = Color.new(255,0,0)
- self.contents.draw_text(0, 0, 149, 32, @text, 1)
- elsif @text == @welcome_text
- self.contents.font.color = Color.new(0, 0, 255)
- self.contents.draw_text(0, 0, 149, 32, @text, 1)
- else
- self.contents.font.color = Color.new(0,0,0)
- self.contents.draw_text(0, 0, 149, 32, @text, 2)
- end
- end
- end
- class Scene_Calculator
- def main
- @back = Spriteset_Map.new
- @command_window = Window_Command_Calculator.new(180, ["1","2","3","4","5","6","7","8","9","0","+","-","×","÷","x2","丌","REM","=","AC","OFF"],4)
- @command_window.x = 320 - @command_window.width / 2
- @command_window.y = 165
- @command_window.index = 0
- @compute_window = Window_Calculator.new
- @compute_window.x = @command_window.x
- @v = Viewport.new(240,121,160,24)
- @v.z = @compute_window.z + 1
- @v.color.set(250,250,250)
- @c = 0
- @ans = true
- Graphics.transition
- loop do
- Graphics.update
- Input.update
- update
- if $scene != self
- break
- end
- end
- Graphics.freeze
- @v.dispose
- @compute_window.dispose
- @command_window.dispose
- @back.dispose
- end
- def update
- @compute_window.update
- @command_window.update
- if @command_window.active
- update_command
- return
- end
- end
- def update_command
- if Input.trigger?(Input::B)
- $game_system.se_play($data_system.cancel_se)
- $scene = Scene_Map.new
- return
- end
- if Input.trigger?(Input::C)
- case @command_window.index
- when 0..18
- $game_system.se_play($data_system.decision_se)
- when 19
- $game_system.se_play($data_system.cancel_se)
- end
- if @ans == true
- @z = 0
- @compute = "0"
- @Operation = 0
- @ans = false
- end
- case @command_window.index
- when 0..8
- if @compute != "0"
- @compute += "#{@command_window.index + 1}"
- else
- @compute = "#{@command_window.index + 1}"
- end
- when 9
- if @compute != "0"
- @compute += "0"
- end
- when 10
- update_number
- if @ans != true
- @a = @compute.to_i
- @Operation = 1
- @compute = "0"
- end
- when 11
- update_number
- if @ans != true
- @a = @compute.to_i
- @Operation = 2
- @compute = "0"
- end
- when 12
- update_number
- if @ans != true
- @a = @compute.to_i
- @Operation = 3
- @compute = "0"
- end
- when 13
- update_number
- if @ans != true
- @a = @compute.to_i
- @Operation = 4
- @compute = "0"
- end
- when 14
- update_number
- if @ans != true
- if @c != 0
- @a = @c
- else
- @a = @compute.to_i
- end
- @a = @a ** 2
- @compute = @a.to_s
- @ans = true
- end
- when 15
- update_number
- if @ans != true
- if @c != 0
- @a = @c
- else
- @a = @compute.to_i
- end
- @q = @a * 22 / 7.00
- @compute = @q.to_s
- @ans = true
- end
- when 16
- update_number
- if @ans !=true
- @a = @compute.to_i
- @Operation = 5
- @compute = "0"
- end
- when 17
- update_number
- if @ans != true
- if @c != 0
- @a = @c
- end
- case @Operation
- when 1
- @b = @compute.to_i
- @d = @a + @b
- @d = @d.to_s
- @compute = @d
- when 2
- @b = @compute.to_i
- @d = @a - @b
- @d = @d.to_s
- @compute = @d
- when 3
- @b = @compute.to_i
- @d = @a * @b
- @d = @d.to_s
- @compute = @d
- when 4
- @b = @compute.to_i
- if @b != 0
- @d = @a / @b.to_f
- end
- @d = @d.to_s
- if @b == 0
- @compute = "MATH ERROR"
- @ans = true
- else
- @compute = @d
- end
- when 5
- @b = @compute.to_i
- if @b != 0
- @d = @a % @b
- end
- @d = @d.to_s
- @d = @d.to_s
- if @b == 0
- @compute = "MATH ERROR"
- @ans = true
- else
- @compute = @d
- end
- end
- end
- when 18
- @compute = "0"
- @Operation = 0
- @c = 0
- @z = 0
- when 19
- $scene = Scene_Map.new
- return
- end
- @compute_window.set_text(@compute)
- return
- end
- end
- def update_number
- if @Operation != 0
- if @c != 0
- @a = @c
- end
- case @Operation
- when 1
- @b = @compute.to_i
- @c = @a + @b
- @compute = "0"
- when 2
- @b = @compute.to_i
- @c = @a - @b
- @compute = "0"
- when 3
- @b = @compute.to_i
- @c = @a * @b
- @compute = "0"
- when 4
- @b = @compute.to_i
- if @b != 0
- @c = @a / @b.to_f
- else
- @compute = "MATH ERROR"
- @ans = true
- end
- when 5
- @b = @compute.to_i
- if @b != 0
- @c = @a % @b
- else
- @compute = "MATH ERROR"
- @ans = true
- end
- end
- end
- end
- end
复制代码 简单说明一下
调用方法:$scene = Scene_Calculator.new
“x2”,比如说输入4“x2”会拿到16,也就是4 square 的意思
“丌”就是圆周率,输入7“丌”会拿到 22
“REM”是算余数
拿别人的脚本来改总是觉得很杯具T.T |
|