Mr Trivel Crafting Addon

Discussion in 'RGSS3 Scripts (RMVX Ace)' started by Roninator2, Jun 12, 2019.

  1. Roninator2

    Roninator2 Gamer Veteran

    Messages:
    1,705
    Likes Received:
    376
    Location:
    Canada
    First Language:
    English
    Primarily Uses:
    RMVXA
    I made this for my game but I think it's really good to share this as it works well and I'm happy with my Ruby skills so far.

    Base script
    https://mrtrivelvx.wordpress.com/2014/06/25/crafting-simple/

    Mr Trivel Crafting 1.01 Addon
    Roninator2
    Introduction

    Adds returning of items if they are specified in the note tag
    Essentially making it so that you do not lose the tagged item

    Features
    The concept is that you can have items that are 'super' items
    which will not be lost and replace other items in the recipe
    Can also replace multiple items

    Screenshots

    upload_2019-6-12_17-23-57.png
    upload_2019-6-12_17-25-30.png

    How to Use
    Place the note tag <swap craft: X> on the item, weapon, armor
    you wish to be recovered in the item that would normally get used
    So on item 15 you say <swap craft: 20>
    The recipe needs item 15, but it gets substituted for item 20
    When you craft the item, item 20 is not lost, neither is item 15.

    Script
    Code:
    # )----------------------------------------------------------------------------(
    # )--     AUTHOR:     Mr. Trivel                                             --(
    # )--     NAME:       Crafting Simple                                        --(
    # )--     CREATED:    2019-06-10                                             --(
    # )--     VERSION:    1.0.1                                                  --(
    # )--     ADD ON:     Roninator2                                             --(
    # )----------------------------------------------------------------------------(
    # )--                          DESCRIPTION                                   --(
    # )--  Adds returning of items if they are specified in the note tag         --(
    # )--  Essentially making it so that you do not lose the tagged item         --(
    # )----------------------------------------------------------------------------(
    # )--                          DESIGN                                        --(
    # )--  I designed this for my own game Path of Life                          --(
    # )--  The concept is that you can have items that are 'super' items         --(
    # )--  which will not be lost and replace other items in the recipe          --(
    # )----------------------------------------------------------------------------(
    # )--                          IMPORTANT                                     --(
    # )--  The tagged item must be in your inventory                             --(
    # )--  Can only substitute items for items, weapons for weapons etc          --(
    # )----------------------------------------------------------------------------(
    # )--                          INSTRUCTIONS                                  --(
    # )--  Place the note tag <swap craft: X> on the item, weapon, armor         --(
    # )--  you wish to be recovered in the item that would normally get used     --(
    # )--  So on item 15 you say <swap craft: 20>                                --(
    # )--  The recipe needs item 15, but it gets substituted for item 20         --(
    # )--  When you craft the item, item 20 is not lost, neither is item 15.     --(
    # )----------------------------------------------------------------------------(
    
    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
    

    Credit and Thanks
    - Roninator2
    - Mr Trivel

    Author's Notes
    Follow Mr Trivel's Term of Use.
     
    Last edited: Jun 13, 2019
    #1
    Tetsune and Romanticist like this.
  2. mlogan

    mlogan Global Moderators Global Mod

    Messages:
    13,796
    Likes Received:
    7,616
    Location:
    Texas
    First Language:
    English
    Primarily Uses:
    RMMV
    As this is a completed script, and not a request, I've moved it to scripts.
     
    #2
  3. Romanticist

    Romanticist Veteran Veteran

    Messages:
    187
    Likes Received:
    97
    First Language:
    English
    Primarily Uses:
    RMVXA
    Your menus look really cool! Is it Luna engine?
     
    #3
  4. Roninator2

    Roninator2 Gamer Veteran

    Messages:
    1,705
    Likes Received:
    376
    Location:
    Canada
    First Language:
    English
    Primarily Uses:
    RMVXA
    Yes Luna engine. With images commissioned for my game.
    Thanks for pointing that out, I should use generic screens to show case this.
     
    Last edited: Jun 16, 2019
    #4
    Romanticist likes this.

Share This Page