查看: 2365|回复: 1

[已经解决] 变量商店脚本出错了

[复制链接]
梦石
0
星屑
1461
在线时间
815 小时
注册时间
2013-8-3
回帖
355
发表于 2016-5-28 13:21:41 | 显示全部楼层 |阅读模式

加入我们,或者,欢迎回来。

您需要 登录 才可以下载或查看,没有账号?注册会员

×
这个脚本某个事件可以正常购买东西关闭,在其他事件不管买不买东西,只要关闭商店时就出现错误,看不懂问题。


[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]
1.png
2.png

【同人游戏】勇者斗恶龙TG
欢迎加入游戏测试群333599798
如有需私聊请加QQ:516425000

梦石
1
星屑
23246
在线时间
9564 小时
注册时间
2012-6-19
回帖
7018

开拓者短篇九导演组冠军

发表于 2016-5-28 13:25:16 | 显示全部楼层
本帖最后由 喵呜喵5 于 2016-5-28 14:47 编辑

你的某个事件的出现条件是否设置成了变量商店脚本所使用的变量了?

(另外,我看了下这段代码,稍微有点旧了,之后我更新一个兼容性更好的版本


==========


变量商店脚本更新了一个更好的版本

https://rpg.blue/home.php?mod=sp ... o=blog&id=12019

(请注意,使用方法相对旧版发生了细微变化)

点评

太棒了!萌萌哒~~  发表于 2016-5-29 00:21

评分

参与人数 1梦石 +1 收起 理由
VIPArcher + 1 认可答案

查看全部评分

回复

使用道具 举报

您需要登录后才可以回帖 登录 | 注册会员

本版积分规则

Powered by Discuz! X5.0 © 2001-2026 Discuz! Team.

在本版发帖返回顶部