查看: 2105|回复: 11

[已经解决] 请问如何使用特定的物品时更换说明文字?

[复制链接]
梦石
0
星屑
8498
在线时间
775 小时
注册时间
2017-11-10
回帖
1074
发表于 2018-1-27 13:04:39 | 显示全部楼层 |阅读模式

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

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

×
模组Vocab内有个UseItem说明文字。
我想添加一个UseItem2,用于使用特定的物品的说明文字。
但在Scene_Battle内的
[pre lang="ruby"] def execute_action_item
    item = @active_battler.action.item
###
    text = sprintf(Vocab::UseItem, @active_battler.name, item.name)
###
    @message_window.add_instant_text(text)
    targets = @active_battler.action.make_targets
    display_animation(targets, item.animation_id)
    $game_party.consume_item(item)
    $game_temp.common_event_id = item.common_event_id
    for target in targets
      target.item_effect(@active_battler, item)
      display_action_effects(target, item)
    end
  end[/pre]
不知道该怎么判断物品的ID,物品不只是一个。
如图:
使用一般物品时的说明。
360截图20180127125907656.png
使用特别物品时的说明。
360截图20180127130024781.png
请问该怎么修改和判断?
一个只会简单事件的Rm新人,脚本完全不懂。只求做个简单的游戏完成自己的游戏之梦而已。
第一个游戏已经完成,等待各素材的完成和测试。
梦石
0
星屑
9292
在线时间
2504 小时
注册时间
2011-5-20
回帖
14521

开拓者

发表于 2018-1-27 13:51:48 | 显示全部楼层
  1. text = sprintf(Vocab::UseItem, @active_battler.name, item.name)
复制代码

item就是正在使用的物品/技能

点评

直接.id啊···  发表于 2018-1-27 18:20
?这点我知道,我要判断使用的物品ID。  发表于 2018-1-27 18:10
[img]http://service.t.sina.com.cn/widget/qmd/5339802982/c02e16bd/7.png
回复

使用道具 举报

梦石
0
星屑
19426
在线时间
3082 小时
注册时间
2013-1-11
回帖
1207
发表于 2018-1-27 18:20:43 | 显示全部楼层
物品应该应该是item.id来判断吧

评分

参与人数 1星屑 +50 收起 理由
正太君 + 50 认可答案

查看全部评分

回复

使用道具 举报

梦石
0
星屑
8498
在线时间
775 小时
注册时间
2017-11-10
回帖
1074
 楼主| 发表于 2018-1-27 18:29:28 | 显示全部楼层
张咚咚 发表于 2018-1-27 18:20
物品应该应该是item.id来判断吧

if [15]..include?(Item.id)
text = sprintf(Vocab::UseItem2, @active_battler.name, item.name)
  else
text = sprintf(Vocab::UseItem, @active_battler.name, item.name)
   end
这样写吗?
好吧,我是瞎写的。

点评

明白了,谢谢。  发表于 2018-1-27 19:03
可以第一层先判断类别,然后下面用case when x,x,when...  发表于 2018-1-27 18:55
谢谢前辈的指教。再问下如果这样的物品比较多又要怎么写?一个个的判断?  发表于 2018-1-27 18:40
嗯  发表于 2018-1-27 18:37
if item.is_a?(RPG::Item) and item.id == 15 这样对吧...  发表于 2018-1-27 18:35
一个只会简单事件的Rm新人,脚本完全不懂。只求做个简单的游戏完成自己的游戏之梦而已。
第一个游戏已经完成,等待各素材的完成和测试。
回复

使用道具 举报

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

本版积分规则

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

在本版发帖返回顶部