RMRK is retiring.
Registration is disabled. The site will remain online, but eventually become a read-only archive. More information.

RMRK.net has nothing to do with Blockchains, Cryptocurrency or NFTs. We have been around since the early 2000s, but there is a new group using the RMRK name that deals with those things. We have nothing to do with them.
NFTs are a scam, and if somebody is trying to persuade you to buy or invest in crypto/blockchain/NFT content, please turn them down and save your money. See this video for more information.
Grid Inventory System

0 Members and 2 Guests are viewing this topic.

*
Rep:
Level 97
2014 Most Unsung Member2014 Best RPG Maker User - Engine2013 Best RPG Maker User (Scripting)2012 Most Mature Member2012 Favorite Staff Member2012 Best RPG Maker User (Scripting)2012 Best MemberSecret Santa 2012 ParticipantProject of the Month winner for July 20092011 Best Use of Avatar and Signature Space2011 Best RPG Maker User (Scripting)2011 Most Mature Member2011 Favourite Staff Member2011 Best Veteran2010 Most Mature Member2010 Favourite Staff Member
*This script has been taken down due to some major bugs. It is being rewritten and this thread will be revived once it is complete*

Grid Inventory
Version: 1.0
Author: modern algebra
Date: Novemeber 3, 2007

Version History


  • Version 1.0 -  Original; all current features

Description


This script does multiple things. First: it gives each actor their own inventory. Second: that inventory is displayed through a grid, with each item taking up a specific amount of squares. How many squares is completely customizable for each and every item. You are also able to set a maximum number of instances of that item each slot can hold. This means that for each item, say for instance, arrows, you can define how many arrows could fit into one displayed slot of arrows. See the demo for clarification. You can also set a picture graphic for each item, though it is not necessary. Beyond that, you can easily set up permanent storage events, each of which are easy to set up and save what items are stored in them at any given time. Items will be automatically distributed amongst the party. If, upon gaining an item, you cannot fit that item or items into the party member's inventories, it will call up a loot inventory and you can decide which items to discard and which to keep. As well, you can customize the size of each actor's inventory and you can modify that at any time with a simple script call. A good system to compare this to is the system from Betrayal at Krondor, as that is what it was based on, but as that is not very well known, this system is similar to the item system of the Diablo series.

Features

  • Limited Inventory
  • Each actor has his own inventory, and the size of his inventory can be changed at any time, to a maximum of 12 x 12 slots
  • The inventory is displayed on a grid. Through this grid, you can move, discard, equip, use, transfer items to another player, and view detailed information on each item.
  • You can customize the exact number of squares each item takes up, as well as the maximum stack size. You can even set a picture to represent that item in the inventory.
  • You can set permanent storage chests which can not only come with items for the party to retrieve, but also allows the party to store their excess items. You can also set the exact size of these storage boxes.
  • In battle, each actor can only use what items are in his inventory, thus adding some strategy to any battle system
  • And much more...

Screenshots
Aluxes' Inventory


The command options


The other command options


Moving an Item


The Item Details Window


Transferring an Item


Discarding a battle axe



Instructions

It's pretty simple. Basically, you need to put the script provided above main. Then, get my Paragraph Formatter and put it above this script. It is important that you get that! The script will throw errors at you without it. Get the facade as well. It is in the topic right underneat the script. Then, you will notice at the top of the script there are three Constants to be set, ELEMENTAL_ICON_ARRAY, DEFAULT_GRID_WIDTH, and DEFAULT_GRID_HEIGHT. Set those as you please. The more difficult part comes with defining the widths, heights, and maximum stack sizes of the items. This is done through a text document called Item Data. You can do this in two ways.

(1) By using the Item Data Generator attached. This is a visual way of seeing what you are doing. Download it and instructions are inside. This way iss best if you need to define a majority of the items. Basically, all you need to do is copy your databases into the Item Data Generator and run it, setting input where it is necessary. I used cybersam's keyboard script for the input of it, so thank him when you are using it.

(2) Manually, by modifying the text document itself. This is best for minor revisions and additions. Basically, the text document is set up like this:
Code: [Select]
Items
100,200,100,
1,1,5,
1.2,5,
...
Weapons
150,240,35,
1,4,1,scimitar.png
1,4,1,
...
Armors
100,100,100,
3,4,1,
4,3,1,
...

What does that mean? Basically, the headings Items, Armors, and Weapons signify that the numbers below it will correspond to Items, Weapons, or Armors. The next three numbers are the color you associate with that type of item. The first number is red, the second is green, the third is blue. You can experiment with these colours to determine which ones should represent which grouping of items. All the lines following that and before the next header (or the end of the file in the case of Armors), correspond to each item, weapon or armor ID. Therefore, the line immediately following the colour corresponds to Item # 1, the next to Item #2, etc... Basically, the first number in each line is the width of the item (in squares, not in pixels), the next number is the height, the third number is how many of that type of item can fit into one stack, and then, you can put the name of the picture to associate with that item. If you leave that blank, then it will just use the icon. Any picture name you put there should have the extension, and the file ought to be in the pictures folder of the graphics folder. If not, you will get errors. Also, there should be three commas on each line, or else you might get an error. Always put it like this:

1,2,1,

and never

1, 2, 1

The text file should be named Item Data. If it is not, you will get an error. A sample Item Data text file is included in the attachment at the bottom of this post. I recommend you follow that as a guide whenever you manually edit your Item Data text file.

You also need to have a png called Loot Bitmap in your pictures folder. I will eventually release a full pack of item pictures, and include a few good ones for loot, storage, etc...

Script


Too long. See attached.

Credit


  • modern algebra

Support


Contact me here or at RMRevolution for support on this script. I will fix any bugs for you, and I am willing to integrate the script into any CMS you might have. I likely will not write anything extra that you may suggest, unless it is something I can use for my game. I already have a few parts of this script I am not releasing, because I plan on having them in my game.

Known Compatibility Issues

No known compatibility issues, but probably some exotic CMSes, CBSes, and the SDK. I have not tested it with any of those though. This will not work for old save games.

Demo


See Attached.
As well, there are a few sample item pictures, a sample Item Data.txt, and the Item Data Generator included. The demo includes instructions on some of the functions of the script, like storage boxes and resizing actor inventories.

« Last Edit: March 12, 2008, 10:20:33 PM by modern algebra »

*******
Rep:
Level 90
Returned from the dead.
Heh, I see you finally got it done :D
I might check this out in my game soon ;) Rep + to you my friend :P
Sincerely,
Your conscience.

********
Licks
Rep:
Level 91
Sexual Deviant
Question, to do you have to use pictures for it, (I mean like not the icons) because I want to use the pictures space for something else.

And if I do, is the picture limit really 50? And if it is, can I expand it?

*
Rep:
Level 97
2014 Most Unsung Member2014 Best RPG Maker User - Engine2013 Best RPG Maker User (Scripting)2012 Most Mature Member2012 Favorite Staff Member2012 Best RPG Maker User (Scripting)2012 Best MemberSecret Santa 2012 ParticipantProject of the Month winner for July 20092011 Best Use of Avatar and Signature Space2011 Best RPG Maker User (Scripting)2011 Most Mature Member2011 Favourite Staff Member2011 Best Veteran2010 Most Mature Member2010 Favourite Staff Member
Umm... eh?

Well, the system does not require pictures. It will use the icon of the respective item if you do not set a picture to it.

I think you are confused a little though. There is a 50 picture limit when displaying pictures through events. However, the pictures folder can contain any number of pictures without any negative effects. And as this is a script, it is not restricted by any picture limits. This script will not inhibit your ability to display pictures through events in any way.

*
I love Firerain
Rep:
Level 97
=D
Omg, this is hawt.
Great work.
Arlen is hot.

*
Rep:
Level 97
2014 Most Unsung Member2014 Best RPG Maker User - Engine2013 Best RPG Maker User (Scripting)2012 Most Mature Member2012 Favorite Staff Member2012 Best RPG Maker User (Scripting)2012 Best MemberSecret Santa 2012 ParticipantProject of the Month winner for July 20092011 Best Use of Avatar and Signature Space2011 Best RPG Maker User (Scripting)2011 Most Mature Member2011 Favourite Staff Member2011 Best Veteran2010 Most Mature Member2010 Favourite Staff Member
Thanks.

Hmm... I am thinking of a few minor revisions to the script, primarily in what is saved in the placements of the script (it currently saves item, as in the entire RPG::Item or RPG::Weapon or RPG::Armor) and I figure that is kind of pointless since for the few situations where I need all that stuff, if I saved item_id and type I would be able to access it.

The other thing, somewhat inspired by Forcystus' question, is to give the pictures you use for this script their own folder in Graphics. The reason is not because there is any limit to how many pictures can go in the Pictures folder, but rather just to remove that clutter for when you want to display pictures normally. Basically, you wouldn't need to look through a ton of item pictures in order to find the one you want to display. It would reduce clutter. The downside to this is that you would lose the ability to import them through the Resource Manager, meaning you would need to set transparency manually. What do you guys think is the better option?

********
Licks
Rep:
Level 91
Sexual Deviant
Ooooh, so I COULD have 10000000 pictures, but I can only use 50 in events?
And the others I just use in the inventory script?

*
Rep:
Level 97
2014 Most Unsung Member2014 Best RPG Maker User - Engine2013 Best RPG Maker User (Scripting)2012 Most Mature Member2012 Favorite Staff Member2012 Best RPG Maker User (Scripting)2012 Best MemberSecret Santa 2012 ParticipantProject of the Month winner for July 20092011 Best Use of Avatar and Signature Space2011 Best RPG Maker User (Scripting)2011 Most Mature Member2011 Favourite Staff Member2011 Best Veteran2010 Most Mature Member2010 Favourite Staff Member
You can only display 50 pictures through events at any single moment. But if you wanted to you could display 50 pictures in one moment, and 50 entirely different pictures in another moment, and so on. And yeah, you can have any amount of pictures that you want in the folder, accessible to all events.
« Last Edit: November 10, 2007, 01:36:31 AM by modern algebra »

********
Licks
Rep:
Level 91
Sexual Deviant
You just made a huge problem I was having with pictures go away, you are awesome. I love this script.

EDIT: Where do I put the item data?
« Last Edit: November 10, 2007, 04:46:22 AM by Brick Shitter »

****
Rep:
Level 87
In my own little world...
Friggin' sweet.
You did good!  :D

Im so proud of you!

*
Rep:
Level 97
2014 Most Unsung Member2014 Best RPG Maker User - Engine2013 Best RPG Maker User (Scripting)2012 Most Mature Member2012 Favorite Staff Member2012 Best RPG Maker User (Scripting)2012 Best MemberSecret Santa 2012 ParticipantProject of the Month winner for July 20092011 Best Use of Avatar and Signature Space2011 Best RPG Maker User (Scripting)2011 Most Mature Member2011 Favourite Staff Member2011 Best Veteran2010 Most Mature Member2010 Favourite Staff Member
You just made a huge problem I was having with pictures go away, you are awesome. I love this script.

EDIT: Where do I put the item data?

The text file just goes in the project folder, where the exe, Graphics, Audio, Data folders all are.

Friggin' sweet.
You did good!  :D

Im so proud of you!

Thanks  :lol:. I'm glad you like it

********
Licks
Rep:
Level 91
Sexual Deviant
I love the script, its pure awesome, and thanks for the help

********
Shadow Knight
Rep:
Level 91
Ruin that brick wall!
Project of the Month winner for October 2008
One huge word:AWESOME!
+Rep
Be kind, everyone you meet is fighting a hard battle.

*
Rep:
Level 97
2014 Most Unsung Member2014 Best RPG Maker User - Engine2013 Best RPG Maker User (Scripting)2012 Most Mature Member2012 Favorite Staff Member2012 Best RPG Maker User (Scripting)2012 Best MemberSecret Santa 2012 ParticipantProject of the Month winner for July 20092011 Best Use of Avatar and Signature Space2011 Best RPG Maker User (Scripting)2011 Most Mature Member2011 Favourite Staff Member2011 Best Veteran2010 Most Mature Member2010 Favourite Staff Member
Thanks everyone.

Next version, after I develop a Mouse Interaction Tool for Zeriab's Scripting Contest, I will add possible mouse functionality. It will be pretty cool :). Naturally, you could turn it off.

I think I will actually wait for VX before I make any major modifications though, and then I will rewrite the entire thing.

***
Rep:
Level 88
OMFG
I had a diablo-style inventory previously, but this one kicks its ASS!

This is one of the greatest scripts I've seen, and I'm definintaly going to use it.

To anyone: It is very easy to get the grahics, all I did was for the chests Google image search for wooden chest. For sword? Sword, sheild sheild, ect. Very easy to jsut go into paint and change the backround color so you can import it.
Games in progress:
Tome of Arastovia: 7% complete at 2 hours of gametime

**
Rep: +0/-0Level 86
I am not that good at scripting but am a writer, if anyone could please tell me the code that will open the storage system (like the chest in the actually tutorial)? Please would someone held me  ???


Current Games:
Darklands (Demon Slayer [new name])

Scripting - About 55% complete.

Eventing - About 1% complete.

Mapping - About .5% complete.

Spriting - 0% complete.

*
Rep:
Level 97
2014 Most Unsung Member2014 Best RPG Maker User - Engine2013 Best RPG Maker User (Scripting)2012 Most Mature Member2012 Favorite Staff Member2012 Best RPG Maker User (Scripting)2012 Best MemberSecret Santa 2012 ParticipantProject of the Month winner for July 20092011 Best Use of Avatar and Signature Space2011 Best RPG Maker User (Scripting)2011 Most Mature Member2011 Favourite Staff Member2011 Best Veteran2010 Most Mature Member2010 Favourite Staff Member
Well, the demo is open I believe. If you take a look at the chest, you will see the code is like this:

Code: [Select]
i = [[1,1,2],[0,5,8],[1,5,3]]
s = [7,7]
n = 'Wooden Chest'
b = "Loot Bitmap.png"
$game_system.item_storage.open(0, i,
s, n, b)

What each of the letters is is explained inside the chest event through comments. In short, s is the size, x by y. n is the name, b is the picture, i are the items.

Each item is represented by a 3 element array designed like this: [type, item_id, amount], where for type: 0 => Item, 1 => Weapon, 2=> Armor, and the item id is the ID of it.

The first number when you open the chest is the ID of the chest.

@pliio I am glad you like it.

**
Rep: +0/-0Level 86
I keep getting a wierd error here is the text "Script 'Window_BackPackInfo' line 194:NoMethodError occured
                                                                       unidentified method 'new_paragraph' for #<bitmap:0x1ef1eb0>


That happens when I open my 'wooden chest' or as I call it stash or storage and it also happens when I look over an unequipted item?

Was it a part of my 'Item Data' text doc. ?

What did I do wrong? (could someone please awnser?)      (i'm horrible at scripting  :-\ ) (lol)


Current Games:
Darklands (Demon Slayer [new name])

Scripting - About 55% complete.

Eventing - About 1% complete.

Mapping - About .5% complete.

Spriting - 0% complete.

*
Rep:
Level 97
2014 Most Unsung Member2014 Best RPG Maker User - Engine2013 Best RPG Maker User (Scripting)2012 Most Mature Member2012 Favorite Staff Member2012 Best RPG Maker User (Scripting)2012 Best MemberSecret Santa 2012 ParticipantProject of the Month winner for July 20092011 Best Use of Avatar and Signature Space2011 Best RPG Maker User (Scripting)2011 Most Mature Member2011 Favourite Staff Member2011 Best Veteran2010 Most Mature Member2010 Favourite Staff Member
Did you copy the Paragraph Formatter script into your game?

**
Rep: +0/-0Level 86
Yes, and it's right above those bunch of scripts that make the grid inventory. But I didn't copy those .DOC files that were in the demo's folder into my game's folder...is that the reason. Or maybe it could be the fact that my 'item data' text document only has 'items' writen in it. Is it one of those?


Current Games:
Darklands (Demon Slayer [new name])

Scripting - About 55% complete.

Eventing - About 1% complete.

Mapping - About .5% complete.

Spriting - 0% complete.

*
Rep:
Level 97
2014 Most Unsung Member2014 Best RPG Maker User - Engine2013 Best RPG Maker User (Scripting)2012 Most Mature Member2012 Favorite Staff Member2012 Best RPG Maker User (Scripting)2012 Best MemberSecret Santa 2012 ParticipantProject of the Month winner for July 20092011 Best Use of Avatar and Signature Space2011 Best RPG Maker User (Scripting)2011 Most Mature Member2011 Favourite Staff Member2011 Best Veteran2010 Most Mature Member2010 Favourite Staff Member
Nah, it's the Paragraph Formatter. Copy the version that is in the folder into your game and replace the one you have now. I changed the PF a little bit.

As to the Item Data, you should add the Weapons and Armors in. It's not causing this error, but it will cause an error if you try to access data for a weapon or armor.

**
Rep: +0/-0Level 86
Thank you very very very very very much for the help... 8)


*EDIT:There is already stuff inside the storage,can I change it so it starts with nothing in it?

*EDIT:Thank you for the help...
« Last Edit: December 05, 2007, 09:10:01 PM by diablosbud »


Current Games:
Darklands (Demon Slayer [new name])

Scripting - About 55% complete.

Eventing - About 1% complete.

Mapping - About .5% complete.

Spriting - 0% complete.

**
Rep: +0/-0Level 86
I am sorry to bother you again modern :-\ but I just put a new script that has an options menu, so they had to replace the menu.It is sweeet, but isn't compatible with this awsome inventory, I was wondering if you could help me make them compatible. I have already made it so that the script can load the inventory or wooden chest. But the problem is whenever I unequip a piece of gear or anything goes into either the inventory of the player or the wooden chest it will have an error that says "Script 'Grid Inventory' line 142: NoMethodError occurred. undefined method 'width' for nil:NilClass". I'm sorry for being a trouble but could you please help me compatiblize the script?

All four parts of the script are:

#===============================================================================
# ** Registry                                                                   
#-------------------------------------------------------------------------------
# This class reads the windows registry.                                       
#===============================================================================

module Win32
  class Registry
    module Constants
      HKEY_CLASSES_ROOT = 0x80000000
      HKEY_CURRENT_USER = 0x80000001
      HKEY_LOCAL_MACHINE = 0x80000002
      HKEY_USERS = 0x80000003
      HKEY_PERFORMANCE_DATA = 0x80000004
      HKEY_PERFORMANCE_TEXT = 0x80000050
      HKEY_PERFORMANCE_NLSTEXT = 0x80000060
      HKEY_CURRENT_CONFIG = 0x80000005
      HKEY_DYN_DATA = 0x80000006
      REG_NONE = 0
      REG_SZ = 1
      REG_EXPAND_SZ = 2
      REG_BINARY = 3
      REG_DWORD = 4
      REG_DWORD_LITTLE_ENDIAN = 4
      REG_DWORD_BIG_ENDIAN = 5
      REG_LINK = 6
      REG_MULTI_SZ = 7
      REG_RESOURCE_LIST = 8
      REG_FULL_RESOURCE_DESCRIPTOR = 9
      REG_RESOURCE_REQUIREMENTS_LIST = 10
      REG_QWORD = 11
      REG_QWORD_LITTLE_ENDIAN = 11
      STANDARD_RIGHTS_READ = 0x00020000
      STANDARD_RIGHTS_WRITE = 0x00020000
      KEY_QUERY_VALUE = 0x0001
      KEY_SET_VALUE = 0x0002
      KEY_CREATE_SUB_KEY = 0x0004
      KEY_ENUMERATE_SUB_KEYS = 0x0008
      KEY_NOTIFY = 0x0010
      KEY_CREATE_LINK = 0x0020
      KEY_READ = STANDARD_RIGHTS_READ |
        KEY_QUERY_VALUE | KEY_ENUMERATE_SUB_KEYS | KEY_NOTIFY
      KEY_WRITE = STANDARD_RIGHTS_WRITE |
        KEY_SET_VALUE | KEY_CREATE_SUB_KEY
      KEY_EXECUTE = KEY_READ
      KEY_ALL_ACCESS = KEY_READ | KEY_WRITE | KEY_CREATE_LINK
      REG_OPTION_RESERVED = 0x0000
      REG_OPTION_NON_VOLATILE = 0x0000
      REG_OPTION_VOLATILE = 0x0001
      REG_OPTION_CREATE_LINK = 0x0002
      REG_OPTION_BACKUP_RESTORE = 0x0004
      REG_OPTION_OPEN_LINK = 0x0008
      REG_LEGAL_OPTION = REG_OPTION_RESERVED |
        REG_OPTION_NON_VOLATILE | REG_OPTION_CREATE_LINK |
        REG_OPTION_BACKUP_RESTORE | REG_OPTION_OPEN_LINK
      REG_CREATED_NEW_KEY = 1
      REG_OPENED_EXISTING_KEY = 2
      REG_WHOLE_HIVE_VOLATILE = 0x0001
      REG_REFRESH_HIVE = 0x0002
      REG_NO_LAZY_FLUSH = 0x0004
      REG_FORCE_RESTORE = 0x0008
      MAX_KEY_LENGTH = 514
      MAX_VALUE_LENGTH = 32768
    end
    include Constants
    include Enumerable
    class Error < ::StandardError
      FormatMessageA=Win32API.new('kernel32.dll','FormatMessageA','LPLLPLP','L')
      def initialize(code)
        @code = code
        msg = "\0" * 1024
        len = FormatMessageA.call(0x1200, 0, code, 0, msg, 1024, 0)
        super msg[0, len].tr("\r", '').chomp
      end
      attr_reader :code
    end
    class PredefinedKey < Registry
      def initialize(hkey, keyname)
        @hkey = hkey
        @parent = nil
        @keyname = keyname
        @disposition = REG_OPENED_EXISTING_KEY
      end
      def close
        raise Error.new(5)
      end
      def class
        Registry
      end
      Constants.constants.grep(/^HKEY_/) do |c|
        Registry.const_set c, new(Constants.const_get(c), c)
      end
    end
    module API
      [
        %w/RegOpenKeyExA    LPLLP        L/,
        %w/RegCreateKeyExA  LPLLLLPPP    L/,
        %w/RegEnumValueA    LLPPPPPP     L/,
        %w/RegEnumKeyExA    LLPPLLLP     L/,
        %w/RegQueryValueExA LPLPPP       L/,
        %w/RegSetValueExA   LPLLPL       L/,
        %w/RegFlushKey      L            L/,
        %w/RegCloseKey      L            L/,
        %w/RegQueryInfoKey  LPPPPPPPPPPP L/,
      ].each do |fn|
        const_set fn[0].intern, Win32API.new('advapi32.dll', *fn)
      end
      module_function
      def check(result)
        raise Error, result, caller(2) if result != 0
      end
      def packdw(dw)
        [dw].pack('V')
      end
      def unpackdw(dw)
        dw +=
  • .pack('V')

        dw.unpack('V')[0]
      end
      def packqw(qw)
        [ qw & 0xFFFFFFFF, qw >> 32 ].pack('VV')
      end
      def unpackqw(qw)
        qw = qw.unpack('VV')
        (qw[1] << 32) | qw[0]
      end
      def OpenKey(hkey, name, opt, desired)
        result = packdw(0)
        check RegOpenKeyExA.call(hkey, name, opt, desired, result)
        unpackdw(result)
      end
      def CreateKey(hkey, name, opt, desired)
        result = packdw(0)
        disp = packdw(0)
        check RegCreateKeyExA.call(hkey, name, 0, 0, opt, desired,
                                   0, result, disp)
        [ unpackdw(result), unpackdw(disp) ]
      end
      def EnumValue(hkey, index)
        name = ' ' * Constants::MAX_KEY_LENGTH
        size = packdw(Constants::MAX_KEY_LENGTH)
        check RegEnumValueA.call(hkey, index, name, size, 0, 0, 0, 0)
        name[0, unpackdw(size)]
      end
      def EnumKey(hkey, index)
        name = ' ' * Constants::MAX_KEY_LENGTH
        size = packdw(Constants::MAX_KEY_LENGTH)
        wtime = ' ' * 8
        check RegEnumKeyExA.call(hkey, index, name, size, 0, 0, 0, wtime)
        [ name[0, unpackdw(size)], unpackqw(wtime) ]
      end
      def QueryValue(hkey, name)
        type = packdw(0)
        size = packdw(0)
        check RegQueryValueExA.call(hkey, name, 0, type, 0, size)
        data = ' ' * unpackdw(size)
        check RegQueryValueExA.call(hkey, name, 0, type, data, size)
        [ unpackdw(type), data[0, unpackdw(size)] ]
      end
      def SetValue(hkey, name, type, data, size)
        check RegSetValueExA.call(hkey, name, 0, type, data, size)
      end
      def FlushKey(hkey)
        check RegFlushKey.call(hkey)
      end
      def CloseKey(hkey)
        check RegCloseKey.call(hkey)
      end
      def QueryInfoKey(hkey)
        subkeys = packdw(0)
        maxsubkeylen = packdw(0)
        values = packdw(0)
        maxvaluenamelen = packdw(0)
        maxvaluelen = packdw(0)
        secdescs = packdw(0)
        wtime = ' ' * 8
        check RegQueryInfoKey.call(hkey, 0, 0, 0, subkeys, maxsubkeylen, 0,
          values, maxvaluenamelen, maxvaluelen, secdescs, wtime)
        [ unpackdw(subkeys), unpackdw(maxsubkeylen), unpackdw(values),
          unpackdw(maxvaluenamelen), unpackdw(maxvaluelen),
          unpackdw(secdescs), unpackqw(wtime) ]
      end
    end
    def self.expand_environ(str)
      str.gsub(/%([^%]+)%/) { ENV[$1] || $& }
    end
    @@type2name = { }
    %w[
      REG_NONE REG_SZ REG_EXPAND_SZ REG_BINARY REG_DWORD
      REG_DWORD_BIG_ENDIAN REG_LINK REG_MULTI_SZ
      REG_RESOURCE_LIST REG_FULL_RESOURCE_DESCRIPTOR
      REG_RESOURCE_REQUIREMENTS_LIST REG_QWORD
    ].each do |type|
      @@type2name[Constants.const_get(type)] = type
    end
    def self.type2name(type)
      @@type2name[type] || type.to_s
    end
    def self.wtime2time(wtime)
      Time.at((wtime - 116444736000000000) / 10000000)
    end
    def self.time2wtime(time)
      time.to_i * 10000000 + 116444736000000000
    end
    private_class_method :new
    def self.open(hkey, subkey, desired = KEY_READ, opt = REG_OPTION_RESERVED)
      subkey = subkey.chomp('\\')
      newkey = API.OpenKey(hkey.hkey, subkey, opt, desired)
      obj = new(newkey, hkey, subkey, REG_OPENED_EXISTING_KEY)
      if block_given?
        begin
          yield obj
        ensure
          obj.close
        end
      else
        obj
      end
    end
    def self.create(hkey, subkey, desired = KEY_ALL_ACCESS, opt = 0x0000)
      newkey, disp = API.CreateKey(hkey.hkey, subkey, opt, desired)
      obj = new(newkey, hkey, subkey, disp)
      if block_given?
        begin
          yield obj
        ensure
          obj.close
        end
      else
        obj
      end
    end
    @@final = proc { |hkey| proc { API.CloseKey(hkey[0]) if hkey[0] } }
    def initialize(hkey, parent, keyname, disposition)
      @hkey = hkey
      @parent = parent
      @keyname = keyname
      @disposition = disposition
      @hkeyfinal = [ hkey ]
      ObjectSpace.define_finalizer self, @@final.call(@hkeyfinal)
    end
    attr_reader :hkey, :parent, :keyname, :disposition
    def created?
      @disposition == REG_CREATED_NEW_KEY
    end
    def open?
      !@hkey.nil?
    end
    def name
      parent = self
      name = @keyname
      while parent = parent.parent
        name = parent.keyname + '\\' + name
      end
      name
    end
    def inspect
      "\#<Win32::Registry key=#{name.inspect}>"
    end
    def _dump(depth)
      raise TypeError, "can't dump Win32::Registry"
    end
    def open(subkey, desired = KEY_READ, opt = REG_OPTION_RESERVED, &blk)
      self.class.open(self, subkey, desired, opt, &blk)
    end
    def create(subkey, desired = KEY_ALL_ACCESS, opt = REG_OPTION_RESERVED, &blk)
      self.class.create(self, subkey, desired, opt, &blk)
    end
    def close
      API.CloseKey(@hkey)
      @hkey = @parent = @keyname = nil
      @hkeyfinal[0] = nil
    end
    def each_value
      index = 0
      while true
        begin
          subkey = API.EnumValue(@hkey, index)
        rescue Error
          break
        end
        begin
          type, data = read(subkey)
        rescue Error
          next
        end
        yield subkey, type, data
        index += 1
      end
      index
    end
    alias each each_value
    def each_key
      index = 0
      while true
        begin
          subkey, wtime = API.EnumKey(@hkey, index)
        rescue Error
          break
        end
        yield subkey, wtime
        index += 1
      end
      index
    end
    def keys
      keys_ary = []
      each_key { |key,| keys_ary << key }
      keys_ary
    end
    def read(name, *rtype)
      type, data = API.QueryValue(@hkey, name)
      unless rtype.empty? or rtype.include?(type)
        string = "Type mismatch (expect #{rtype.inspect} but #{type} present)"
        raise TypeError, string
      end
      case type
      when REG_SZ, REG_EXPAND_SZ
        [ type, data.chop ]
      when REG_MULTI_SZ
        [ type, data.split(/\0/) ]
      when REG_BINARY
        [ type, data ]
      when REG_DWORD
        [ type, API.unpackdw(data) ]
      when REG_DWORD_BIG_ENDIAN
        [ type, data.unpack('N')[0] ]
      when REG_QWORD
        [ type, API.unpackqw(data) ]
      else
        raise TypeError, "Type #{type} is not supported."
      end
    end
    def [](name, *rtype)
      type, data = read(name, *rtype)
      case type
      when REG_SZ, REG_DWORD, REG_QWORD, REG_MULTI_SZ
        data
      when REG_EXPAND_SZ
        Registry.expand_environ(data)
      else
        raise TypeError, "Type #{type} is not supported."
      end
    end
    def read_s(name)
      read(name, REG_SZ)[1]
    end
    def read_s_expand(name)
      type, data = read(name, REG_SZ, REG_EXPAND_SZ)
      if type == REG_EXPAND_SZ
        Registry.expand_environ(data)
      else
        data
      end
    end
    def read_i(name)
      read(name, REG_DWORD, REG_DWORD_BIG_ENDIAN, REG_QWORD)[1]
    end
    def read_bin(name)
      read(name, REG_BINARY)[1]
    end
    def write(name, type, data)
      case type
      when REG_SZ, REG_EXPAND_SZ
        data = data.to_s + "\0"
      when REG_MULTI_SZ
        data = data.to_a.join("\0") + "\0\0"
      when REG_BINARY
        data = data.to_s
      when REG_DWORD
        data = API.packdw(data.to_i)
      when REG_DWORD_BIG_ENDIAN
        data = [data.to_i].pack('N')
      when REG_QWORD
        data = API.packqw(data.to_i)
      else
        raise TypeError, "Unsupported type #{type}"
      end
      API.SetValue(@hkey, name, type, data, data.length)
    end
    def []=(name, rtype, value = nil)
      if value
        write name, rtype, value
      else
        case value = rtype
        when Integer
          write name, REG_DWORD, value
        when String
          write name, REG_SZ, value
        when Array
          write name, REG_MULTI_SZ, value
        else
          raise TypeError, "Unexpected type #{value.class}"
        end
      end
      value
    end
    def write_s(name, value)
      write name, REG_SZ, value.to_s
    end
    def write_i(name, value)
      write name, REG_DWORD, value.to_i
    end
    def write_bin(name, value)
      write name, REG_BINARY, value.to_s
    end
    def flush
      API.FlushKey @hkey
    end
    def info
      API.QueryInfoKey(@hkey)
    end
    %w[
      num_keys max_key_length
      num_values max_value_name_length max_value_length
      descriptor_length wtime
    ].each_with_index do |s, i|
      eval <<-__END__
        def #{s}
          info[#{i}]
        end
      __END__
    end
  end
end





=begin -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
                           Aleworks Options Menu(AO)
=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
Created by: Aleworks
Version: 2.50
Date: 26/12/06
=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
History of the version:
  -1.00
    First version
  -2.00
    Better code
    New interface
    More options
  -2.10
    Font changing improved
    Game speed bug fixed
    Autosaving bug fixed
    Lag reduction
  -2.50
    Font changing improved
    Autosaving improved
    Windowskin change bug fixed
    Scene_Options improved
    New options: Font Color, Font Brightness, Font Opacity, Windowskin Color,
                 Brightness, Battle Animations, Difficulty
=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
                            *** How to use ***
- For call the menu use:
  $scene = Scene_AOptions.new($scene)
- For edit the initial options and the menu options see ** Editable options **
and ** Types of options **
- For refer to AOptions use: $ao
- For edit the values of AO, while playing the game, use:
  $ao.something
something can be a method or a variable
For a list of the editable variables see the attr_accessors down the AOptions.
- For add a new option, see in the script, there are the instructions.
=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
              *** AO RGSS Classes and Modules definitions edits ***
 *** Color ***
replace: initialize
 *** Font ***
alias: initialize; alias name: aleworks_optionsmenu_font_initialize
 *** RPG::Cache ***
replace: self.windowskin
 *** Win32::Registry ***
add: value_time_index
 *** Game_Enemy ***
replace: base_maxhp
replace: base_maxsp
replace: base_str
replace: base_dex
replace: base_agi
replace: base_int
replace: base_atk
replace: base_pdef
replace: base_mdef
replace: base_eva
 *** Game_System ***
replace: bgm_play
replace: bgs_play
replace: me_play
replace: se_play
 *** Sprite_Battler ***
replace: update
 *** Window_Base ***
alias: normal_color, alias name: aleworks_optionsmenu_window_base_normal_color
replace: initialize
replace: dispose
replace: update
add: hue_to_color
 *** Window_SaveFile ***
replace: initialize
replace: refresh
 *** Scene_Title ***
replace: main
 *** Scene_Map ***
alias: update; alias name: aleworks_optionsmenu_scene_map_update
alias: transfer_player; alias name: aleworks_optionsmenu_scene_map_transfer
 *** Scene_Load ***
alias: on_decision; alias name: aleworks_optionsmenu_load_on_decision
 *** Scene_File ***
replace: main
replace: update
replace: make_filename
add: make_name
=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
=end

#=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
#  *** AO class ***
#=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
class AOptions
  attr_accessor :options
  attr_accessor :font_size_range
  attr_accessor :audio_volume_range
  attr_accessor :audio_speed_range
  attr_accessor :game_speed_range
  attr_accessor :opacity_range
  attr_accessor :color_range
  attr_accessor :brightness_range
  attr_accessor :fonts
  attr_accessor :font_name
  attr_accessor :font_size
  attr_accessor :font_color
  attr_accessor :font_brightness
  attr_accessor :font_opacity
  attr_accessor :winskin
  attr_accessor :windowskin_color
  attr_accessor :window_opacity
  attr_accessor :winskin_rtp
  attr_accessor :brightness
  attr_accessor :brightness_class
  attr_accessor :bgm_volume
  attr_accessor :bgs_volume
  attr_accessor :me_volume
  attr_accessor :se_volume
  attr_accessor :bgm_speed
  attr_accessor :bgs_speed
  attr_accessor :me_speed
  attr_accessor :se_speed
  attr_accessor :game_speed
  attr_accessor :auto_save
  attr_accessor :auto_save_count
  attr_accessor :auto_save_file
  attr_accessor :auto_save_status
  attr_accessor :window_autosave
  attr_accessor :window_autosave_timer
  attr_accessor :battle_animations
  attr_accessor :difficulty
  attr_accessor :difficulty_values
  attr_accessor :difficulty_names
  #=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
  #  ** AO initilize **
  #=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
  def initialize
    $data_system = load_data('Data/System.rxdata')
    @options = []
  #=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
  #  ** Editable options **
  #=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
    # * Menu groups options *
    # @options
  • =[A, [[B,C],etc]]]

    #  - @options
  • , where # determinates the number of the group of options

    #  - A is the name of the group of options
    #  - [B,C] is a option of the group of options
    #    - B is the name of the option
    #    - C is the type of option (See Type of options for more info)
    #=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
    @options[0] = ['Visual', [ ['Font', 0],
                               ['Letters Size', 1],
                               ['Letters Color', 10],
                               ['Letters Brightness', 11],
                               ['Letters Opacity', 12],
                               ['Windowskin', 2],
                               ['Windowskin Color', 13],
                               ['Window Opacity', 3],
                               ['Brightness', 14]
                  ]          ]

    @options[1] = ['Audio',  [ ['Music volume', 4],
                               ['Sound volume', 5],
                               ['Music Speed', 6],
                               ['Sound speed', 7]
                  ]          ]

    @options[2] = ['Game',   [ ['Game speed', 9],
                               ['Autosave', 8],
                               ['Battle Animations', 15],
                               ['Difficulty', 16]
                  ]          ]
    #=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
    # If it is true AO, will include the 001-Blue01.png skin of the Standart RTP
    #=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
    @winskin_rtp = true
    #=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
    #  * Selectable fonts *
    #  You have to put the names of the selectable fonts here.
    #  If you want that all font be selectable, put:
    #  @fonts = fonts_entries
    #  If you want to specify the fonts put an Array. It may be like this:
    #  @fonts = ['Comic Sans MS', 'Lucida Sans', 'Times New Roman']
    #    ~~~~~ Warning ~~~~~~
    #  If you use 'fonts_entries', some fonts maybe dont work well, and in some
    #  systems, maybe the script cant read the fonts.
    #  Tested only in Window XP.
    #=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
    @fonts = ['Comic Sans MS', 'Lucida Sans', 'Times New Roman']
    #=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
    #  * Selectable Ranges => [Min,Max] *
    #    ~~~~~ Warning ~~~~~~
    #      It may throw errors, if the ranges are out of the max. and min.
    #      All the defaults ranges will not throw errors.
    #=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
    @font_size_range = [6, 36]      # Letter Size           Min = 6    Max = 96
    @audio_volume_range = [0, 150]  # Audio Volume(in %)    Min = 0    Max = 150
    @audio_speed_range = [1, 500]   # Audio Speed(in %)     Min = 0    Max = ?
    @game_speed_range = [10, 120]   # Game Speed(in frames) Min = 10   Max = 120
    @opacity_range = [0, 100]       # Opacity               Min = 0    Max = 100
    @color_range = [-1, 360]        # Hue color             Min = 0    Max = 360
    @brightness_range = [-255, 255] # Brightness            Min = -255 Max = 255
    #=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
    # * Auto save options *
    # There are two types of autosaving, one that save after some time and one
    # that save after somes changes of maps.
    # For the first form, use:
    #  @auto_save   = ['map', #]
    #  - Where # is the number of map changes for save.
    # For the second form, use:
    #  @auto_save   = ['time', #]
    #  - Where # is the number of seconds that need to pass for save.
    # You can put too, any other thing like nil, and call the autosave when
    # you want.
    # It may be like:
    #   @auto_save = [nil, 0]
    # And dor call autosave:
    #   $ao.autosave
    #=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
    @auto_save = ['map', 2]
    @auto_save_file = 'Autosave.rxdata' # Name of thme autosave file.
    #=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
    # * Dificulty options *
    # @difficulty_values
    #   This values are the percentage of the atributes of the enemies.
    # @difficulty_names
    #   This are the names of the corresponding percentages of @difficulty_values
    #=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
    @difficulty_values = [60, 85, 100, 115, 130, 200]
    @difficulty_names = ['Very Easy', 'Easy', 'Normal', 'Hard', 'Hardest',
                         'Imposible']
    #=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
    # * Initials values of the options *
    #=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
    @font_name             = "Lucida Console" # Font name
    @font_size             = 22    # Size of the letters
    @font_color            = -1    # Color of the Window_Base normal_color  (-1 = Normal Color)
    @font_brightness       = 0     # Brightness of the letters
    @font_opacity          = 100   # Opacity of the letters
    @winskin               = $data_system.windowskin_name # Windowskin
    @window_opacity        = 100   # Opacity of windows
    @windowskin_color      = -1    # Color of the windows (-1 = Normal Color)
    @brightness            = 0     # Brightness of all sprites
    @bgm_volume            = 80    # Volume of BGM
    @bgs_volume            = 100   # Volume of BGS
    @me_volume             = 80    # Volume of ME
    @se_volume             = 100   # Volume of SE
    @bgm_speed             = 100   # Speed of BGM
    @bgs_speed             = 100   # Speed of BGS
    @me_speed              = 100   # Speed of ME
    @se_speed              = 100   # Speed of SE
    @auto_save_status      = false # The status of the autosave
    @game_speed            = 40    # Speed of the game(Frames)
    @battle_animations     = true  # Animations of Battle
    @difficulty            = 100   # Difficulty of the game
  #=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
  # ** Internal variables **
  #=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
    $defaultfonttype = $fontface = $fontname=Font.default_name = @font_name
    $defaultfontsize = $fontsize = Font.default_size = @font_size
    @brightness_class = Brightness.new(@brightness)
    @auto_save_count = @auto_save[1]
    @window_autosave = nil
    @window_autosave_timer = 0
  end
  #=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
  #  ** Types of options **
  #=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
  # For easy editing, the AO options are divided by types. You can edit, add
  # or remove types for your own options.   
  #=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
  def win_options(e)
    #=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
    #  * Types values *
    #=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
    # Here you can edit the value that each type of option shows.
    # options.push([i[0],A])
    #
    # You only need to edit A, options.push and i[0], have to be ever the same
    #=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
    options = []
    for i in e
      case i[1]
      when 0 # Type 0 (Font)
        options.push([i[0], @font_name])
      when 1 # Type 1 (Size of letters)
        options.push([i[0], @font_size])
      when 2 # Type 2 (Windoskin)
        options.push([i[0], @winskin])
      when 3 # Type 3 (Opacity of windows)
        options.push([i[0], "#{@window_opacity} %"])
      when 4 # Type 4 (BGM & ME volume)
        options.push([i[0], "#{@bgm_volume} %"])
      when 5 # Type 5 (BGS & SE volume)
        options.push([i[0], "#{@bgs_volume} %"])
      when 6 # Type 6 (BGM & ME speed)
        options.push([i[0], "#{@bgm_speed} %"])
      when 7 # Type 7 (BGS & SE speed)
        options.push([i[0], "#{@bgs_speed} %"])
      when 8 # Type 8 (Autosave)
        if @auto_save_status
          a = 'ON'
        else
          a = 'OFF'
        end
        options.push([i[0], a])
      when 9 # Type 9 (Game speed)
        options.push([i[0], @game_speed])
      when 10 # Type 10 (Font Color)
        a = @font_color
        a = 'Normal' if @font_color == -1
        options.push([i[0], a])
      when 11 # Type 11 (Font Brightness)
        a = "- #{@font_brightness.abs}" if @font_brightness < 0
        a = 'Normal' if @font_brightness == 0
        a = "+ #{@font_brightness}" if @font_brightness > 0
        options.push([i[0], a])
      when 12 # Type 12 (Font Opacity)
        options.push([i[0], "#{@font_opacity} %"])
      when 13 # Type 13 (Windowskin Color)
        a = @windowskin_color
        a = 'Normal' if @windowskin_color == -1
        options.push([i[0], a])
      when 14 # Type 14 (Brightness)
        a = '- #{@brightness.abs}' if @brightness < 0
        a = 'Normal' if @brightness == 0
        a = '+ #{@brightness}' if @brightness > 0
        options.push([i[0], @brightness])
      when 15 # Type 15 (Battle Animations)
        if @battle_animations
          a = 'ON'
        else
          a = 'OFF'
        end
        options.push([i[0], a])
      when 16 # Type 16 (Game Difficulty)
        a = @difficulty_names[@difficulty_values.index(@difficulty)]
        options.push([i[0], a])
      end
    end
    return options
  end
  def command_options(index, index_com, type)
    #=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
    #  * Types effect *
    #=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
    # Here you can edit what each type will do when the player change it.
    # - If your option is a switch, you can put: 
    #    if @switch
    #      @switch = false
    #    else
    #      @switch = true
    #    end
    # - If your option is a range of numbers
    #    @variable = range(@variable, [min, max], type)
    #   For more info see range
    # - If your option has differents strings values, like the font type, use:
    #    if @option_value == nil or Arraywithstrings.include?(@option_value) == false
    #      @font_name = Arraywithstrings[0]
    #      return
    #    end
    #    if type == -1
    #      if @option_value == Arraywithstrings[0]
    #        @option_value = Arraywithstrings[Arraywithstrings.size - 1]
    #      else
    #        @option_value = Arraywithstrings[Arraywithstrings.index(@option_value) - 1]
    #      end
    #    elsif type == 1
    #      if @option_value == Arraywithstrings[Arraywithstrings.size - 1]
    #        @option_value = Arraywithstrings[0]
    #      else
    #        @option_value = Arraywithstrings[Arraywithstrings.index(@option_value) + 1]
    #      end
    #    end
    # - If your option need to refresh the options group window use:
    #    $scene.command_left.refresh
    #=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
    case @options[index][1][index_com][1]
    when 0 # Type 0 (Font)
      return nil if type < -1 and type > 1 or type == 0
      if @font_name == nil or @fonts.include?(@font_name) == false
        @font_name = @fonts[0]
        return
      end
      if type == -1
        if @font_name == @fonts[0]
          @font_name = @fonts[@fonts.size - 1]
        else
          @font_name = @fonts[@fonts.index(@font_name) - 1]
        end
      elsif type == 1
        if @font_name == @fonts[@fonts.size - 1]
          @font_name = @fonts[0]
        else
          @font_name = @fonts[@fonts.index(@font_name) + 1]
        end
      end
      $defaultfonttype = $fontface = $fontname=Font.default_name = @font_name
      $scene.command_left_refresh
    when 1 # Type 1 (Size of letters)
      return nil if type == 0
      @font_size = range(@font_size, @font_size_range, type)
      $defaultfontsize = $fontsize = Font.default_size = @font_size
      $scene.command_left_refresh
    when 2 # Type 2 (Windoskin)
      return nil if type < -1 and type > 1 or type == 0
      w = ws_entries
      w.push('001-Blue01') if @winskin_rtp == true
      winskin=@winskin
      if ws_entries.size == 0
        @winskin = winskin
        return
      end
      if type == -1 and w.size >= 1
        if @winskin == nil or w.include?(@winskin) == false or @winskin == w[0]
          winskin = w[w.size - 1] unless w[w.size - 1] == nil
        elsif w[w.index(@winskin)-1] != nil
          winskin = w[w.index(@winskin) - 1]
        end
      elsif type == 1 and w.size >= 1
        if @winskin == nil or w.include?(@winskin) == false or
           @winskin == w[w.size - 1]
          winskin=w[0] unless w[0] == nil
        elsif w[w.index(@winskin) + 1] != nil
          winskin=w[w.index(@winskin) + 1]
        end
      end
      @winskin = winskin
    when 3 # Type 3 (Opacity of windows)
      return nil if type == 0
      @window_opacity = range(@window_opacity, @opacity_range, type)
      $scene.command_left_refresh
    when 4 # Type 4 (BGM & ME volume)
      return nil if type == 0
      @bgm_volume = range(@bgm_volume, @audio_volume_range, type)
      @me_volume = range(@me_volume, @audio_volume_range, type)
      $game_system.bgm_memorize
      $game_system.bgm_restore
    when 5 # Type 5 (BGS & SE volume)
      return nil if type == 0
      @bgs_volume = range(@bgs_volume, @audio_volume_range, type)
      @se_volume = range(@se_volume, @audio_volume_range, type)
      $game_system.bgs_memorize
      $game_system.bgs_restore
    when 6 # Type 6 (BGM & ME speed)
      return nil if type == 0
      @bgm_speed = range(@bgm_speed, @audio_speed_range, type)
      @me_speed = range(@me_speed, @audio_speed_range, type)
      $game_system.bgm_memorize
      $game_system.bgm_restore
    when 7 # Type 7 (BGS & SE speed)
      return nil if type == 0
      @bgs_speed = range(@bgs_speed, @audio_speed_range, type)
      @se_speed = range(@se_speed, @audio_speed_range, type)
      $game_system.bgs_memorize
      $game_system.bgs_restore
    when 8 # Type 8 (Autosave)
      return nil if type != 0
      if @auto_save_status
        @auto_save_status = false
      else
        @auto_save_status = true
      end
    when 9 # Type 9 (Game speed)
      return nil if type == 0
      @game_speed = range(@game_speed , @game_speed_range, type)
      Graphics.frame_rate = @game_speed
    when 10 # Type 10 (Font Color)
      return nil if type == 0
      @font_color = range(@font_color , @color_range, type)
      $scene.command_left_refresh
    when 11 # Type 11 (Font Brightness)
      return nil if type == 0
      @font_brightness = range(@font_brightness , @brightness_range, type)
      $scene.command_left_refresh
    when 12 # Type 12 (Font Opacity)
      return nil if type == 0
      @font_opacity = range(@font_opacity , @opacity_range, type)
      $scene.command_left_refresh
    when 13 # Type 13 (Windowskin Color)
      return nil if type == 0
      @windowskin_color = range(@windowskin_color , @color_range, type)
    when 14 # Type 14 (Brightness)
      return nil if type == 0
      @brightness = range(@brightness , @brightness_range, type)
      @brightness_class.refresh
    when 15 # Type 15 (Battle Animations)
      return nil if type != 0
      if @battle_animations
        @battle_animations = false
      else
        @battle_animations = true
      end
    when 16 # Type 16 (Game Difficulty)
      return nil if type < -1 and type > 1 or type == 0
      d = @difficulty_values
      difficulty = @difficulty
      if d.size == 0
        @difficulty = difficulty
        return
      end
      if type == -1 and d.size >= 1
        if @difficulty == d[0]
          difficulty = d[d.size - 1] unless d[d.size - 1] == nil
        elsif d[d.index(@difficulty)-1] != nil
          difficulty = d[d.index(@difficulty) - 1]
        end
      elsif type == 1 and d.size >= 1
        if @difficulty == nil or d.include?(@difficulty) == false or
           @difficulty == d[d.size - 1]
          difficulty = d[0] unless d[0] == nil
        elsif d[d.index(@difficulty) + 1] != nil
          difficulty = d[d.index(@difficulty) + 1]
        end
      end
      @difficulty = difficulty
    end
    return true
  end
  #=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
  #  ** Range **
  #=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
  # range(value,range,cant)
  #   - value is the actual value of the variable
  #   - range is the min and the max value of the range
  #   - cant is the cant that will be modified. The AO menu, use for the right
  #     and left arrowkey +1 and -1, and for the R and L buttons, +10 and -10.
  #=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
  def range(value, range, cant)
    value += cant
    if cant < -1 and value < range[0] and value != range[0] + cant
      value = range[0]
    elsif cant > 1 and value > range[1] and value != range[1] + cant
      value = range[1]
    elsif value < range[0]
      value = range[1]
    elsif value > range[1]
      value = range[0]
    end
    return value
  end
  #=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
  #  ** Windowskin entries **
  #=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
  # Return the name of all the windowskins
  #=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
  def ws_entries
    skin = Dir.entries('Graphics/Windowskins')
    skin.delete_at(0)
    skin.delete_at(0)
    skin.sort!
    c = 0
    for i in 0..skin.size - 1
      n=File.extname(skin[i - c])
      if n != '.bmp' and n != '.png' and n != '.jpg' and n != '.jpge' and
         n != '.jif'
        skin.delete_at(i - c)
        c += 1
      end
    end
    for i in 0..skin.size - 1
      size = File.extname(skin).size
      skin.slice!(skin.size - size, size)
    end
    return skin
  end
  #=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
  #  ** Autosave **
  #=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
  def load_game(file)
    if @auto_save[0] == 'map' or @auto_save[0] == 'time'
      @auto_save_count = @auto_save[1] 
    end
    @auto_save_count *= @game_speed if @auto_save[0] == 'time'
  end
  def autosave
    return if @auto_save_file == nil
    @auto_save_count = @auto_save[1]
    @auto_save_count *= @game_speed if @auto_save[0] == 'time'
    scene = $scene
    a = Scene_Save.new
    file = File.open(@auto_save_file, 'wb')
    a.write_save_data(file)
    file.close
    $scene = scene
    @window_autosave = Window_Help.new
    @window_autosave.x = 505
    @window_autosave.y = -16
    @window_autosave.width = 160
    @window_autosave.height = 64
    @window_autosave.opacity = 0
    @window_autosave.back_opacity = 0
    @window_autosave.set_text('Autosaving')
    @window_autosave_timer = @game_speed * 2.5
  end
  #=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
  #  ** Fonts entries **
  #=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
  # Return the name of all fonts
  #=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
  def fonts_entries
    fonts = []
    dir = 'SOFTWARE\Microsoft\Windows NT\CurrentVersion\Fonts'
    Win32::Registry::HKEY_LOCAL_MACHINE.open(dir) do |reg|
      entries_count = reg.each_value { | | }
      for index in 0..entries_count-1
        fonts.push(reg.value_time_index(index))
      end
    end
    c=0
    for i in 0..fonts.size-1
      n = fonts.scan(/ (TrueType)/)
      if n == nil
        fonts.delete_at(i - c)
        c += 1
      end
    end
    for i in 0..fonts.size - 1
      fonts.slice!(fonts.size - 11,11)
    end
    return fonts.sort
  end
end
#=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
#  *** Load/Save options data ***
#=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
module AO
  def AO.load
    file=File.open('Options.rxdata', 'rb')
    $ao = Marshal.load(file)
    file.close
    Graphics.frame_rate = $ao.game_speed
    $defaultfonttype = $fontface = $fontname = Font.default_name = $ao.font_name
    $defaultfontsize = $fontsize = Font.default_size = $ao.font_size
    $ao.brightness_class = Brightness.new($ao.brightness)
  end
  def AO.save
    $ao.brightness_class.dispose
    $ao.brightness_class = nil
    file = File.open('Options.rxdata', 'wb')
    Marshal.dump($ao, file)
    file.close
    $ao.brightness_class = Brightness.new($ao.brightness)
  end
end
#=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
#  *** Menu of Options ***
#=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
class Scene_AOptions
  attr_accessor :command_left
  attr_accessor :index
  attr_accessor :scene
  def initialize(scene)
    @scene = scene
  end
  def main
    o = []
    for i in $ao.options
      o.push(i[0])
    end
    @command_left = Window_Command.new(140, o)
    @command_left.width = 140
    @command_left.height = o.size * 32 + 32
    @command_left.x = 0
    @command_left.y = 0
    @index = 0
    @window_right = Window_AOptions.new
    options = $ao.win_options($ao.options[@command_left.index][1])
    @window_right.refresh(options, @index)
    @window_right.cursor_rect.set(0, -32, 16, 16)
    Graphics.transition
    while $scene == self
      Graphics.update
      Input.update
      update_left if @command_left.active
      update_right if @command_left.active == false
    end
    Graphics.freeze
    AO.save
    @command_left.dispose
    @window_right.dispose
  end
  def update_left
    @command_left.update
    options = $ao.win_options($ao.options[@command_left.index][1])
    @window_right.refresh(options, @index)
    @window_right.cursor_rect.set(0, -32, 16, 16)
    if Input.trigger?(Input::C)
      @command_left.active = false
      $game_system.se_play($data_system.decision_se)
    end
    if Input.trigger?(Input::B)
      $game_system.se_play($data_system.cancel_se)
      $scene = @scene
    end
  end
  def update_right
    @window_right.update
    @command_left.update
    options_size = $ao.options[@command_left.index][1].size - 1
    if Input.trigger?(Input::C)
      sound = $ao.command_options(@command_left.index, @index, 0)
      $game_system.se_play($data_system.decision_se) if sound == true
      options = $ao.win_options($ao.options[@command_left.index][1])
      @window_right.refresh(options, @index)
      return
    end
    if Input.repeat?(Input::UP)
      if Input.trigger?(Input::UP) or @index > 0
        $game_system.se_play($data_system.cursor_se)
        if @index == 0
          @index = options_size
        else
          @index -= 1
        end
        options = $ao.win_options($ao.options[@comman


Current Games:
Darklands (Demon Slayer [new name])

Scripting - About 55% complete.

Eventing - About 1% complete.

Mapping - About .5% complete.

Spriting - 0% complete.

*
Rep:
Level 97
2014 Most Unsung Member2014 Best RPG Maker User - Engine2013 Best RPG Maker User (Scripting)2012 Most Mature Member2012 Favorite Staff Member2012 Best RPG Maker User (Scripting)2012 Best MemberSecret Santa 2012 ParticipantProject of the Month winner for July 20092011 Best Use of Avatar and Signature Space2011 Best RPG Maker User (Scripting)2011 Most Mature Member2011 Favourite Staff Member2011 Best Veteran2010 Most Mature Member2010 Favourite Staff Member
I'll look into it, but I have to do exams first. Please use code tags as well.

**
Rep: +0/-0Level 86
I'm fine until then, but don't know how to use tags. Next time I write a code out I'll search for it in the Post Reply page.


Current Games:
Darklands (Demon Slayer [new name])

Scripting - About 55% complete.

Eventing - About 1% complete.

Mapping - About .5% complete.

Spriting - 0% complete.