Tibia Mod
Forum zostało Przeniesione tutaj:
http://tibiamod.xaa.pl/

Zapraszam.

Join the forum, it's quick and easy

Tibia Mod
Forum zostało Przeniesione tutaj:
http://tibiamod.xaa.pl/

Zapraszam.
Tibia Mod
Czy chcesz zareagować na tę wiadomość? Zarejestruj się na forum za pomocą kilku kliknięć lub zaloguj się, aby kontynuować.

[Moduł]Change Log

Go down

[Moduł]Change Log Empty [Moduł]Change Log

Pisanie by Sedron Nie Mar 16, 2014 6:42 pm

Witam.

Tym razem chciałbym wam przedstawić skrypt który daje nam możliwość wypisania listy zmian na naszym serwerze podczas "Update'ów"

[Moduł]Change Log WBvSdAq

To do dzieła.
1. Wchodzimy w folder modules i tworzymy folder client_changelog.
1a. Tworzymy w nim plik o nazwie changelog.lua, który wypełniamy tym:
Kod:

local changelogWindow = nil
local changelogButton = nil

local changes = {
    [1] = {
        patch = "1.0",
        changes = {
            "- Added dragon spawn",
            "- Remove dragon spawn"
        }    
    },
    [2] = {
        patch = "1.1",
        changes = {
            "- Reworked dragon spawn",
            "- Fixed NPC bugs"
        }
    }
}

function init()
  changelogWindow = g_ui.displayUI('changelog')
  changelogWindow:hide()

  changelogButton = modules.client_topmenu.addLeftButton('changelogButton', tr('Changelog'), 'changelog', toggle)
  
  changelogWindow:breakAnchors()
  changelogWindow:setPosition({x = 100, y = 100})
  changelogWindow.onEnter = hide
  changelogWindow.onEscape = hide
  
  changelogText = changelogWindow:recursiveGetChildById('text')
  local text = ""
  for i = 1, #changes do
    local tmp = changes[i]
    text = string.format("%s[Patch %s]\n", text, tmp.patch)
    for j = 1, #tmp.changes do
        text = string.format("%s%s\n", text, tmp.changes[j])
    end
    text = string.format("%s\n", text)
  end
  changelogText:setText(text)
end

function terminate()
  changelogWindow:destroy()
  changelogButton:destroy()
end

function toggle()
    if changelogWindow:isVisible() then
        changelogWindow:hide()
        changelogButton:setOn(false)
    else
        changelogWindow:show()
        changelogButton:setOn(true)
        changelogWindow:focus()
    end
end

function hide()
    changelogWindow:hide()
    changelogButton:setOn(false)
end
Skrypt oczywiście edytujemy po każdym Update.
1b. Tworzymy plik changelog.otmod i wypełniamy go tym:
Kod:

Module
  name: client_changelog
  description: Convey your latest changes
  author: Summ Publiced by Sedron
  website: http://otland.net/members/summ.17398/
  sandboxed: true
  autoload: true
  autoload-priority: 1000
  scripts: [ changelog ]
  @onLoad: init()
  @onUnload: terminate()
1c. Następnie tworzymy plik o nazwie changelog.otui i wklejamy do niego:
Kod:

MainWindow
  id: changelogWindow
  !text: tr('Changelog')
  size: 480 340

  MultilineTextEdit
    id: text
    anchors.top: textScroll.top
    anchors.left: parent.left
    anchors.right: textScroll.left
    anchors.bottom: textScroll.bottom
    vertical-scrollbar: textScroll
    text-wrap: true
    editable: false

  VerticalScrollBar
    id: textScroll
    anchors.top: parent.top
    anchors.bottom: next.top
    anchors.right: parent.right
    margin-top: 10
    margin-bottom: 10
    step: 16
    pixels-scroll: true

  Button
    !text: tr('Ok')
    width: 64
    anchors.right: parent.right
    anchors.bottom: parent.bottom
    @onClick: modules.client_changelog.hide()
1d. Ostatnią czynnością będzie dodanie do folderu ikonki moduły, którą pobierzemy Tutaj.

Pozdrawiam.
Sedron
Sedron
Admin

Liczba postów : 97
Join date : 11/11/2012

https://tibiamod.forumpl.net

Powrót do góry Go down

Powrót do góry

- Similar topics

 
Permissions in this forum:
Nie możesz odpowiadać w tematach