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

[转载发布] Built-in class Extension's v1.9.5 [Updated]

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

    连续签到: 2 天

    [LV.7]常住居民III

    9071

    主题

    864

    回帖

    6万

    积分

    管理员

    Rank: 9Rank: 9Rank: 9

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

    灌水之王

    发表于 2026-8-1 14:44:42 | 显示全部楼层 |阅读模式
    Built-in class Extension's v1.9.5
            Author Sarlecc



             
    Introduction
            This script adds four new methods to the String class and three to the Array class more may be added in the future as I think of them.


    Updates:


            - v1.5 added three methods to the Array class and changed the name to Built-in class Extension's. (as it now handles more than just Strings)


            - v1.6 added mix_up method to String class.


            - v1.8 added search method to array class, added prime? method to Math module. Also due to the length of the script putting it up on  mediafire.
            - v1.9 added two new methods to the Array class. Also was having problems updating the script so the download link changed...


            -v1.9.5 added new prime number checking algorithm. now check if a prime number is prime much faster (slower though on composite numbers)


    Features

    SpoilerSpoiler



                            - Can remove every other character
                            - Can add characters every other character
                            - Can convert a string to random characters.


                            - Can mix the characters in a string.


                            - Can find the mean.


                            - Can find the median.


                            - Can find the range.


                            - Can search for certain numbers in an array


                            - Can determine if a number is a prime number


                            - Can find the id in an array with the lowest value


                            - Can find the id in an array with the highest value






    Screenshots
            None needed
             
    How to Use
            Place script below materials and above main

                    Code:       
    1. #==============================================================================
    2. # String Extension by Sarlecc
    3. #
    4. # Strings
    5. # "".remove_every(n, d) n = number, d = divsion (optional)
    6. # "Example".remove_every(0, 3)# "".add_every(chars, n, d) chars = characters
    7. # "Example".add_every("u", 2, 4)
    8. # "".rand_chars
    9. # "Example".rand_chars
    10. # "".mix_up
    11. #
    12. # Arrays
    13. # [].mean
    14. # [].median
    15. # [].range
    16. # [].search(num1, num2) num2 is optional
    17. #
    18. # The following two methods return the id with the lowest or highest value in the given range
    19. # both num1 and num2 are optional if omitted or values are to high then it will use 0 and the size
    20. # of the array
    21. # [].lowest(num1, num2)
    22. # [].highest(num1, num2)
    23. #
    24. # Math
    25. # Math.prime?(num)
    26. # Math.prime2?(num)
    27. # Math.prime2? is on average 2.5 times faster than Math.prime? if the number is prime; otherwise it is around 16-353 times slower
    28. # its recommended that you use Math.prime? for checking thousands of numbers at a time as Math.prime2? will give an error (I assume
    29. # that it has to do with the multithreading and attempting to do the next number while still doing the previous number).
    30. # use Math.prime2? for checking larger primes
    31. # Math.prime? time for number 18987964267331664557:
    32. # 4521.762485 seconds
    33. # Math.prime2? time for number 18987964267331664557:
    34. # 1922.888493 seconds
    35. # Math.prime? time for 106573388391:
    36. # 0.000027-0.000028 seconds
    37. # Math.prime2? time for 106573388391:
    38. # 0.000452-0.009907 seconds
    39. #==============================================================================
    复制代码


             
    Demo
            Yea none needed.
             
    Script
             Script



    GitHub

    FAQ
            None yet.
             
    Credit
            - Sarlecc

    Terms


    Author's Notes:


    The difference between rand_chars and mix_up is mix_up only returns a string containing characters in that string. The rand_chars method returns random characters that do not necessarily show up in the string. I'm guessing that mix_up might be good for anagrams/scrabble style games?


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

    使用道具 举报

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

    本版积分规则

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

    幸运抽奖

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

    立即查看

    聊天机器人
    Loading...

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

    GMT+8, 2026-8-18 00:24 , Processed in 0.136911 second(s), 55 queries .

    Powered by Discuz! X3.4

    Copyright © 2001-2020, Tencent Cloud.

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