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

[转载发布] Kuro Any Bar

[复制链接]
累计送礼:
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-7-31 21:35:14 | 显示全部楼层 |阅读模式
    Kuro Any Bar
    V2.1
    Tipe: Eventer Tool

    Introduction
    "I want my game to have multiple bar on map which I can define it as I wanted it to be!" And thus this script was born.

    Feature

    • Animated multi-function bar.
    • Might be called as much as you wanted.
    • Can use either variable ID or eval script.
    • Very customable and easy to use!
    • Additionally including the text which you can edit.
    • Can use picture as the bar.
    Screenshots




    Demo
    https://db.tt/CwRDmzxo V2.1 (10/12/2014)

    Script

    Spoiler                Code:       
    1. =begin
    2. ================================================================================
    3.                               KURO ANY BAR V2.0
    4. ================================================================================
    5.   Introduction :
    6.   A multi simple active bar for any kind of use.
    7.   From now will be used to support my advanced event system.
    8. ================================================================================
    9.   Changelog :
    10.   V.2.1 (10-12-2014)
    11.   * More property : skinpic.
    12.   * Kini hanya menerima nilai dari game variable.
    13.   * Fixed, value yang nembus nilai max atau kurang dari 0.
    14.   * Fixed, flip picture.
    15.   * Fixed, ukuran dan posisi text.
    16.   * Rapihin.
    17.   V.2.0 (06-09-2014)
    18.   * Method baru : Kuro::Bar.update
    19.   * More property : picture, gradien, etc.
    20.   * Gauge animatif.
    21.   * New interface : rombak habis-habisan.
    22.   V.1.0 (03-09-2014)
    23.   * Awal pembuatan, dan selesainya script.
    24. ================================================================================
    25.   Current feature :
    26.   * Multi simple custom bar.
    27.   * Come with custom text.
    28.   * Could be aligned.
    29.   * Vertical? no prob~
    30.   * Can use picture as the bar.
    31. ================================================================================
    32.   How to use :
    33.   Konfigurasi bar nya berada di module sesuai dengan format yang tertera.
    34.   Jadi tinggal siap panggil di mana saja melalui event dengan script call.
    35.   
    36.   Kuro::Bar.create(ID)          <<< buat bar
    37.   Kuro::Bar.update(ID,KEY,VALUE) <<< edit property bar
    38.   Kuro::Bar.delete(ID)          <<< hapus bar
    39.   ID    = adalah nomor id preset yang anda buat (0 = default preset)
    40.   KEY  = nama property daripada bar di preset anda (:x, :y, :width)
    41.   VALUE = nilai baru untuk property preset anda.
    42. ================================================================================
    43. =end
    44. module Kuro
    45.   module Bar
    46. #===============================================================================
    47. # CONFIGURATION START
    48. #===============================================================================
    49. # COLOR PALLETTE
    50. # ==============================================================================
    51.   # Palet warna. Silahkan saja kalo mau membuat warna anda sendiri.
    52.   # WARNA  = Color.new(red, green, blue)
    53.     BLACK  = Color.new(0,0,0)
    54.     WHITE  = Color.new(255,255,255)
    55.     RED    = Color.new(255,0,0)
    56.     GREEN  = Color.new(0,255,0)
    57.     BLUE    = Color.new(0,0,255)
    58.     YELLOW  = Color.new(255,255,0)
    59.     CYAN    = Color.new(0,255,255)
    60.     MAGENTA = Color.new(255,0,255)
    61.   # Palet warna untuk gradient. Gabung-gabungkan saja palet warna di atas.
    62.   # HANYA 2 WARNA !
    63.   # GRADIEN    = [WARNA 1, WARNA 2]
    64.     GREENBLACK = [GREEN,BLACK]
    65.     BLUEBLACK  = [BLUE,BLACK]
    66.     REDBLACK  = [RED,BLACK]
    67. # BAR DEFAULT VALUE
    68. # ==============================================================================
    69.     PRESET = [{ # Default setting
    70.   # Setting default nya (PRESET[0]).
    71.   # Kalo ada property yang gak ada di preset yang anda buat, bakal pake value
    72.   # dari property yang ada di sini.
    73.       :x        => 0,      # X coordinate
    74.       :y        => 0,      # Y coordinate
    75.       :z        => 50,      # Z coordinate
    76.       :width    => 100,    # Bar width
    77.       :height  => 10,      # Bar height
    78.       :color    => WHITE,  # Bar color
    79.       :opaback  => 255,    # Back skin opacity (0~255)
    80.       :picture  => nil,    # Use picture as bar (in folder system)
    81.       :skinpic  => nil,    # Use picture as bar foreskin (in folder system)
    82.       :flip    => false,  # Flip the bar?
    83.       :text    => nil,    # Text (\\b = base value, \\m = max value)
    84.       :align    => 0,      # Bar align (0 = left, 1 = mid, 2 = right)
    85.       :base    => 1,      # Variable ID as base value (use "" for eval script)
    86.       :max      => "100",  # Variable ID as max value (use "" for eval script)
    87.       :vertical => false    # Was it vertical?
    88.     }]
    89.   # Kecepatan animasi bar. Semakin gede, semakin cepat.
    90.     BOOST = 3
    91. # BAR PRESET
    92. #===============================================================================
    93.   # Mulai buat preset anda sendiri dari sini. Berantakan gak masalah selama
    94.   # nama key nya bener. Ingat, jangan lupa naruh tanda koma!
    95.     PRESET[1] = { # Actor 1 HP
    96.       :base    => "$game_actors[1].hp",
    97.       :max      => "$game_actors[1].mhp",
    98.       :text    => "[\\b/\\m]",
    99.       :color    => GREENBLACK,
    100.       :width    => 120,
    101.       :height  => 12,
    102.       :skinpic  => "barskin",
    103.     }
    104.     PRESET[2] = { # Actor 1 MP
    105.       :y        => 12,
    106.       :width    => 120,
    107.       :height  => 12,
    108.       :color    => BLUEBLACK,
    109.       :base    => "$game_actors[1].mp",
    110.       :max      => "$game_actors[1].mmp",
    111.       :text    => "[\\b/\\m]",
    112.       :skinpic  => "barskin",
    113.     }
    114.     PRESET[3] = { # Quest : Kill Rat
    115.       :x        => 16,
    116.       :y        => 380,
    117.       :width    => 512,
    118.       :height  => 24,
    119.       :color    => REDBLACK,
    120.       :opaback  => 128,
    121.       :base    => 1,
    122.       :max      => "10",
    123.       :text    => "kill rat (\\b/\\m)",
    124.     }
    125.     PRESET[4] = { # Mashing Button !!!
    126.       :x        => 192,
    127.       :y        => 240,
    128.       :picture  => "screwthis",
    129.       :opaback  => 200,
    130.       :base    => 2,
    131.       :max      => "100",
    132.       :align    => 1,
    133.     }
    134.     PRESET[5] = { # Hit me!
    135.       :x        => 364,
    136.       :width    => 180,
    137.       :height  => 24,
    138.       :base    => 3,
    139.       :max      => "30",
    140.       :text    => "[\\b/\\m]",
    141.       :align    => 2,
    142.     }
    143. #===============================================================================
    144. # CONFIGURATION END
    145. #===============================================================================
    146.    
    147.     def self.create(id)
    148.       $kab[id] = AnyBar.new(id)
    149.     end
    150.     def self.update(id,key,value)
    151.       return if PRESET[id][key] == value
    152.       PRESET[id][key] = value
    153.       if $kab[id] != nil
    154.         $kab[id].load
    155.       end
    156.     end
    157.     def self.delete(id)
    158.       if $kab[id] != nil
    159.         $kab[id].dispose
    160.         $kab[id] = nil
    161.       end
    162.     end
    163.   end
    164. end
    165. class AnyBar
    166.   def initialize(id)
    167.     @id = id
    168.     load
    169.   end
    170.   def load
    171.     d = Kuro::Bar::PRESET[0]
    172.     v = Kuro::Bar::PRESET[@id]
    173.     a = d.keys
    174.     k = []
    175.     for i in 0...a.size
    176.       if v.include?(a[i])
    177.         k[i] = v[a[i]]
    178.       else
    179.         k[i] = d[a[i]]
    180.       end
    181.     end
    182.     @x = k[0]
    183.     @y = k[1]
    184.     @z = k[2]
    185.     @w = k[3]
    186.     @h = k[4]
    187.     @c = k[5]
    188.     @o = k[6]
    189.     @p = k[7]
    190.     @s = k[8]
    191.     @f = k[9]
    192.     @t = k[10]
    193.     @a = k[11]
    194.     @n = k[12]
    195.     if k[13].is_a? Fixnum
    196.       @m = [$game_variables[k[13]],1].max
    197.     else
    198.       @m = [eval(k[13]),1].max
    199.     end
    200.     @v = k[14]
    201.     refresh
    202.     create
    203.   end
    204.   def refresh
    205.     @back.bitmap.dispose unless @back==nil
    206.     @bar.bitmap.dispose unless @bar==nil
    207.     @skin.bitmap.dispose unless @skin==nil
    208.     @text.bitmap.dispose unless @text==nil
    209.   end
    210.   def create
    211.     create_back if @o > 0
    212.     create_bar
    213.     create_skin if @s != nil
    214.     create_text if @t != nil
    215.     update
    216.   end
    217.   def create_back
    218.     @back = Sprite.new
    219.     if @p != nil
    220.       @back.bitmap = Cache.system(@p)
    221.       @back.tone = Tone.new(-255,-255,-255)
    222.       @back.mirror = @f
    223.     else
    224.       @back.bitmap = Bitmap.new(@w,@h)
    225.       @back.bitmap.fill_rect(0,0,@w,@h,Color.new(0,0,0,@o))
    226.     end
    227.     @back.x = @x
    228.     @back.y = @y
    229.     @back.z = @z
    230.   end
    231.   def create_bar
    232.     @bar = Sprite.new
    233.     if @p != nil
    234.       @bar.bitmap = Cache.system(@p)
    235.       @w = @bar.bitmap.width
    236.       @h = @bar.bitmap.height
    237.       @bar.mirror = @f
    238.     else
    239.       @bar.bitmap = Bitmap.new(@w,@h)
    240.       if @c.is_a? Array
    241.         @bar.bitmap.gradient_fill_rect(0,0,@w,@h,@c[0],@c[1],@v)
    242.       else
    243.         @bar.bitmap.fill_rect(0,0,@w,@h,@c)
    244.       end
    245.     end
    246.     @bar.x = @x
    247.     @bar.y = @y
    248.     @bar.z = @z+1
    249.     getvar
    250.     if @v
    251.       @bar.src_rect.height = @b*@h/@m
    252.       @bar.src_rect.y = (@h-@bar.height)/2 if @a==1
    253.       @bar.src_rect.y = (@h-@bar.height) if @a==2
    254.       @bar.y = @y+(@h-@bar.height)/2 if @a==1
    255.       @bar.y = @y+(@h-@bar.height) if @a==2
    256.     else
    257.       @bar.src_rect.width = @b*@w/@m
    258.       @bar.src_rect.x = (@w-@bar.width)/2 if @a==1
    259.       @bar.src_rect.x = (@w-@bar.width) if @a==2
    260.       @bar.x = @x+(@w-@bar.width)/2 if @a==1
    261.       @bar.x = @x+(@w-@bar.width) if @a==2
    262.     end
    263.   end
    264.   def create_skin
    265.     @skin = Sprite.new
    266.     @skin.bitmap = Cache.system(@s)
    267.     @skin.mirror = @f
    268.     @skin.x = @x
    269.     @skin.y = @y
    270.     @skin.z = @z+2
    271.   end
    272.   def create_text
    273.     @text = Sprite.new
    274.     @text.bitmap = Bitmap.new([@w,@h].max,20)
    275.     @text.bitmap.font.size = [@h,16].max
    276.     @text.x = @x
    277.     @text.x -= @text.width/2 if @v
    278.     @text.y = @y
    279.     @text.z = @z+3
    280.   end
    281.   def getvar
    282.     if @n.is_a? Fixnum
    283.       $game_variables[@n] = [[$game_variables[@n],0].max,@m].min
    284.       @b = $game_variables[@n]
    285.     else
    286.       @b = eval(@n)
    287.     end
    288.   end
    289.   def update
    290.     update_back if @back != nil
    291.     update_bar
    292.     update_text if @text != nil
    293.     update_skin if @skin != nil
    294.   end
    295.   def update_back
    296.     @back.update
    297.   end
    298.   def update_bar
    299.     getvar
    300.     htarget = @b*@h/@m
    301.     wtarget = @b*@w/@m
    302.     boost = Kuro::Bar::BOOST
    303.     return if @bar.height==htarget.round and @bar.width==wtarget.round
    304.     if @v
    305.       if @bar.height>htarget.round
    306.         @bar.src_rect.height = [@bar.src_rect.height-boost,htarget.round].max
    307.       else
    308.         @bar.src_rect.height = [@bar.src_rect.height+boost,htarget.round].min
    309.       end
    310.       @bar.src_rect.y = (@h-@bar.height)/2 if @a==1
    311.       @bar.src_rect.y = (@h-@bar.height) if @a==2
    312.       @bar.y = @y+(@h-@bar.height)/2 if @a==1
    313.       @bar.y = @y+(@h-@bar.height) if @a==2
    314.     else
    315.       if @bar.width>wtarget.round
    316.         @bar.src_rect.width = [@bar.src_rect.width-boost,wtarget.round].max
    317.       else
    318.         @bar.src_rect.width = [@bar.src_rect.width+boost,wtarget.round].min
    319.       end
    320.       @bar.src_rect.x = (@w-@bar.width)/2 if @a==1
    321.       @bar.src_rect.x = (@w-@bar.width) if @a==2
    322.       @bar.x = @x+(@w-@bar.width)/2 if @a==1
    323.       @bar.x = @x+(@w-@bar.width) if @a==2
    324.     end
    325.   end
    326.   def update_skin
    327.     @skin.update
    328.   end
    329.   def update_text
    330.     @text.bitmap.clear
    331.     if @v
    332.       @text.bitmap.draw_text(0,0,@h,@w,convert(@t),1)
    333.       @text.angle=-90
    334.     else
    335.       @text.bitmap.draw_text(0,0,@w,@h,convert(@t),1)
    336.     end
    337.   end
    338.   def convert(text)
    339.     text = text.gsub(/\\b/){@b.to_s}
    340.     text = text.gsub(/\\m/){@m.to_s}
    341.     return text
    342.   end
    343.   def dispose
    344.     @back.dispose if @back != nil
    345.     @bar.dispose
    346.     @text.dispose if @text != nil
    347.     @skin.dispose if @skin != nil
    348.   end
    349. end
    350. class Scene_Map < Scene_Base
    351.   alias kab_potato update
    352.   def update
    353.     kab_potato
    354.     $kab = [] if $kab == nil
    355.     for i in 0...$kab.length
    356.       $kab[i].update unless $kab[i] == nil
    357.     end
    358.   end
    359. end
    复制代码






    How to use?
    Configuration help are written in the module. You may define the bar preset ID by yourself there.
    You may call this via script call event :
    Kuro::Bar.create(ID) to create the bar preset ID
    Kuro::Bar.update(ID, KEY, NEW_VALUE) edit the VALUE from KEY in preset ID.
    Kuro::Bar.delete(ID) Erase the bar preset ID.
    See the demo for more detail.

    Credits
    Kuro DCupu

    Author's Notes
    I'm more like an eventer myself and this script has only been used for my own personal purpose as an eventer until now, so any distaste, error, bug or glitch are expected.
    I did share it on certain forum at http://rmid.forumotion.net/t8641p10-rgss3-kuro-any-bar but not many feedback, thus this script stop progressing by then.


    本贴来自国际rpgmaker官方论坛作者:Kuro DCupu处,因国际论坛即将永久关站,为了存档多年珍贵资料,署名转载到本论坛存档,由于官方帖子为英文原帖,需要中文翻译请点击论坛顶部切换语言为中文就可以将帖子翻译成中文浏览,方便大家随时查看,原文地址:https://forums.rpgmakerweb.com/threads/kuro-any-bar.40919/

    本帖子中包含更多资源

    您需要 登录 才可以下载或查看,没有账号?立即注册

    x
    天天去同能,天天有童年!
    回复 送礼论坛版权

    使用道具 举报

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

    本版积分规则

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

    幸运抽奖

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

    立即查看

    聊天机器人
    Loading...

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

    GMT+8, 2026-8-17 21:14 , Processed in 0.121425 second(s), 52 queries .

    Powered by Discuz! X3.4

    Copyright © 2001-2020, Tencent Cloud.

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