Szyu

Villager
Member
Joined
Aug 22, 2013
Messages
29
Reaction score
62
First Language
German
Primarily Uses
Szyu's Item Usage Redirection
 
Introduction
Redirects an items usage effect, when certain conditions are met.


Get it at Pastebin
 
 
How to Use

<usage_redirection> and </usage_redirection> mark the condition area in an Item's notes
In this block, you can add redirection with
 

id - conditionExample:

<usage_redirection>20 - class_id == 2</usage_redirection>In this example, the used item's effect is redirected to item[20], if the
target's class_id is 2
 
Possible conditions could be everything, that could be done with script call
or from Game_Battler as class (for example id for actor's id, or $game_variables[x])
 
 
Credits
Credits to Szyu if you plan to use this script.

Terms of Use
You are free to use this script for commercial and non-commercial projects. However I'd like you to inform me of the projects you are planning to use it in, so I can keep track of where my scripts are used. 
 
Last edited by a moderator:

Kes

Veteran
Veteran
Joined
Aug 3, 2012
Messages
23,594
Reaction score
13,382
First Language
English
Primarily Uses
RMMZ
Again, it would be helpful to put your Terms of Use commercial/non commercial in the opening post.

This looks particularly interesting.  Nice idea.
 

alexncf125

Veteran
Veteran
Joined
Mar 21, 2016
Messages
53
Reaction score
1
First Language
English
Primarily Uses


Line 47 to 51,

def use_item(item)
old_item = item.clone
sz_iurd_use_item(item)
consume_item(old_item) if item.is_a?(RPG::Item) && old_item != item
end

Does anyone know what the above script is doing?

This script will cause the item to be consumed twice.
Did the author make a mistake?
 

Shaz

Keeper of the Nuts
Global Mod
Joined
Mar 2, 2012
Messages
46,006
Reaction score
16,823
First Language
English
Primarily Uses
RMMV

I have merged your post into the thread for the script



If we have the thread here for the script, you can just post your questions/issues right there, rather than starting a new post. This could help get attention sooner, from the script creator, as they might be subscribed to the thread.

It doesn't seem like that to me. Have you actually added the script to your game and played it, and confirmed that it DOES consume the item twice? If so, please show a screenshot so we can see how you've set it up.
 
Last edited:

Roninator2

Gamer
Veteran
Joined
May 22, 2016
Messages
4,825
Reaction score
1,372
First Language
English
Primarily Uses
RMVXA
Does anyone know what the above script is doing?
Did you not understand the instructions?

Since the script allows you to redirect effects to a different item, the script is simply applying the affects of item x and then removing item y (item used).

But like Shaz said, you should test scripts before questioning if they work.
I would also ask that the next time you post code to use a code block, not paste it as plain text.
I understood how the code was actually written when looking at the script itself.
 
Last edited:

alexncf125

Veteran
Veteran
Joined
Mar 21, 2016
Messages
53
Reaction score
1
First Language
English
Primarily Uses
未命名.png
MuRWgz.gif


I don't understand why you guys think I'm asking this question without testing it.

Just build a new project and paste the script in the script editor,
Not even a <usage_redirection>......</usage_redirection> tag in any item's note box.
When there are two potions in the inventory, just using one potion will consume two potions.

To Shaz:
Sorry, because the author was last online in 2021,
So I thought it would be more efficient to solve my problem by opening a new thread.
 
Last edited:

Roninator2

Gamer
Veteran
Joined
May 22, 2016
Messages
4,825
Reaction score
1,372
First Language
English
Primarily Uses
RMVXA
I don't understand why you guys think I'm asking this question without testing it.

Just build a new project and paste the script in the script editor,
Not even a <usage_redirection>......</usage_redirection> tag in any item's note box.
When there are two potions in the inventory, just using one potion will consume two potions.
Apologies. Didn't expect this to actually be an issue since the script is so old, who would have thought this issue was not discovered until now.

I believe the issue can be corrected if the method in question was changed to this
Ruby:
  def use_item(item)
    old_item = item.clone
    sz_iurd_use_item(item)
    consume_item(old_item) if item.is_a?(RPG::Item) && old_item.id != item.id
  end

The bug is real because when the item is cloned it creates a new reference in memory and thus they are different so it removes the item since they are not the same.
 
Last edited:

alexncf125

Veteran
Veteran
Joined
Mar 21, 2016
Messages
53
Reaction score
1
First Language
English
Primarily Uses
Apologies. Didn't expect this to actually be an issue sine the script is so old, who would have thought this issue was not discovered until now.

I believe the issue can be corrected if the method in question was changed to this
Ruby:
  def use_item(item)
    old_item = item.clone
    sz_iurd_use_item(item)
    consume_item(old_item) if item.is_a?(RPG::Item) && old_item.id != item.id
  end

The bug is real because when the item is cloned it creates a new reference in memory and thus they are different so it removes the item since they are not the same.
I would like to ask, what is the rationale for this change?
In other words, when is "old_item.id" not equal to "item.id"?
"old_item.id" and "tem.id" will be same when I use <usage_redirection> tag or not.
 
Last edited:

Roninator2

Gamer
Veteran
Joined
May 22, 2016
Messages
4,825
Reaction score
1,372
First Language
English
Primarily Uses
RMVXA
In other words, when is "old_item.id" not equal to "item.id"?
"old_item.id" and "tem.id" will be same when I use <usage_redirection> tag or not.
You are entirely right. All that does is stop the bug, but really we can delete that method entirely.
I tested it and it works as expected without the use_item method.
 

alexncf125

Veteran
Veteran
Joined
Mar 21, 2016
Messages
53
Reaction score
1
First Language
English
Primarily Uses
You are entirely right. All that does is stop the bug, but really we can delete that method entirely.
I tested it and it works as expected without the use_item method.
Thank you for all the help today.
Hope it helps someone who has the same problem in the future.
 

Latest Threads

Latest Profile Posts

Next Up. The 2nd floor of the Western Academy!

Base:
Map012.png

With a little parallax magic *:



WestAcademyFl2.png


Anything you'd add?
BUwvmx.png


Introducing a new and exciting challenge mode!! Is our demo too easy? Did you get a rare pull and want to show off on stream? Please talk to the mysterious 2nd announcer who has 6 additional challenges PER ROUND! As a game developer, I struggled to complete some of the stage 2 challenges, so I hope you tactics fans have a blast!
AeroPergold wrote on Woratana's profile.
You gucci, Woratana?
so wild I came across a video about side-scrollers for RPG Maker and my game was used as an example in the video. I really felt honored to be honest.
hi all. Is this video working for you? It's published on YT but i've had people say they can't view it?!

Forum statistics

Threads
131,639
Messages
1,221,822
Members
173,384
Latest member
dreamless
Top