Project1
标题:
谁帮我修改下这个脚本
[打印本页]
作者:
灰太狼与喜羊羊
时间:
2014-8-12 18:38
标题:
谁帮我修改下这个脚本
我新找了个多重货币的脚本,但在菜单中显示货币的数量时感觉与游戏特别不配,
我用的是找到的一个动态菜单脚本,谁能帮我把金币窗口变成透明、改变位置与颜色呀
#==============================================================================
# 本脚本来自www.66RPG.com,使用和转载请保留此信息
#==============================================================================
module Currency
#==============================================================================
# 设定部分
#==============================================================================
# 货币名称 -- 在金钱窗口里使用
@name = ["金", "银"]
# 货币名称 -- 在商店里选择时使用
@iname =["金币", "银币"]
# 货币汇率 -- 计算价钱用
@rate = [ 1, 0.5,]
# 无法使用的货币
@cannot_use = []
# 不在金钱窗口显示的货币
@do_not_show = []
# 货币文字 -- 商店画面选项理所显示的文字
def self.word
return "选择货币"
end
# 只能用特定货币购买时显示的文字
# %s代表该货币
One_Currency = "只能用%s来购买!"
# 金钱窗口设置:是否在菜单显示新的金钱窗口
SHOW_NEW_CURRENCY = true
#==============================================================================
# 设定部分结束
#==============================================================================
#==============================================================================
# 使用方法
#==============================================================================
=begin
在事件中使用脚本:
gain_currency(类型, 数量)增加该类型货币
lose_currency(类型, 数量)减少该类型货币
convert(类型, 变量ID) 将该变量内的数值转换为该类型并返回
currency_type(类型, 变量ID) 将该类型货币金额代入该变量
在物品(武器、防具亦可,技能尚未测试)的备注栏打上
则该物品只能使用该类型货币购买
在物品(武器、防具亦可,技能尚未测试)的备注栏打上
则该物品只能使用该类型以外的货币购买
两个同时定义时,会互相抵销
(例如:同一个物品同时定义了 和
也就是同时「只能使用1号货币」和「只能除用除1号以外的货币」
那麽就变成了全部都能使用)
类型为数字代号,就是在脚本中所设定好的顺序(从0开始算)
0为默认金钱(直接用事件命令就行了)
=end
#==============================================================================
# 使用方法结束
#==============================================================================
attr_accessor :name
attr_accessor :rate
def self.get_g_rate(i)
if $game_party.gold != 0
p = @rate[i] * $game_party.gold
return p.to_i == 0? 1 : p.to_i
else
return 0
end
end
def self.get_n_rate(i, number)
if number != 0
p = @rate[i] * number
return p.to_i == 0? 1 : p.to_i
else
return 0
end
end
def self.number
return @name.size
end
def self.name(i)
return @name[i]
end
def self.id(i)
return @iname[i]
end
def self.show?(id)
return !(@do_not_show.include?(id))
end
def self.can_use?(id, item=nil)
return false if @cannot_use.include?(id)
unless item==nil
if item.get_currency_use != nil
return true if item.get_currency_use.include?(id)
end
if item.get_currency_not_use != nil
return false if item.get_currency_not_use.include?(id)
end
end
return true
end
end
class Game_Party < Game_Unit
attr_accessor :curr
alias c_ini initialize
def initialize
c_ini
@curr = []
for i in 0...Currency.number
if @curr[i] == nil
@curr[i] = 0
end
end
@curr[0] = @gold
end
# 获得和失去金钱
def gain_curr(type, amount)
@curr[type] = [[@curr[type] + amount, 0].max, 9999999].min
@gold = @curr[0]
end
def lose_curr(type, amount)
gain_curr(type, -amount)
end
def gain_gold(n)
gain_curr(0, n)
end
def curr(n)
return @curr[n] == nil ? 0 : @curr[n]
end
end
class Game_Interpreter
# 获取货币
def gain_currency(type, amount)
$game_party.gain_curr(type, amount)
end
# 失去货币
def lose_currency(type, amount)
$game_party.lose_curr(type, amount)
end
# 货币兑换
def convert(type, vid)
return Currency.get_n_rate(type, $game_variables[vid])
end
# 获取货币持有量
def currency_type(type, vid)
$game_variables[vid] = $game_party.curr(type)
end
end
class Scene_Menu < Scene_Base
alias c_menu_start start
def start
c_menu_start
if Currency::SHOW_NEW_CURRENCY
@gold_window.dispose
@gold_window = Window_SGold.new(0, 0)
@gold_window.y = 416-@gold_window.height
end
end
end
class RPG::BaseItem
def get_currency_use
e = []
self.note.split(/[\r\n]+/).each { |line|
if line =~ //
a = line.split(/ /)[1]
d = ""
while ((c = a.slice!(/./m)) != nil)
d += c if c != ">"
end
e.push(d.to_i)
end
}
return e==[] ? nil : e
end
def get_currency_not_use
e = []
self.note.split(/[\r\n]+/).each { |line|
if line =~ //
a = line.split(/ /)[1]
d = ""
while ((c = a.slice!(/./m)) != nil)
d += c if c != ">"
end
e.push(d.to_i)
end
}
return e==[] ? nil : e
end
end
#==============================================================================
# ■ Window_SGold
#------------------------------------------------------------------------------
# 新的显示金钱窗口,可以显示多重货币。
#==============================================================================
class Window_SGold < Window_Base
def initialize(x, y, c=-1)
a = 1
[url=home.php?mod=space&uid=26101]@Money[/url] = []
for i in 0...Currency::number
@money.push(i) if Currency.show?(i)
end
a = @money.size if c == -1
super(x, y, 160, a * WLH + 32)
@currency = c
refresh
end
def refresh
self.contents.clear
if @currency == -1
for i in @money
draw_scurrency_value(i, 4, i*WLH, 120)
end
else
draw_scurrency_value(@currency, 4, 0, 120)
end
end
def draw_scurrency_value(i, x, y, width)
cx = contents.text_size(Vocab::gold).width
self.contents.font.color = normal_color
self.contents.draw_text(x, y, width-cx-2, WLH, $game_party.curr(i), 2)
self.contents.font.color = system_color
self.contents.draw_text(x, y, width, WLH, Currency.name(i), 2)
end
end
#==============================================================================
# ■ Window_ShopBuy
#------------------------------------------------------------------------------
# 商店画面、浏览显示可以购买的商品的窗口。
#==============================================================================
class Window_ShopBuy < Window_Selectable
#--------------------------------------------------------------------------
# ● 初始化对像
# x : 窗口 X 座标
# y : 窗口 Y 座标
# c : 货币类型
#--------------------------------------------------------------------------
def initialize(x, y, c=0)
super(x, y, 304, 304)
@shop_goods = $game_temp.shop_goods
@currency = c
refresh
self.index = 0
end
#--------------------------------------------------------------------------
# ● 绘制商品
# index : 商品索引
#--------------------------------------------------------------------------
def draw_item(index)
item = @data[index]
number = $game_party.item_number(item)
price = Currency.get_n_rate(@currency, item.price)
gold = Currency.get_g_rate(@currency)
enabled = Currency.can_use?(@currency, item)
enabled = ( price <= gold and number < 99) if enabled
rect = item_rect(index)
self.contents.clear_rect(rect)
draw_item_name(item, rect.x, rect.y, enabled)
rect.width -= 4
self.contents.draw_text(rect,price, 2)
end
end
class Window_ShopStatus < Window_Base
alias curr_refresh refresh
def refresh
curr_refresh
currency = []
money = ""
if @item != nil
for i in 0...Currency::number
currency.push(i) if Currency.can_use?(i, @item)
end
for i in currency
money += "、" if i>0 and i<=currency.size
money += Currency.name(i)
end
string = sprintf(Currency::One_Currency, money)
self.contents.draw_text(4, 24, 200, WLH, string,1)
end
end
end
#==============================================================================
# ■ Scene_Shop
#------------------------------------------------------------------------------
# 处理商店画面的类。
#==============================================================================
class Scene_Shop < Scene_Base
#--------------------------------------------------------------------------
# ● 开始处理
#--------------------------------------------------------------------------
alias c_start start
def start
c_start
@currency = 0
@command = []
for i in 0...Currency::number
if Currency.can_use?(i)
@command.push(Currency::id(i))
end
end
@currency_window = Window_Command.new(160, @command, 1, 3)
@currency_window.x = 384
@currency_window.y = 56
@currency_window.active = false
@currency_window.visible = false
end
#--------------------------------------------------------------------------
# ● 结束处理
#--------------------------------------------------------------------------
alias c_term terminate
def terminate
c_term
@currency_window.dispose
end
#--------------------------------------------------------------------------
# ● 更新画面
#--------------------------------------------------------------------------
def update
super
update_menu_background
@help_window.update
@command_window.update
@gold_window.update
@dummy_window.update
@buy_window.update
@sell_window.update
@number_window.update
@status_window.update
@currency_window.update
if @command_window.active
update_command_selection
elsif @buy_window.active
update_buy_selection
elsif @sell_window.active
update_sell_selection
elsif @number_window.active
update_number_input
elsif @currency_window.active
update_currency_selection
end
end
#--------------------------------------------------------------------------
# ● 生成命令窗口
#--------------------------------------------------------------------------
def create_command_window
s1 = Vocab::ShopBuy
s2 = Vocab::ShopSell
s3 = Vocab::ShopCancel
s4 = Currency.word
@command_window = Window_Command.new(384, [s1, s2, s4, s3], 4)
@command_window.y = 56
if $game_temp.shop_purchase_only
@command_window.draw_item(1, false)
end
end
#--------------------------------------------------------------------------
# ● 更新命令窗口
#--------------------------------------------------------------------------
def update_command_selection
if Input.trigger?(Input::B)
Sound.play_cancel
$scene = Scene_Map.new
elsif Input.trigger?(Input::C)
case @command_window.index
when 0 # 买入
Sound.play_decision
@command_window.active = false
@dummy_window.visible = false
@buy_window.active = true
@buy_window.visible = true
@buy_window.refresh
@status_window.visible = true
when 1 # 卖出
if $game_temp.shop_purchase_only
Sound.play_buzzer
else
Sound.play_decision
@command_window.active = false
@dummy_window.visible = false
@sell_window.active = true
@sell_window.visible = true
@sell_window.refresh
end
when 3 # 离开
Sound.play_decision
$scene = Scene_Map.new
when 2 # 货币
@currency_window.active = true
@currency_window.visible = true
@command_window.active = false
@gold_window.visible = false
end
end
end
#--------------------------------------------------------------------------
# ● 更新货币选择窗口
#--------------------------------------------------------------------------
def update_currency_selection
if Input.trigger?(Input::B)
Sound.play_cancel
@currency_window.active = false
@currency_window.visible = false
@command_window.active = true
@gold_window.visible = true
elsif Input.trigger?(Input::C)
Sound.play_decision
@currency_window.active = false
@currency_window.visible = false
@command_window.active = true
@currency = @currency_window.index
@buy_window.dispose
@buy_window = Window_ShopBuy.new(0, 112, @currency)
@buy_window.active = false
@buy_window.visible = false
@gold_window.dispose
@gold_window = Window_SGold.new(384, 56, @currency)
end
end
#--------------------------------------------------------------------------
# ● 更新买入选择
#--------------------------------------------------------------------------
def update_buy_selection
@status_window.item = @buy_window.item
if Input.trigger?(Input::B)
Sound.play_cancel
@command_window.active = true
@dummy_window.visible = true
@buy_window.active = false
@buy_window.visible = false
@status_window.visible = false
@status_window.item = nil
@help_window.set_text("")
return
end
if Input.trigger?(Input::C)
@item = @buy_window.item
number = $game_party.item_number(@item)
price = Currency.get_n_rate(@currency, @item.price)
gold = Currency.get_g_rate(@currency)
enabled = Currency.can_use?(@currency, @item)
enabled = ( price <= gold and number < 99) if enable
unless enabled
Sound.play_buzzer
else
Sound.play_decision
max = price == 0 ? 99 : gold / @item.price
max = [max, 99 - number].min
@buy_window.active = false
@buy_window.visible = false
@number_window.set(@item, max, @item.price)
@number_window.active = true
@number_window.visible = true
end
end
end
#--------------------------------------------------------------------------
# ● 确认数值输入
#--------------------------------------------------------------------------
def decide_number_input
Sound.play_shop
@number_window.active = false
@number_window.visible = false
case @command_window.index
when 0 # 买入
gold = @number_window.number * @item.price
$game_party.lose_curr(@currency_window.index, gold)
$game_party.gain_item(@item, @number_window.number)
@gold_window.refresh
@buy_window.refresh
@status_window.refresh
@buy_window.active = true
@buy_window.visible = true
when 1 # 卖出
gold = @number_window.number * (@item.price / 2)
$game_party.gain_curr(@currency_window.index, gold)
$game_party.lose_item(@item, @number_window.number)
@gold_window.refresh
@sell_window.refresh
@status_window.refresh
@sell_window.active = true
@sell_window.visible = true
@status_window.visible = false
end
end
end
#==============================================================================
#==============================================================================
# 本脚本来自www.66RPG.com,使用和转载请保留此信息
#==============================================================================
复制代码
作者:
正太君
时间:
2014-8-12 20:01
你想改成什么样,应该给个草图出来吧...
欢迎光临 Project1 (https://rpg.blue/)
Powered by Discuz! X3.1