Currency Functions | v1.1 | etcgfm v1.0.1 | up 2.28.14

  1. 5 years ago
    Edited 4 years ago by Dite

    Required Mods
    get_category (only if you want to use a category to hold currency)

    This is a page full of functions that help you update and display currency. Most of the inputs and outputs are interchangeable, so you can update each item with a number, but display each one, or vice versa.
    There are currently 3 types of inputs with 3 types of outputs, with 8 functions total (some inputs and outputs don't go together).

    'count': Your field has the number of each item you have. ex: earth: 27 / fire: 30 / air: 27 / water: 24
    'list': Your field has each item listed in any order, so you can just log new items at the front of the field. Use this if you want to use a category to hold currency. ex: star3, star1, star2, star3, star2, star3
    'total': Your field is just a single number that you increase or decrease when you earn or use it. ex: 22.

    'count': Similar to the count input. You want to output one copy of each item, along with how many you have. ex: Overdrive Potions
    'items': Similar to list input. Shows each item you have, in order. ex: Portfolio cameras (w/o the total).
    'money': Created for the total input. Allows you to display the total with the least number of items, and gives you that total. Also can be used with monetary lists, where it will display the listed items from highest to lowest, and still give you the total. ex: Main Event MITB points from lists, Elements berries from a total.

    Usable Combinations
    Without the right inputs and outputs together, you'll be told the function doesn't exist. These are the currently allowed functions.
    count, count: a straightforward item-with-number input and output. You input something as: item1: 3 /item2: 1, and it outputs it as [item1] x 3 [item2] x 1
    count, items: converts your item count to a graphical view of what you have. You'll input item: 3, and it'll output [item1] [item1] [item1] [item2]
    list, count: lets you input a list of what you got, then it counts them and spits out the count. If you input the stars in the 'list' example, you'd get: [star1] x 1 [star2] x2 [star3] x 3.
    list, items: The straightforward item list. It just orders them and spits them out as graphics.
    list, total: Only to be used with monetary values.It can be considered a 'wallet-style' view. You input whatever items (or dollar bills) you have, but instead of converting them (as two $5's don't just turn into a $10 bill), it just lists what you has, reverse orders them, and totals them up.
    total, count: Used to count one item. The function itself is relatively pointless (you can do the same thing with the image tag and the eTCG's given get_additional function), but I know some people like uniformity, so it's in a similar style.
    total, items: Used to visually represent what you have of one currency type. Portfolio's cameras are displayed in this way.
    total, money: Displays your monetary currency in the fewest images possible. Displays the greatest bills possible. So, in an average US dollar situation where you have $48, it'd display $20, $20, $5, $1, $1, $1.

    It's the attached php file. You can copy and paste them to your func.php or custom functions page, but I'd probably suggest just including it in one.

    <? include('currency_func.php'); ?>

    The page itself has detailed instructions, but here's a breakdown of how it works, in case you want to just read this as you go along:

    currency($tcg, $field, $from, $to, $pre, $post, $break = 0, $bills = '')

    The reqired variables to change are:
    $tcg, to whatever TCG you're using it on; $field to whatever field (or category) you're using it on.
    $from which is your input style, and $to, which is your output style.
    $pre and $post, which are your filenames. For something like Overdrive's potions, you put in an items folder, $pre would be 'items/potion-' and $post would be '.png' (period included).
    It allows full URLs, so if the TCG lets you direct-link, just put the URL in with http://. The only thing that shouldn't be in $pre or $post should be the term you use when updating.

    The other variables:
    $break is an optional variable for all types. It's basically in case you want the line to break at certain times. It allows you to line things up relatively neatly, or be a good counting tool (if you do lists with 5- or 10- item breaks, you can count easily per line).

    $bills is a required variable, but only for the 'total' input and 'money' output. It's the dollar bill value. Be sure to list all possible bills (so for Main Event MITB , you'd put '05,10,20,50'). the list can be in any order, as it reverse-sorts them. Use whatever number is in the filename, so if the file is 'moneyinthebank-05', use 05. If it's '1dollar' use 1.

    Note: When not used with the 'money' output, the 'total' input will use $field for it's filename. So, for the Cameras example, my file is 'portfolio/items/camera.png'. So, my additional field is called 'camera' NOT 'cameras'. It doesn't matter what you name it, as long as the field and item have the same name.

    Upcoming Versions
    Nothing specific. If anyone wants a certain input and/or output, I'll update later versions to include them.

    Previous/Current Versions
    1.1 - Added total_to_count and total_to_items functions, which enables 'total' input to work with all current outputs.
    1.0 - Initial version.

  2. 4 years ago


    15 Feb 2015
    Edited 4 years ago by Lucy

    Hey Dite!
    Would love to use this mod but is there supposed to be a file attachment on your post? (currency_func.php) I can't seem to see it unless I'm just being a dummy :P

    EDIT: Thanks for posting it Dite!

  3. I have a question for that mod. In general I love it already.
    My only problem is: let's say I have a hearts currency like at Rapture and I have the hearts as a list together in one field. My output is count so that I see how many of each heart I have... but when for example I traded all hearts for cards and have nothing in that field I get an error with the get_category function.
    is there a way to change it so the code says 'there are no items in this category' (like it does when there are no cards in a category) when an additional field is empty?

  4. I haven't tested it, but try changing line 35 to:

    if(!empty($list)){$func($list, $pre, $post, $break, $etc);}
    		else{ echo "There is no currency right now."; }

or Sign Up to reply!