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

[转载发布] ozu_Self – No-Frills Self-Variables

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

    连续签到: 2 天

    [LV.7]常住居民III

    7975

    主题

    864

    回帖

    3万

    积分

    管理员

    Rank: 9Rank: 9Rank: 9

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

    灌水之王

    发表于 4 天前 | 显示全部楼层 |阅读模式
    ozu_Self 1.0
    by ozubon

    Introduction

    This is a self-variable or event variable plugin using mere 13 lines of code. Self-variables are saved with the game save, and persist through maps.

    Self-variables? What?
    Instead of using game variables for every event you can give the event its own variables. All those times you make new game variables for single events and your game variables list gets longer and... bloated..er... This, like other self-variable plugins seeks to address that. When you think about it, why shouldn't events have their own variables?

    How to use
    Spoiler: Help file
                    Code:       
    1. * ===========================================================================
    2. * Self-variables
    3. * ===========================================================================
    4. * A self-variable looks like this:
    5. *
    6. *       self(this)[Variable id]
    7. *
    8. * Now that you know that, all you have to do is come up with a variable id
    9. * and set it to something!
    10. *
    11. * Let's say you want to set self-variable 1 to 9001
    12. * Put this in a script call:
    13. *
    14. *       self(this)[1] = 9001
    15. *
    16. * Bonus:
    17. * You can have variable id's with names instead of numbers, but they gotta
    18. * be in quotation!
    19. *
    20. *      self(this)["garlic cloves"] = 10
    21. *
    22. * ===========================================================================
    23. * Conditional branch
    24. * ===========================================================================
    25. * This uses standard javascript operators, but don't panic, it's easy!
    26. *
    27. * To check if self-variable 1 is indeed 9001, put this into the conditional
    28. * branch script box:
    29. *
    30. *      self(this)[1] == 9001
    31. *
    32. * Don't use one lonely equal sign, one means set; two means compare!
    33. *
    34. * Here's some other operators:
    35. *
    36. *      Greater than: >                    Less than: <
    37. *      Greater than or equal to: >=       Less than or equal to: <=
    38. *      Not equal to: !=                   Equal and equal type: ===
    39. *  
    40. * This will return true because garlic cloves is more than 9:
    41. *
    42. *      self(this)["garlic cloves"] > 9
    43. *
    44. * ===========================================================================
    45. * Math
    46. * ===========================================================================
    47. * These are the assignment operators:
    48. *
    49. *      Set: =                             Mod: %=
    50. *      Add: +=                            Subtract: -=
    51. *      Multiply: *=                       Divide: /=
    52. *  
    53. * So, to add 3 to garlic cloves you do this:
    54. *
    55. *      self(this)["garlic cloves"] += 3
    56. *
    57. * Given that garlic cloves was 10, it is now 13!
    58. *
    59. * Bonus: MV's own modulo always return positive, if you want ot use it
    60. * it's a little extra finger work (or whatever you type with):
    61. *
    62. *      self(this)["garlic cloves"] = self(this)["garlic cloves"].mod(5)
    63. *
    64. * ===========================================================================
    65. * Other events' variables
    66. * ===========================================================================
    67. * To access other events' variables all you have to do is replace "this" with
    68. * the id of the event. Let's say you want to set event 2's variable 3 to 4:
    69. *
    70. *      self(2)[3] = 4
    71. *
    72. * Or check in a conditional branch if it is 4:
    73. *
    74. *      self(2)[3] == 4
    75. *
    76. * ===========================================================================
    77. * Events on other maps
    78. * ===========================================================================
    79. * You can also access variables on events on other maps, to do that you
    80. * specify the map id after the event id:
    81. *
    82. *      self(Event id, Map id)[Variable id]
    83. *
    84. * Let's say you want to set event 8 on map 7's potato variable to 6:
    85. *
    86. *      self(8, 7)["potato"] = 6
    87. *
    88. * Or check in a conditional branch if it is 6:
    89. *
    90. *      self(8, 7)["potato"] == 6
    91. *
    92. * ===========================================================================
    93. * Setting game variables to event variables
    94. * ===========================================================================
    95. * Simply, set a game variable using Control Variables with script operand:
    96. *
    97. *      self(this)[Variable id]
    98. *
    99. * Some examples:
    100. *
    101. *      self(this)[40]
    102. *      self(3)["pebbles"]
    103. *      self(1, 2)["quarks"]
    104. *
    复制代码


    Terms of use
    You don't have to credit me but I'd appreciate it!
    For commercial use, you gotta credit me!

    Plugin
    https://raw.githubusercontent.com/ozubon/tidbits/master/ozu_Self.js
    Right-click link -> Save As

    Credit
    ozubon


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

    使用道具 举报

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

    本版积分规则

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

    幸运抽奖

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

    立即查看

    聊天机器人
    Loading...

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

    GMT+8, 2026-8-1 08:32 , Processed in 0.139116 second(s), 55 queries .

    Powered by Discuz! X3.4

    Copyright © 2001-2020, Tencent Cloud.

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