[Moduł]Change Log
[Moduł]Change Log
Witam.
Tym razem chciałbym wam przedstawić skrypt który daje nam możliwość wypisania listy zmian na naszym serwerze podczas "Update'ów"
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:
1b. Tworzymy plik changelog.otmod i wypełniamy go tym:
Pozdrawiam.
Tym razem chciałbym wam przedstawić skrypt który daje nam możliwość wypisania listy zmian na naszym serwerze podczas "Update'ów"
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
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()
- 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()
Pozdrawiam.
Permissions in this forum:
Nie możesz odpowiadać w tematach
|
|