累计送礼: 0 个 累计收礼: 1 个 TA的每日心情 开心 2026-7-12 04:10
签到天数: 209 天
连续签到: 2 天
[LV.7]常住居民III
管理员
VIP
7
卡币
58883
OK点
16
推广点
0
同能卷
50
积分 68848
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:
=begin ================================================================================ KURO ANY BAR V2.0 ================================================================================ Introduction : A multi simple active bar for any kind of use. From now will be used to support my advanced event system. ================================================================================ Changelog : V.2.1 (10-12-2014) * More property : skinpic. * Kini hanya menerima nilai dari game variable. * Fixed, value yang nembus nilai max atau kurang dari 0. * Fixed, flip picture. * Fixed, ukuran dan posisi text. * Rapihin. V.2.0 (06-09-2014) * Method baru : Kuro::Bar.update * More property : picture, gradien, etc. * Gauge animatif. * New interface : rombak habis-habisan. V.1.0 (03-09-2014) * Awal pembuatan, dan selesainya script. ================================================================================ Current feature : * Multi simple custom bar. * Come with custom text. * Could be aligned. * Vertical? no prob~ * Can use picture as the bar. ================================================================================ How to use : Konfigurasi bar nya berada di module sesuai dengan format yang tertera. Jadi tinggal siap panggil di mana saja melalui event dengan script call. Kuro::Bar.create(ID) <<< buat bar Kuro::Bar.update(ID,KEY,VALUE) <<< edit property bar Kuro::Bar.delete(ID) <<< hapus bar ID = adalah nomor id preset yang anda buat (0 = default preset) KEY = nama property daripada bar di preset anda (:x, :y, :width) VALUE = nilai baru untuk property preset anda. ================================================================================ =end module Kuro module Bar #=============================================================================== # CONFIGURATION START #=============================================================================== # COLOR PALLETTE # ============================================================================== # Palet warna. Silahkan saja kalo mau membuat warna anda sendiri. # WARNA = Color.new(red, green, blue) BLACK = Color.new(0,0,0) WHITE = Color.new(255,255,255) RED = Color.new(255,0,0) GREEN = Color.new(0,255,0) BLUE = Color.new(0,0,255) YELLOW = Color.new(255,255,0) CYAN = Color.new(0,255,255) MAGENTA = Color.new(255,0,255) # Palet warna untuk gradient. Gabung-gabungkan saja palet warna di atas. # HANYA 2 WARNA ! # GRADIEN = [WARNA 1, WARNA 2] GREENBLACK = [GREEN,BLACK] BLUEBLACK = [BLUE,BLACK] REDBLACK = [RED,BLACK] # BAR DEFAULT VALUE # ============================================================================== PRESET = [{ # Default setting # Setting default nya (PRESET[0]). # Kalo ada property yang gak ada di preset yang anda buat, bakal pake value # dari property yang ada di sini. :x => 0, # X coordinate :y => 0, # Y coordinate :z => 50, # Z coordinate :width => 100, # Bar width :height => 10, # Bar height :color => WHITE, # Bar color :opaback => 255, # Back skin opacity (0~255) :picture => nil, # Use picture as bar (in folder system) :skinpic => nil, # Use picture as bar foreskin (in folder system) :flip => false, # Flip the bar? :text => nil, # Text (\\b = base value, \\m = max value) :align => 0, # Bar align (0 = left, 1 = mid, 2 = right) :base => 1, # Variable ID as base value (use "" for eval script) :max => "100", # Variable ID as max value (use "" for eval script) :vertical => false # Was it vertical? }] # Kecepatan animasi bar. Semakin gede, semakin cepat. BOOST = 3 # BAR PRESET #=============================================================================== # Mulai buat preset anda sendiri dari sini. Berantakan gak masalah selama # nama key nya bener. Ingat, jangan lupa naruh tanda koma! PRESET[1] = { # Actor 1 HP :base => "$game_actors[1].hp", :max => "$game_actors[1].mhp", :text => "[\\b/\\m]", :color => GREENBLACK, :width => 120, :height => 12, :skinpic => "barskin", } PRESET[2] = { # Actor 1 MP :y => 12, :width => 120, :height => 12, :color => BLUEBLACK, :base => "$game_actors[1].mp", :max => "$game_actors[1].mmp", :text => "[\\b/\\m]", :skinpic => "barskin", } PRESET[3] = { # Quest : Kill Rat :x => 16, :y => 380, :width => 512, :height => 24, :color => REDBLACK, :opaback => 128, :base => 1, :max => "10", :text => "kill rat (\\b/\\m)", } PRESET[4] = { # Mashing Button !!! :x => 192, :y => 240, :picture => "screwthis", :opaback => 200, :base => 2, :max => "100", :align => 1, } PRESET[5] = { # Hit me! :x => 364, :width => 180, :height => 24, :base => 3, :max => "30", :text => "[\\b/\\m]", :align => 2, } #=============================================================================== # CONFIGURATION END #=============================================================================== def self.create(id) $kab[id] = AnyBar.new(id) end def self.update(id,key,value) return if PRESET[id][key] == value PRESET[id][key] = value if $kab[id] != nil $kab[id].load end end def self.delete(id) if $kab[id] != nil $kab[id].dispose $kab[id] = nil end end end end class AnyBar def initialize(id) @id = id load end def load d = Kuro::Bar::PRESET[0] v = Kuro::Bar::PRESET[@id] a = d.keys k = [] for i in 0...a.size if v.include?(a[i]) k[i] = v[a[i]] else k[i] = d[a[i]] end end @x = k[0] @y = k[1] @z = k[2] @w = k[3] @h = k[4] @c = k[5] @o = k[6] @p = k[7] @s = k[8] @f = k[9] @t = k[10] @a = k[11] @n = k[12] if k[13].is_a? Fixnum @m = [$game_variables[k[13]],1].max else @m = [eval(k[13]),1].max end @v = k[14] refresh create end def refresh @back.bitmap.dispose unless @back==nil @bar.bitmap.dispose unless @bar==nil @skin.bitmap.dispose unless @skin==nil @text.bitmap.dispose unless @text==nil end def create create_back if @o > 0 create_bar create_skin if @s != nil create_text if @t != nil update end def create_back @back = Sprite.new if @p != nil @back.bitmap = Cache.system(@p) @back.tone = Tone.new(-255,-255,-255) @back.mirror = @f else @back.bitmap = Bitmap.new(@w,@h) @back.bitmap.fill_rect(0,0,@w,@h,Color.new(0,0,0,@o)) end @back.x = @x @back.y = @y @back.z = @z end def create_bar @bar = Sprite.new if @p != nil @bar.bitmap = Cache.system(@p) @w = @bar.bitmap.width @h = @bar.bitmap.height @bar.mirror = @f else @bar.bitmap = Bitmap.new(@w,@h) if @c.is_a? Array @bar.bitmap.gradient_fill_rect(0,0,@w,@h,@c[0],@c[1],@v) else @bar.bitmap.fill_rect(0,0,@w,@h,@c) end end @bar.x = @x @bar.y = @y @bar.z = @z+1 getvar if @v @bar.src_rect.height = @b*@h/@m @bar.src_rect.y = (@h-@bar.height)/2 if @a==1 @bar.src_rect.y = (@h-@bar.height) if @a==2 @bar.y = @y+(@h-@bar.height)/2 if @a==1 @bar.y = @y+(@h-@bar.height) if @a==2 else @bar.src_rect.width = @b*@w/@m @bar.src_rect.x = (@w-@bar.width)/2 if @a==1 @bar.src_rect.x = (@w-@bar.width) if @a==2 @bar.x = @x+(@w-@bar.width)/2 if @a==1 @bar.x = @x+(@w-@bar.width) if @a==2 end end def create_skin @skin = Sprite.new @skin.bitmap = Cache.system(@s) @skin.mirror = @f @skin.x = @x @skin.y = @y @skin.z = @z+2 end def create_text @text = Sprite.new @text.bitmap = Bitmap.new([@w,@h].max,20) @text.bitmap.font.size = [@h,16].max @text.x = @x @text.x -= @text.width/2 if @v @text.y = @y @text.z = @z+3 end def getvar if @n.is_a? Fixnum $game_variables[@n] = [[$game_variables[@n],0].max,@m].min @b = $game_variables[@n] else @b = eval(@n) end end def update update_back if @back != nil update_bar update_text if @text != nil update_skin if @skin != nil end def update_back @back.update end def update_bar getvar htarget = @b*@h/@m wtarget = @b*@w/@m boost = Kuro::Bar::BOOST return if @bar.height==htarget.round and @bar.width==wtarget.round if @v if @bar.height>htarget.round @bar.src_rect.height = [@bar.src_rect.height-boost,htarget.round].max else @bar.src_rect.height = [@bar.src_rect.height+boost,htarget.round].min end @bar.src_rect.y = (@h-@bar.height)/2 if @a==1 @bar.src_rect.y = (@h-@bar.height) if @a==2 @bar.y = @y+(@h-@bar.height)/2 if @a==1 @bar.y = @y+(@h-@bar.height) if @a==2 else if @bar.width>wtarget.round @bar.src_rect.width = [@bar.src_rect.width-boost,wtarget.round].max else @bar.src_rect.width = [@bar.src_rect.width+boost,wtarget.round].min end @bar.src_rect.x = (@w-@bar.width)/2 if @a==1 @bar.src_rect.x = (@w-@bar.width) if @a==2 @bar.x = @x+(@w-@bar.width)/2 if @a==1 @bar.x = @x+(@w-@bar.width) if @a==2 end end def update_skin @skin.update end def update_text @text.bitmap.clear if @v @text.bitmap.draw_text(0,0,@h,@w,convert(@t),1) @text.angle=-90 else @text.bitmap.draw_text(0,0,@w,@h,convert(@t),1) end end def convert(text) text = text.gsub(/\\b/){@b.to_s} text = text.gsub(/\\m/){@m.to_s} return text end def dispose @back.dispose if @back != nil @bar.dispose @text.dispose if @text != nil @skin.dispose if @skin != nil end end class Scene_Map < Scene_Base alias kab_potato update def update kab_potato $kab = [] if $kab == nil for i in 0...$kab.length $kab[i].update unless $kab[i] == nil end end 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