设为首页收藏本站同能贴吧 切换语言 繁体中文
开启辅助访问 切换到窄版
扫描二维码关注官方公众号
返回列表
+ 发新帖
查看: 79|回复: 0

[转载发布] Tarot and fortunetelling plugin

[复制链接]
累计送礼:
0 个
累计收礼:
1 个
  • TA的每日心情
    开心
    2026-7-12 04:10
  • 签到天数: 209 天

    连续签到: 2 天

    [LV.7]常住居民III

    8308

    主题

    864

    回帖

    3万

    积分

    管理员

    Rank: 9Rank: 9Rank: 9

    VIP
    7
    卡币
    30623
    OK点
    16
    推广点
    0
    同能卷
    50
    积分
    39825

    灌水之王

    发表于 6 天前 | 显示全部楼层 |阅读模式
    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:       
    1. * This plugin adds four plugins commands to be used in your events:
    2. *
    3. * 1. TarotShuffle
    4. * This command just shuffles the tarot deck. No arguments.
    5. *
    6. * 2. TarotClear
    7. * Clear the cards on the screen
    8. *
    9. * 3. TarotInterpretation
    10. * Display a message with a random fortune telling.
    11. * I suggest you to use a message plugin with wordwrap support (eg Yanfly Message Core),
    12. * because the generated messages are big.
    13. *
    14. * 4. TarotSpreadCard <X> <Y> <R>
    15. *
    16. * This is the main command to be used. This command will display a card on the position X, Y.
    17. * Please note that X and Y use the card height as units, not pixels.
    18. *
    19. * To display the Celtic Cross spread, use the following sequence:
    20. *
    21. *    TarotShuffle
    22. *    TarotSpreadCard 2 2 0
    23. *    TarotSpreadCard 2 2 90
    24. *    TarotSpreadCard 2 3 0
    25. *    TarotSpreadCard 1 2 0
    26. *    TarotSpreadCard 2 1 0
    27. *    TarotSpreadCard 3 2 0
    28. *    TarotSpreadCard 4 4 0
    29. *    TarotSpreadCard 4 3 0
    30. *    TarotSpreadCard 4 2 0
    31. *    TarotSpreadCard 4 1 0
    32. *    TarotInterpretation
    33. *    TarotClear
    复制代码





    Script




    Spoiler: ELD_Tarot.js
                    Code:       
    1. /*:
    2. * @plugindesc Spread cards on the screen and give fortune-telling messages
    3. * @author Eldaym
    4. *
    5. *
    6. * @param cardWidth
    7. * @type number
    8. * @default 120
    9. *
    10. * @param cardHeight
    11. * @type number
    12. * @default 156
    13. *
    14. * @param cardScale
    15. * @type number
    16. * @decimals 3
    17. * @default 1
    18. *
    19. * @param waitOnSpread
    20. * @type number
    21. * @default 30
    22. *
    23. * @param reversalProbability
    24. * @type number
    25. * @default 1
    26. *
    27. * @param cardPictures
    28. * @type file[]
    29. * @dir img/pictures/
    30. * @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"]
    31. *
    32. * @param interpretationTexts
    33. * @type text[][]
    34. * @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"]","["."]"]
    35. *
    36. * Based on http://orteil.dashnet.org/randomgen/?gen=wzTkj6Qg
    37. *
    38. * @help
    39. *
    40. *
    41. *
    42. * This plugin adds four plugins commands to be used in your events:
    43. *
    44. * 1. TarotShuffle
    45. * This command just shuffles the tarot deck. No arguments.
    46. *
    47. * 2. TarotClear
    48. * Clear the cards on the screen
    49. *
    50. * 3. TarotInterpretation
    51. * Display a message with a random fortune telling.
    52. * I suggest you to use a message plugin with wordwrap support (eg Yanfly Message Core),
    53. * because the generated messages are big.
    54. *
    55. * 4. TarotSpreadCard <X> <Y> <R>
    56. *
    57. * This is the main command to be used. This command will display a card on the position X, Y.
    58. * Please note that X and Y use the card height as units, not pixels.
    59. *
    60. * To display the Celtic Cross spread, use the following sequence:
    61. *
    62. *    TarotShuffle
    63. *    TarotSpreadCard 2 2 0
    64. *    TarotSpreadCard 2 2 90
    65. *    TarotSpreadCard 2 3 0
    66. *    TarotSpreadCard 1 2 0
    67. *    TarotSpreadCard 2 1 0
    68. *    TarotSpreadCard 3 2 0
    69. *    TarotSpreadCard 4 4 0
    70. *    TarotSpreadCard 4 3 0
    71. *    TarotSpreadCard 4 2 0
    72. *    TarotSpreadCard 4 1 0
    73. *    TarotInterpretation
    74. *    TarotClear
    75. *
    76. */
    77. (function() {
    78.     var params = PluginManager.parameters('ELD_Tarot');
    79.     function shuffle(a) {
    80.         for (let i = a.length - 1; i > 0; i--) {
    81.             const j = Math.floor(Math.random() * (i + 1));
    82.             [a[i], a[j]] = [a[j], a[i]];
    83.         }
    84.         return a;
    85.     }
    86.     var alias_Game_Interpreter_pluginCommand = Game_Interpreter.prototype.pluginCommand;
    87.     Game_Interpreter.prototype.pluginCommand = function(command, args) {
    88.         alias_Game_Interpreter_pluginCommand.call(this, command, args);
    89.         if (command == 'TarotClear' || command == 'TarotShuffle') {
    90.             if (this._tarotCount && this._tarotCount > 0) {
    91.                 for (var i = 0; i < this._tarotCount; i++) {
    92.                     $gameScreen.erasePicture(i + 1);
    93.                 }
    94.             }
    95.             this._tarotCount = 0;
    96.         }
    97.         if (command == 'TarotShuffle' || (command == 'TarotSpreadCard' && !this._tarotCards)) {
    98.             console.log('shuffling cards')
    99.             if (!this._tarotCards) {
    100.                 this._tarotCards = eval(params['cardPictures']);
    101.             }
    102.             if (this._tarotCount > 0) {
    103.                 for (var i = 0; i < this._tarotCount; i++) {
    104.                     $gameScreen.erasePicture(i + 1);
    105.                 }
    106.                 this._tarotCount = 0;
    107.             }
    108.             this._tarotCards = shuffle(this._tarotCards);
    109.         }
    110.         if (command == 'TarotSpreadCard') {
    111.             if (!this._tarotCount) {
    112.                 this._tarotCount = 0;
    113.             }
    114.             this._tarotCount++;
    115.             var cardScale = parseFloat(params['cardScale']);
    116.             var h = parseInt(params['cardHeight']) * cardScale;
    117.             var w = (parseInt(params['cardWidth']) * cardScale);
    118.             var x = parseFloat(args[0]) * Math.max(w, h);
    119.             var y = (parseFloat(args[1]) - 0.5) * h;
    120.             var angle = parseInt(args[2]);
    121.             $gameScreen.showPicture(this._tarotCount, this._tarotCards[this._tarotCount], 1, x, y, cardScale*100, cardScale*100, 255, 0);
    122.             var realpic = $gameScreen.picture(this._tarotCount);
    123.             realpic._z += this._tarotCount;
    124.             if (angle != 0) {
    125.                 realpic._angle = angle;
    126.             }
    127.             var revprob = parseInt(params['reversalProbability']);
    128.             if ((revprob > 0) && (Math.randomInt(100) <= revprob)) {
    129.                 realpic._angle = angle + 180;
    130.             }
    131.             this.wait(parseInt(params['waitOnSpread']));
    132.         }
    133.         if (command == 'TarotInterpretation') {
    134.             var texts = eval(params['interpretationTexts']);
    135.             console.log(texts);
    136.             var msg = '';
    137.             var s = '';
    138.             for (var i = 0; i < texts.length; i++) {
    139.                 texts[i] = eval(texts[i]);
    140.                 var j = Math.randomInt(texts[i].length);
    141.                 s = texts[i][j];
    142.                 msg = msg + s;
    143.             }
    144.             $gameMessage.add(msg);
    145.             this.setWaitMode('message');
    146.         }
    147.     }
    148. })();
    复制代码





    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.


    本贴来自国际rpgmaker官方论坛作者:Eldaym处,因国际论坛即将永久关站,为了存档多年珍贵资料,署名转载到本论坛存档,由于官方帖子为英文原帖,需要中文翻译请点击论坛顶部切换语言为中文就可以将帖子翻译成中文浏览,方便大家随时查看,原文地址:https://forums.rpgmakerweb.com/threads/tarot-and-fortunetelling-plugin.90704/
    天天去同能,天天有童年!
    回复 送礼论坛版权

    使用道具 举报

    文明发言,和谐互动
    文明发言,和谐互动
    高级模式
    您需要登录后才可以回帖 登录 | 立即注册

    本版积分规则

    简体中文
    繁體中文
    English(英语)
    日本語(日语)
    Deutsch(德语)
    Русский язык(俄语)
    بالعربية(阿拉伯语)
    Türkçe(土耳其语)
    Português(葡萄牙语)
    ภาษาไทย(泰国语)
    한어(朝鲜语/韩语)
    Français(法语)
    关闭

    幸运抽奖

    社区每日抽奖来袭,快来试试你是欧皇还是非酋~

    立即查看

    聊天机器人
    Loading...

    QQ|Archiver|手机版|小黑屋|同能RPG制作大师 ( 沪ICP备12027754号-3 )

    GMT+8, 2026-8-1 20:50 , Processed in 0.140556 second(s), 52 queries .

    Powered by Discuz! X3.4

    Copyright © 2001-2020, Tencent Cloud.

    快速回复 返回顶部 返回列表