| 赞 | 7 |
| VIP | |
| 好人卡 | |
| 积分 | 15 |
| 经验 | |
| 最后登录 | 2026-6-20 |
| 在线时间 | 815 小时 |
- 梦石
- 0
- 星屑
- 1461
- 在线时间
- 815 小时
- 注册时间
- 2013-8-3
- 回帖
- 355
|
加入我们,或者,欢迎回来。
您需要 登录 才可以下载或查看,没有账号?注册会员
×
这个脚本某个事件可以正常购买东西关闭,在其他事件不管买不买东西,只要关闭商店时就出现错误,看不懂问题。
[pre lang="ruby"]=begin
===============================================================================
变量商店 By喵呜喵5
===============================================================================
【说明】
可以使用变量在商店进行购物
首先先在事件中使用脚本命令输入:shop_set(变量的ID,"变量的单位"),例如:
shop_set(1,"节操")
接着使用事件中的商店处理时,购买物品不会消耗金钱而是消耗对应的变量
使用命令shop_set可以恢复原来使用金钱购物的商店
=end
$m5script = {} if $m5script.nil?
$m5script["M5VARShop"] = true
module M5VARShop
#==============================================================================
# 设定部分
#==============================================================================
PRICE = false #true
#设置为true的情况下,变量商店物品的出售价格为【数据库中】物品售价的一半
#设置为false的情况下, 变量商店物品的出售价格为【该商店】物品售价的一半
VAR = 1
#这里设置一个没有使用到的变量的ID,游戏中请不要修改这个ID的变量数值
#==============================================================================
# 设定结束
#==============================================================================
end
class Game_Interpreter
def shop_set(gold=0,unit="")
gold = 0 if gold == M5VARShop::VAR
$game_variables[M5VARShop::VAR]=[gold,unit]
end
end
class Window_Gold_New < Window_Gold
def initialize(gold,unit)
@gold,@unit = gold,unit
super()
end
def value
@gold == 0 ? super : $game_variables[@gold]
end
def currency_unit
(@gold == 0 || @unit == "") ? super : @unit
end
end
class Scene_Shop
def create_gold_window
$game_variables[M5VARShop::VAR] = [0,""] if \
!$game_variables[M5VARShop::VAR].is_a?(Array)
@gold_window = Window_Gold_New.new($game_variables[M5VARShop::VAR][0],$game_variables[M5VARShop::VAR][1])
@gold_window.viewport = @viewport
@gold_window.x = Graphics.width - @gold_window.width
@gold_window.y = @help_window.height
end
alias m5_20140318_do_buy do_buy
def do_buy(number)
if $game_variables[M5VARShop::VAR][0] == 0
m5_20140318_do_buy(number)
else
$game_variables[$game_variables[M5VARShop::VAR][0]] -= number * buying_price
$game_party.gain_item(@item, number)
end
end
alias m5_20140318_do_sell do_sell
def do_sell(number)
if $game_variables[M5VARShop::VAR][0] == 0
m5_20140318_do_sell(number)
else
$game_variables[$game_variables[M5VARShop::VAR][0]] += number * selling_price
$game_party.lose_item(@item, number)
end
end
alias m5_20140318_selling_price selling_price
def selling_price
return m5_20140318_selling_price if M5VARShop::PRICE || $game_variables[M5VARShop::VAR][0] == 0
buying_price / 2
end
end[/pre] |
-
-
|