[Script] [ACE] [VXA] Tổng hợp các lệnh nho nhỏ bằng script

135

Comments

  • NagiNagi Posts: 589Registered
    Focker_c wrote:
    Công nhận một điều là phức tạp hơn GM Lang ^^


    ___________


    Lại hỏi lại một chút. Draw item ở một tọa độ thì câu lệnh như nào nhỉ ?
    Hỏi ở top nào đó rồi nhưng lục lại 30p ko thấy đâu ... :)
    draw_icon(icon_index, x, y, enabled = true)
  • Dang_KhoaDang_Khoa Posts: 3,861Administrators
    Focker_c wrote:
    Công nhận một điều là phức tạp hơn GM Lang ^^

    Cú pháp nó khác nhau thôi, chứ về bản chất là giống, anh từng dùng GML nên biết :3
  • Focker_cFocker_c Posts: 1,577Registered
    Ko đc Nagi ei :(

    Đây :
    [php]class Window_Text < Window_Base
    #
    # * Object Initialization
    #
    def initialize(x, y)
    super(x, y, 160, 64)
    self.contents = Bitmap.new(width - 32, height - 32)
    end
    #
    # * Draw text
    #
    def drawText(i_text, i_color)
    self.contents.clear
    self.contents.font.color = text_color(i_color)
    self.contents.draw_text(4, 0, 120, 32, i_text)
    self.contents.draw_icon(15, 0, 0,true)
    end
    end[/php]

    Đã thêm
    self.contents.draw_icon(15, 0, 0,true)

    Why ?
  • NagiNagi Posts: 589Registered
    Dunno, mù tịt vụ đo :huhu:
  • Focker_cFocker_c Posts: 1,577Registered
    Vậy mình sử dụng cái lệnh draw_icon ở đâu được ? @nagi
  • NagiNagi Posts: 589Registered
    Focker_c wrote:
    Vậy mình sử dụng cái lệnh draw_icon ở đâu được ? @nagi
    Vào scripts editor của VXA rồi bâm F11 -> Ctrl Shift F rồi gõ:
    def draw_icon là thây, no nằm trong windows_base
  • Focker_cFocker_c Posts: 1,577Registered
    @ Mới chuyển qua RPG Maker mà, đâu biết gì đâu.
    Ý của mình là mình có cái script này của @slucis7593 :

    [php]class Window_Text < Window_Base
    #
    # * Object Initialization
    #
    def initialize
    super(0, 0, 160, 64)
    self.contents = Bitmap.new(width - 32, height - 32)
    end
    #
    # * Draw text
    #
    def drawText(i_text, i_color)
    self.contents.clear
    self.contents.font.color = text_color(i_color)
    self.contents.draw_text(4, 0, 120, 32, i_text)
    end
    end[/php]

    Nhưng viết mã \i[icon_id] vào trong cái window này thì nó ko hiện icon. Giờ phải làm sao để vẽ đc icon ở trong cái window ấy ?
  • slucis7593slucis7593 Posts: 544Registered
    @Focker_c:
    Cậu dùng hàm draw_icon() được định nghĩa trong class Window_Base này:
    [php]
    #
    # * Draw Icon
    # enabled : Enabled flag. When false, draw semi-transparently.
    #
    def draw_icon(icon_index, x, y, enabled = true)
    bitmap = Cache.system("Iconset")
    rect = Rect.new(icon_index % 16 * 24, icon_index / 16 * 24, 24, 24)
    contents.blt(x, y, bitmap, rect, enabled ? 255 : translucent_alpha)
    end
    [/php]


    Bây giờ chèn vào đoạn script ở trên sẽ thành:
    [php]
    class Window_Text < Window_Base
    #
    # * Object Initialization
    #
    def initialize(i_left, i_top, i_width, i_height)
    super(i_left, i_top, i_width, i_height)
    self.contents = Bitmap.new(width - 32, height - 32)
    end
    #
    # * Draw text
    #
    def drawText(i_text, i_color, i_id_icon)
    self.contents.clear
    self.contents.font.color = text_color(i_color)
    self.contents.draw_text(4, 0, 120, 32, i_text)
    self.draw_icon(i_id_icon, 12, 32)
    end
    end
    [/php]


    Hoặc có thể dùng trực tiếp call script ở event:
    [php]
    $window = Window_Text.new()
    $window.draw_icon(1, 4, 12)
    [/php]


    Nếu muốn vẽ item được định nghĩa trong database item thì dùng hàm: draw_item_name() cũng được định nghĩa trong class Window_Base
    [php]
    #
    # * Draw Item Name
    # enabled : Enabled flag. When false, draw semi-transparently.
    #
    def draw_item_name(item, x, y, enabled = true, width = 172)
    return unless item
    draw_icon(item.icon_index, x, y, enabled)
    change_color(normal_color, enabled)
    draw_text(x + 24, y, width, line_height, item.name)
    end
    [/php]


    Ở trên vị trí vẽ mình fixed cứng, không sửa được nên cậu muốn sửa thì thêm tham số vào hàm nhé :)

    Nhìn chung draw được nhiều cái lắm, cậu bật lên mà tham khảo :D
  • Focker_cFocker_c Posts: 1,577Registered
    :(
    Tình hình là vẫn ko draw đc icon , @slucis7593 ơi .

    Xài
    [php]$window = Window_Text.new()
    $window.draw_icon(1, 4, 12) [/php]

    Cũng ko được mà cho cái script này vào xài cũng ko được :

    [php]class Window_Text < Window_Base
    #
    # * Object Initialization
    #
    def initialize(i_left, i_top, i_width, i_height)
    super(i_left, i_top, i_width, i_height)
    self.contents = Bitmap.new(width - 32, height - 32)
    end
    #
    # * Draw text
    #
    def drawText(i_text, i_color, i_id_icon)
    self.contents.clear
    self.contents.font.color = text_color(i_color)
    self.contents.draw_text(4, 0, 120, 32, i_text)
    self.draw_icon(i_id_icon, 12, 32)
    end
    end [/php]

    haiz :(
  • DeathDeath Posts: 732Registered, Moderators
    Call Script:
    $window = Window_Text.new(0,0,100,100)
    $window.drawText(1, 4, 12)
    
  • Focker_cFocker_c Posts: 1,577Registered
    Đã thử cái đó rồi @death ơi :( !
  • DeathDeath Posts: 732Registered, Moderators
    New project copy script ở trên rồi call script thử xem.
    :ngaytho:
  • slucis7593slucis7593 Posts: 544Registered
    @Focker_c :
    -_- hiz, sao máy bác cứ khác khác vậy nhỉ, máy mình chạy ngon mà.

    Mình dùng call script:
    [php]
    $wd = Window_Text.new(0, 0, 160, 100)
    $wd.drawText("Hello", 0, 7)
    $wd.draw_icon(5, 40, 30)
    [/php]


    Hiển thị được 2 cái icon thứ 7 và thứ 5 lên cửa sổ đây này:

    10177270_281289035376631_4345725718013681079_n.jpg
  • Focker_cFocker_c Posts: 1,577Registered
    Buồn hết cả cười :D :D :D
    Lỗi do script khác :D lại cứ tưởng là cái này lỗi :D
    Fix rồi ^^
    Ok ok ! Cảm ơn mọi người ^^
  • iPhone69iPhone69 Posts: 9Registered
    Xin phép được bổ sung
    Lệnh toàn màn hình:
    [php]
    keybd = Win32API.new 'user32.dll', 'keybd_event', , 'v'
    keybd.call(0xA4, 0, 0, 0) ; keybd.call(13, 0, 0, 0) 
    keybd.call(13, 0, 2, 0) ; keybd.call(0xA4, 0, 2, 0) 
    [/php]
    Giải thích: lệnh này giả lập tổ hợp phím Alt+Enter để fullscreen
Sign In or Register to comment.