| 赞 | 72 |
| VIP | |
| 好人卡 | |
| 积分 | 23 |
| 经验 | |
| 最后登录 | 2022-3-9 |
| 在线时间 | 4033 小时 |
…あたしは天
- 梦石
- 0
- 星屑
- 2308
- 在线时间
- 4033 小时
- 注册时间
- 2010-10-4
- 回帖
- 10548
 
|
加入我们,或者,欢迎回来。
您需要 登录 才可以下载或查看,没有账号?注册会员
×
本帖最后由 taroxd 于 2014-10-4 17:41 编辑
此脚本不需要置顶的基础设置就可使用
[pre lang="ruby" line="1"]
#--------------------------------------------------------------------------
# ● 数值输入处理可以输入负数
#--------------------------------------------------------------------------
module Taroxd
NegativeInput = Object.new
end
class Window_NumberInput < Window_Base
#--------------------------------------------------------------------------
# ● 开始输入的处理
#--------------------------------------------------------------------------
def start
@digits_max = $game_message.num_input_digits_max + 1
num = $game_variables[$game_message.num_input_variable_id]
max_num = 10**(@digits_max - 1) - 1
num = [[num, max_num].min, -max_num].max
@number = sprintf("%+0*d", @digits_max, num)
@index = 0
update_placement
create_contents
refresh
open
activate
end
#--------------------------------------------------------------------------
# ● 处理数字的更改
#--------------------------------------------------------------------------
def process_digit_change
return unless active
if Input.repeat?(:UP) || Input.repeat?(:DOWN)
Sound.play_cursor
if @index == 0
@number[0] = @number.start_with?('+') ? '-' : '+'
else
n = @number[@index].to_i
@number[@index] = ((n + (Input.repeat?(:UP) ? 1 : -1)) % 10).to_s
end
refresh
end
end
#--------------------------------------------------------------------------
# ● 刷新
#--------------------------------------------------------------------------
def refresh
contents.clear
change_color(normal_color)
@digits_max.times do |i|
rect = item_rect(i)
rect.x += 1
draw_text(rect, @number, 1)
end
end
#--------------------------------------------------------------------------
# ● 按下确定键时的处理
#--------------------------------------------------------------------------
def process_ok
Sound.play_ok
$game_variables[$game_message.num_input_variable_id] = @number.to_i
deactivate
close
end
end
[/pre] |
|