Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # ╔═════════════════════════════════════╦════════════════════╗
- # ║ Title: Swap Craft ║ Version: 1.00 ║
- # ║ Author: Roninator2 ║ ║
- # ╠═════════════════════════════════════╬════════════════════╣
- # ║ Function: ║ Date Created ║
- # ║ Mr Trivel Crafting - ╠════════════════════╣
- # ║ Lets you swap items in the receipe ║ 01 Nov 2020 ║
- # ╚═════════════════════════════════════╩════════════════════╝
- # ╔══════════════════════════════════════════════════════════╗
- # ║ Allows swapped items to be returned to inventory ║
- # ║ and not used when the item is crafted. ║
- # ║ ║
- # ║ Can only substitute items for items, weapons for weapons ║
- # ║ The notetag is placed on the receipe ingredients ║
- # ║ not the item getting swapped in. ║
- # ║ ║
- # ║ Then if the swap item is in your inventory, the ║
- # ║ original item is not used. ║
- # ║ ║
- # ║ Use note tag <swap craft: X> on the item, weapon, armor ║
- # ║ x being the id of the item, weapon used for crafting ║
- # ╚══════════════════════════════════════════════════════════╝
- # ╔═════════════════════════════════════╗
- # ║ Terms of use: ║
- # ║ Follow the Original Authors terms ║
- # ╚═════════════════════════════════════╝
- module R2
- module Trivel_Craft
- Regex = /<swap[-_ ]craft:[-_ ]\s*(\d+)\s*>/imx
- end
- end
- class MrTS_Requirements_Window < Window_Base
- def set_recipe(item)
- return unless item
- @recipe = item
- @item_list = []
- @saveitem = []
- MrTS::Crafting::RECIPES[@recipe][:ingredients].each { |i|
- type = i[0].to_i
- if type == 0
- item = $data_items[i[1]]
- results = item.note.scan(R2::Trivel_Craft::Regex)
- results.each do |res|
- repitem = res[0].to_i
- if $game_party.has_item?($data_items[repitem], false)
- @item_list.delete(i)
- i = [type, repitem, 1]
- @saveitem << i
- @saveitem.uniq!
- end
- end
- end
- if type == 1
- item = $data_weapons[i[1]]
- results = item.note.scan(R2::Trivel_Craft::Regex)
- results.each do |res|
- repitem = res[0].to_i
- if $game_party.has_item?($data_weapons[repitem], false)
- @item_list.delete(i)
- i = [type, repitem, 1]
- @saveitem << i
- @saveitem.uniq!
- end
- end
- end
- if type == 2
- item = $data_armors[i[1]]
- results = item.note.scan(R2::Trivel_Craft::Regex)
- results.each do |res|
- repitem = res[0].to_i
- if $game_party.has_item?($data_armors[repitem], false)
- @item_list.delete(i)
- i = [type, repitem, 1]
- @saveitem << i
- @saveitem.uniq!
- end
- end
- end
- @item_list.push(get_true_item(i))
- @item_list.uniq!
- }
- refresh
- end
- alias r2_trivel_craft_item_83v craft_item
- def craft_item
- r2_trivel_craft_item_83v
- @saveitem.each do |il|
- keep = get_true_item(il)
- $game_party.gain_item(keep[0], keep[1])
- end
- end
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement