[XP] Digit Extraction v1
#1
Introduction
This event script lets you extract the digits from a value via script calls.

Features
  • Extract a value and use an extracted digit via script calls.
    I haven't tested floats or negative integers but I'm sure it wouldn't work as it should because I didn't make this with them in mind
  • And for those new to my systems, this stuff is generally plug and play.
How to Install
Copy-paste the common event into your project. Depending on how far into development you are with your project, you should change its condition switch.

FAQ
  1. How do I extract a value?
    To extract a value, you could call this via call script:
    pk8_diex_extract(value)
    value - Should be a positive integer. This system wasn't made with floats or negative integers in mind.
  2. Okay, but I want to be able to extract a number to a variable in which I can read from. How do I do that?
    This can be done by setting a scripted variable of some sort to equal the array of extracted digits. Try this (Be sure to correct me if this is found to be bad practice):
    @some_variable = pk8_diex_extract(85743)
  3. How do I get it to extract a game variable instead?
    @some_variable = pk8_diex_extract($game_variable[id])
    id - Should be a Game Variable ID.
  4. How do I read extracted digits?
    You could use this script call:
    @some_variable[i]
    i - The index number will refer to the rightmost extracted digit. (e.g.: 1: Ones, 2: Tens, 3: Hundreds, 4: Thousands)
  5. I'd like to give the value of a digit to a game variable. How do I do it?
    Using calls like these:
    $game_variable[id] = @some_variable[i]
    id - Should be a Game Variable ID.
    i - The index number will refer to the rightmost extracted digit. (e.g.: 1: Ones, 2: Tens, 3: Hundreds, 4: Thousands)

    An example set of script calls:
    $game_variables[1] = 85743
    @some_variable = pk8_diex_extract($game_variables[1])
    $game_variables[2] = @some_variable[1]
    $game_variables[3] = @some_variable[2]
    $game_variables[4] = @some_variable[3]
    $game_variables[5] = @some_variable[4]
    $game_variables[6] = @some_variable[5]
Credit and Thanks
Credit
  • -
Thanks Author's Notes
The presentation for the demo was for the most part, rushed. I didn't come up with a fancy readme this time around. Once again, this system wasn't really made with floats or negative integers in mind. I will try to come up with something that could accommodate floats, but for now, this is all I got.

If anyone wants to take up the reins and build something a lot better than what I have then by all means, take it away!

A VX version has yet to be made but can easily be recreated if you copy my code command by command.

License / Terms
This is free for non-commercial and commercial use. Credit is optional.

Downloads

.zip   Digit Extraction XP.zip (Size: 189.93 KB / Downloads: 3)
Reply }


Messages In This Thread
[XP] Digit Extraction v1 - by PK8 - 01-23-2012, 11:19 AM



Users browsing this thread: 1 Guest(s)