Tarot and fortunetelling plugin

Eldaym

Villager
Member
Joined
Jan 23, 2018
Messages
6
Reaction score
3
First Language
Portuguese
Primarily Uses
RMMV
Tarot and fortunetelling 1.00
Eldaym


Introduction
This script does two things. It displays cards on the screen in any specific spread (like the Celtic Cross), and also displays a random generated


Features
- Displays tarot cards on the screen in any spread you wish
- Customizable random generated fortune-telling messages


Screenshots
https://i.imgur.com/4hzzJef.png



How to Use
You can use any picture you want for the cards if you setup in the cardPictures parameter. You can download this Rider-Waite-Smith deck that would work with the default: https://ufile.io/9q2bz (if someone can suggest a better place to upload, please suggest)
Code:
 * This plugin adds four plugins commands to be used in your events:
 *
 * 1. TarotShuffle
 * This command just shuffles the tarot deck. No arguments.
 *
 * 2. TarotClear
 * Clear the cards on the screen
 *
 * 3. TarotInterpretation
 * Display a message with a random fortune telling.
 * I suggest you to use a message plugin with wordwrap support (eg Yanfly Message Core),
 * because the generated messages are big.
 *
 * 4. TarotSpreadCard <X> <Y> <R>
 * 
 * This is the main command to be used. This command will display a card on the position X, Y.
 * Please note that X and Y use the card height as units, not pixels.
 *
 * To display the Celtic Cross spread, use the following sequence:
 *
 *    TarotShuffle
 *    TarotSpreadCard 2 2 0
 *    TarotSpreadCard 2 2 90
 *    TarotSpreadCard 2 3 0
 *    TarotSpreadCard 1 2 0
 *    TarotSpreadCard 2 1 0
 *    TarotSpreadCard 3 2 0
 *    TarotSpreadCard 4 4 0
 *    TarotSpreadCard 4 3 0
 *    TarotSpreadCard 4 2 0
 *    TarotSpreadCard 4 1 0
 *    TarotInterpretation
 *    TarotClear



Script




Code:
/*:
 * @plugindesc Spread cards on the screen and give fortune-telling messages
 * @author Eldaym
 *
 *
 * @param cardWidth
 * @type number
 * @default 120
 *
 * @param cardHeight
 * @type number
 * @default 156
 *
 * @param cardScale
 * @type number
 * @decimals 3
 * @default 1
 *
 * @param waitOnSpread
 * @type number
 * @default 30
 *
 * @param reversalProbability
 * @type number
 * @default 1
 *
 * @param cardPictures
 * @type file[]
 * @dir img/pictures/
 * @default ["00_Fool", "01_Magician", "02_High_Priestess", "03_Empress", "04_Emperor", "05_Hierophant", "06_Lovers", "07_Chariot", "08_Strength", "09_Hermit", "10_Wheel_of_Fortune", "11_Justice", "12_Hanged_Man", "13_Death", "14_Temperance", "15_Devil", "16_Tower", "17_Star", "18_Moon", "19_Sun", "20_Judgement", "21_World", "22_Ace_of_Wands", "23_Two_of_Wands", "24_Three_of_Wands", "25_Four_of_Wands", "26_Five_of_Wands", "27_Six_of_Wands", "28_Seven_of_Wands", "29_Eight_of_Wands", "30_Nine_of_Wands", "31_Ten_of_Wands", "32_Page_of_Wands", "33_Knight_of_Wands", "34_Queen_of_Wands", "35_King_of_Wands", "36_Ace_of_Pentacles", "37_Two_of_Pentacles", "38_Three_of_Pentacles", "39_Four_of_Pentacles", "40_Five_of_Pentacles", "41_Six_of_Pentacles", "42_Seven_of_Pentacles", "43_Eight_of_Pentacles", "44_Nine_of_Pentacles", "45_Ten_of_Pentacles", "46_Page_of_Pentacles", "47_Knight_of_Pentacles", "48_Queen_of_Pentacles", "49_King_of_Pentacles", "50_Ace_of_Cups", "51_Two_of_Cups", "52_Three_of_Cups", "53_Four_of_Cups", "54_Five_of_Cups", "55_Six_of_Cups", "56_Seven_of_Cups", "57_Eight_of_Cups", "58_Nine_of_Cups", "59_Ten_of_Cups", "60_Page_of_Cups", "61_Knight_of_Cups", "62_Queen_of_Cups", "63_King_of_Cups", "64_Ace_of_Swords", "65_Two_of_Swords", "66_Three_of_Swords", "67_Four_of_Swords", "68_Five_of_Swords", "69_Six_of_Swords", "70_Seven_of_Swords", "71_Eight_of_Swords", "72_Nine_of_Swords", "73_Ten_of_Swords", "74_Page_of_Swords", "75_Knight_of_Swords", "76_Queen_of_Swords", "77_King_of_Swords"]
 *
 * @param interpretationTexts
 * @type text[][]
 * @default ["[\"In the past, \",\"There was a time when \",\"Before, \"]","[\"you were often dealt with unfairly\",\"you had someone who meant a lot to you\",\"you cared more than you do now\"]","[\".\\\\. Now, \",\".\\\\. Today, \"]","[\"you should realize things aren't so bad\",\"life is presenting you with great opportunities you are choosing to ignore\",\"you should remember to not let your past haunt you\",\"you need to take life more seriously\",\"people give you better advice than you realize\",\"you give lots of advice but never take any\"]","[\".\\\\. Someday, \",\".\\\\. In the future, \",\".\\\\. Later, \"]","[\"you'll realize your mistakes and it will be too late\",\"you'll regret the choice you aren't making\",\"you'll live life just fine no matter what anybody thinks\",\"you'll know your mom was right sometimes\",\"you'll realize you love someone and it will be too late\"]","[\".\"]"]
 *
 * Based on http://orteil.dashnet.org/randomgen/?gen=wzTkj6Qg
 *
 * @help
 *
 *
 *
 * This plugin adds four plugins commands to be used in your events:
 *
 * 1. TarotShuffle
 * This command just shuffles the tarot deck. No arguments.
 *
 * 2. TarotClear
 * Clear the cards on the screen
 *
 * 3. TarotInterpretation
 * Display a message with a random fortune telling.
 * I suggest you to use a message plugin with wordwrap support (eg Yanfly Message Core),
 * because the generated messages are big.
 *
 * 4. TarotSpreadCard <X> <Y> <R>
 * 
 * This is the main command to be used. This command will display a card on the position X, Y.
 * Please note that X and Y use the card height as units, not pixels.
 *
 * To display the Celtic Cross spread, use the following sequence:
 *
 *    TarotShuffle
 *    TarotSpreadCard 2 2 0
 *    TarotSpreadCard 2 2 90
 *    TarotSpreadCard 2 3 0
 *    TarotSpreadCard 1 2 0
 *    TarotSpreadCard 2 1 0
 *    TarotSpreadCard 3 2 0
 *    TarotSpreadCard 4 4 0
 *    TarotSpreadCard 4 3 0
 *    TarotSpreadCard 4 2 0
 *    TarotSpreadCard 4 1 0
 *    TarotInterpretation
 *    TarotClear
 *
 */
 

(function() {
    var params = PluginManager.parameters('ELD_Tarot');


    function shuffle(a) {
        for (let i = a.length - 1; i > 0; i--) {
            const j = Math.floor(Math.random() * (i + 1));
            [a[i], a[j]] = [a[j], a[i]];
        }
        return a;
    }


    var alias_Game_Interpreter_pluginCommand = Game_Interpreter.prototype.pluginCommand;
    Game_Interpreter.prototype.pluginCommand = function(command, args) {
        alias_Game_Interpreter_pluginCommand.call(this, command, args);


        if (command == 'TarotClear' || command == 'TarotShuffle') {
            if (this._tarotCount && this._tarotCount > 0) {
                for (var i = 0; i < this._tarotCount; i++) {
                    $gameScreen.erasePicture(i + 1);
                }
            }
            this._tarotCount = 0;
        }
        if (command == 'TarotShuffle' || (command == 'TarotSpreadCard' && !this._tarotCards)) {
            console.log('shuffling cards')
            if (!this._tarotCards) {
                this._tarotCards = eval(params['cardPictures']);
            }
            if (this._tarotCount > 0) {
                for (var i = 0; i < this._tarotCount; i++) {
                    $gameScreen.erasePicture(i + 1);
                }
                this._tarotCount = 0;
            }
            this._tarotCards = shuffle(this._tarotCards);
        }
        if (command == 'TarotSpreadCard') {
            if (!this._tarotCount) {
                this._tarotCount = 0;
            }
            this._tarotCount++;
            var cardScale = parseFloat(params['cardScale']);
            var h = parseInt(params['cardHeight']) * cardScale;
            var w = (parseInt(params['cardWidth']) * cardScale);
            var x = parseFloat(args[0]) * Math.max(w, h);
            var y = (parseFloat(args[1]) - 0.5) * h;
            var angle = parseInt(args[2]);
            $gameScreen.showPicture(this._tarotCount, this._tarotCards[this._tarotCount], 1, x, y, cardScale*100, cardScale*100, 255, 0);
            var realpic = $gameScreen.picture(this._tarotCount);
            realpic._z += this._tarotCount;
            if (angle != 0) {
                realpic._angle = angle;
            }
            var revprob = parseInt(params['reversalProbability']);
            if ((revprob > 0) && (Math.randomInt(100) <= revprob)) {
                realpic._angle = angle + 180;
            }
            this.wait(parseInt(params['waitOnSpread']));
        }

        if (command == 'TarotInterpretation') {
            var texts = eval(params['interpretationTexts']);
            console.log(texts);
            var msg = '';
            var s = '';
            for (var i = 0; i < texts.length; i++) {
                texts[i] = eval(texts[i]);
                var j = Math.randomInt(texts[i].length);
                s = texts[i][j];
                msg = msg + s;
            }
            $gameMessage.add(msg);
            this.setWaitMode('message');
        }
    }

})();




Credit and Thanks
- The default text of the fortuneteller generator comes from http://orteil.dashnet.org/randomgen/?gen=wzTkj6Qg

The script is under the WTFPL license, which means you can use it for any use (commercial or non-commercial), and no credits are required.

This is my first time publishing plugin. My code is probably bad, any criticism is welcome.
 
Last edited:

Warpmind

Twisted Genius
Veteran
Joined
Mar 13, 2012
Messages
917
Reaction score
566
First Language
Norwegian
Primarily Uses
I likey - and the RWS deck is Public Domain, so that's a useful thing... :D
 

Diretooth

Lv. 23 Werewolf
Veteran
Joined
Mar 10, 2013
Messages
1,213
Reaction score
438
First Language
English
Primarily Uses
RMMV
This is a neat plugin, and one I would definitely use if I could directly call which card I wanted. Maybe that could be a future up[date for the plugin? Probably a command like 'TarotSpreadCard [filename] [X] [Y] [R]'
A question: What are the terms of use for this plugin? Is commercial allowed, or is it non-commercial only?
 

Eldaym

Villager
Member
Joined
Jan 23, 2018
Messages
6
Reaction score
3
First Language
Portuguese
Primarily Uses
RMMV
This is a neat plugin, and one I would definitely use if I could directly call which card I wanted. Maybe that could be a future up[date for the plugin? Probably a command like 'TarotSpreadCard [filename] [X] [Y] [R]'
A question: What are the terms of use for this plugin? Is commercial allowed, or is it non-commercial only?
You can use the standard "Show Picture" event command for that.

There is no specific terms. You can use the plugin any way you want, both commercial or non-commercial, no credits required. I will update the first topic with the license.
 

Starmage

Veteran
Veteran
Joined
Apr 2, 2016
Messages
582
Reaction score
644
First Language
FIlipino
Primarily Uses
N/A
Wow! This is so cool!! :D As someone practicing the Tarot myself, this should be a very helpful plugin. :) Thanks for your hardwork! :)
 

Users Who Are Viewing This Thread (Users: 0, Guests: 1)

Latest Threads

Latest Posts

Latest Profile Posts

buinguyenhoangtho wrote on fizzly's profile.
Hello @fizzly, i would like to use your asset/ resource for my project ( is maybe commercial ). May i have your permission? Thanks you !
Working on breaking the limits of RPGMaker! :cool:
I have 470+ hours on RMMV but have only made a demo game, is this normal? :kaoswt: (I lose motivation a lot plus I use a 32gb laptop, so..)
I like Iron Maiden.
Benku wrote on Magnus0808's profile.
Hey man you helped me out a long time ago with a plugin i was wondering if you can help me out one more time since its literally the last thing i need help with if not is cool but id figured id ask you one more soild.

Forum statistics

Threads
95,427
Messages
929,082
Members
125,659
Latest member
AphoticAmaranth
Top