Socket 0 #1 Posted June 29, 2010 (edited) Bem, apenas a V2 do meu Instalador de Scripts. Novas funções: Algumas opções de editor de textos: New (Ctrl + N), Save (Ctrl + S), Save As (Ctrl + Shift + S) Pequeno interpretador: Tools - Run (F5) Cria arquivos .luas (Lua System). Instala arquivos .luas, .lua e .luai É feito em Lua, e diferentemente dos meus outros programas com interface em Lua, não é necessário o uso de um interpretador. Tem um arquivo Installer.exe, feito e compilado em Delphi 7, ele apenas executa o comando no CMD: wlua.exe "Installer.wlua" Para configurar o script, após abrí-lo, aparecerá uma jenela pequena. Onde pedirá o diretório da pasta data de seu otserv, após indicá-la pela primeira vez, bastar clicar em Confirm toda vez que abrir o programa novamente. A lista à esquerda da janela principal, são todos os arquivos com extensão .lua, .luai e .luas, que estão na pasta Installer/scripts Para criar um novo arquivo .luas: Vá em Tools - New system Aparecerá uma lista, e os botões Add, Save, Remove, Realize e Close Os botões Add e Remove, vão adcionando e removendo scripts da lista respectivamente. Obs: Caso o tipo de arquivo for de extensão .lua, basta você indicar o type (action, talkaction, lib, spell, etc), e a tag, que vai em seu respectivo arquivo .xml e clicar em Save. Caso seja de extensão .luai, o type, e a tag serão preenchidos normalmente, você pode mudá-los à vontade e clicar em Save. Obs: Conforme você for clicando nos scripts que você adcionar à lista, o type e a tag irão mudar, conforme você tiver configurado. O botão Close, fecha a caixa sem fazer nada. E o botão Realize, abre uma janela para você escolher o nome, e o local onde irá salvar o arquivo .luas. Após salvar o arquivo .luas, vá até a janela principal e clique em File - Open, procure o arquivo .luas que você acabou de criar. Após abri-lo, clique em Tools - Install a system, e ele será instalado em seu Otserv. Vou postar o script aqui, mas não basta apenas colocá-lo em um arquivo .lua e interpretá-lo, pois ele utiliza de módulos e bibliotecas externas que estão localizados na pasta do download. [spoiler=Script] module("Installer", package.seeall) package.cpath = "?.dll" package.path = "?.lua" require "lib.install" require "wx" require "ex" dofile("system.wlua") local ID_INSTALL = 1 local ID_CLOSE = 2 local ID_OPEN = 3 local ID_SAVE = 4 local ID_NEW = 5 local ID_LOAD = 6 local ID_SAVEAS = 7 local ID_NEWSYS = 8 local ID_SYS = 9 local SCRIPT_DIR for i, v in pairs(install) do _G["__"..i] = v end local frame = wx.wxFrame(wx.NULL, wx.wxID_ANY, "Installer", wx.wxDefaultPosition, wx.wxSize(550,350)) local panel = wx.wxPanel(frame, wx.wxID_ANY) local listBox = wx.wxListBox(panel, wx.wxID_ANY, wx.wxDefaultPosition, wx.wxSize(100,100), __getScripts()) local script = wx.wxTextCtrl(panel, wx.wxID_ANY, "", wx.wxDefaultPosition, wx.wxDefaultSize, wx.wxTE_MULTILINE) local installButton = wx.wxButton(panel, ID_INSTALL, "Install") local closeButton = wx.wxButton(panel, ID_CLOSE, "Close") local mainSizer = wx.wxBoxSizer(wx.wxVERTICAL) local listSizer = wx.wxBoxSizer(wx.wxHORIZONTAL) listSizer:Add(listBox, 0, wx.wxALL+wx.wxEXPAND, 5) listSizer:Add(script, 5, wx.wxALL+wx.wxEXPAND, 5) local buttonSizer = wx.wxBoxSizer(wx.wxHORIZONTAL) buttonSizer:Add(installButton, 0, wx.wxALL, 5) buttonSizer:Add(closeButton, 0, wx.wxALL, 5) mainSizer:Add(listSizer, 5, wx.wxALL+wx.wxEXPAND, 5) mainSizer:Add(buttonSizer, 0, wx.wxALIGN_CENTER, 5) panel:SetSizer(mainSizer) mainSizer:SetSizeHints(panel) local menuBar = wx.wxMenuBar() local menuFile = wx.wxMenu({ {ID_NEW, "New\tCtrl+N", "Create a new script"}, {ID_OPEN, "Open\tCtrl+O", "Open a script"}, { }, {ID_SAVE, "Save\tCtrl+S", "Save the script"}, {ID_SAVEAS, "Save as...\tCtrl+Shift+S", "Save the script as"}, { }, {ID_CLOSE, "Exit\tCtrl+X", "Close window"} }) local toolsFile = wx.wxMenu({ {ID_LOAD, "Run\tF5", "Run program"}, { }, {ID_INSTALL, "Install", "Install current script"}, { }, {ID_NEWSYS, "New system", "Create a new system"}, {ID_SYS, "Install a system", "Install current system"} }) menuBar:Append(menuFile, "File&") menuBar:Append(toolsFile, "Tools") frame:SetMenuBar(menuBar) frame:CreateStatusBar(1) frame:SetStatusText("untitled",0) function loadScript(event) local handle = io.open('scripts/'..event:GetString()) script:SetValue(handle:read('*a')) handle:close() SCRIPT_DIR = 'scripts/'..event:GetString() frame:SetStatusText(event:GetString()) end function close(event) os.exit() panel:Close() end function install(event) if not SCRIPT_DIR then return wx.wxMessageBox("Save the script before install.") end if SCRIPT_DIR:find("%.luai") then dofile(SCRIPT_DIR) Sname = instal_f.name Stag = instal_f.tag Stype = instal_f.module Sscript = instal_f.script local inst = __installScript(Sname, Sscript, Stype, Stag) return inst and wx.wxMessageBox("Script sucessfully installed.") or wx.wxMessageBox("An error ocurred.") end local ID_FINISH = 10 local ID_EXIT = 11 local dialog = wx.wxDialog(wx.NULL, wx.wxID_ANY, "Install", wx.wxDefaultPosition, wx.wxSize(550,350)) local nameLabel = wx.wxStaticText(dialog, wx.wxID_ANY, "Name:") local tagLabel = wx.wxStaticText(dialog, wx.wxID_ANY, "Tag: ") local typeLabel = wx.wxStaticText(dialog, wx.wxID_ANY, "Type: ") local name = wx.wxTextCtrl(dialog, wx.wxID_ANY, "") local tag = wx.wxTextCtrl(dialog, wx.wxID_ANY, "") local types = {"action", "creatures", "global", "lib", "movement", "raid", "spell", "talkaction"} local type = wx.wxComboBox(dialog, wx.wxID_ANY, "Select type", wx.wxDefaultPosition, wx.wxSize(100,-1), types) local mainSizer = wx.wxBoxSizer(wx.wxVERTICAL) local firstSizer = wx.wxBoxSizer(wx.wxHORIZONTAL) firstSizer:Add(nameLabel, 0, wx.wxALL+wx.wxEXPAND, 5) firstSizer:Add(name, 5, wx.wxALL+wx.wxEXPAND, 5) local secondSizer = wx.wxBoxSizer(wx.wxHORIZONTAL) secondSizer:Add(tagLabel, 0, wx.wxALL+wx.wxEXPAND, 5) secondSizer:Add(tag, 5, wx.wxALL+wx.wxEXPAND, 5) local thirdSizer = wx.wxBoxSizer(wx.wxHORIZONTAL) thirdSizer:Add(typeLabel, 0, wx.wxALL+wx.wxEXPAND, 5) thirdSizer:Add(type, 5, wx.wxALL+wx.wxEXPAND, 5) local buttonSizer = wx.wxBoxSizer(wx.wxHORIZONTAL) local finishButton = wx.wxButton(dialog, ID_FINISH, "Install") local exitButton = wx.wxButton(dialog, ID_EXIT, "Close") buttonSizer:Add(finishButton, 0, wx.wxALIGN_CENTER_VERTICAL, 5) buttonSizer:Add(exitButton, 0, wx.wxALIGN_CENTER_VERTICAL, 5) mainSizer:Add(firstSizer, 0, wx.wxALL+wx.wxEXPAND, 5) mainSizer:Add(secondSizer, 0, wx.wxALL+wx.wxEXPAND, 5) mainSizer:Add(thirdSizer, 0, wx.wxALL+wx.wxEXPAND, 5) mainSizer:Add(buttonSizer, 0, wx.wxALL+wx.wxEXPAND, 5) function closeDialog(event) dialog:Close() end function installScript(event) if script:GetValue() == '' then return wx.wxMessageBox("Open a script to install.") end local Sname = name:GetValue() local Stag = tag:GetValue() local Stype = types[type:GetSelection()+1] if Sname == '' or Stag == '' or Stype == '' then return wx.wxMessageBox("Fill all ctrls to install.") end local _ = install local inst = __installScript(Sname, script:GetValue(), Stype, Stag) closeDialog() return inst and wx.wxMessageBox("Script sucessfully installed.") or wx.wxMessageBox("An error ocurred.") end dialog:Connect(ID_EXIT, wx.wxEVT_COMMAND_BUTTON_CLICKED, closeDialog) dialog:Connect(ID_FINISH, wx.wxEVT_COMMAND_BUTTON_CLICKED, installScript) dialog:SetSizer(mainSizer) mainSizer:SetSizeHints(dialog) dialog:Show() end function openScript(event) local openFile = wx.wxFileDialog(panel, "Open script", "", "", "Lua files (*.lua)|*.lua|Luai files (*.luai)|*.luai|System files (*.luas)|*.luas|", wx.wxOPEN + wx.wxFILE_MUST_EXIST) openFile:ShowModal() if openFile:GetPath() == '' then return end local handle = io.open(openFile:GetPath()) if not handle then return wx.wxMessageBox("Cannot open script " .. openFile:GetPath()) end script:SetValue(handle:read('*a')) SCRIPT_DIR = openFile:GetPath() frame:SetStatusText(SCRIPT_DIR:GetName()) end function saveAs(event) local saveFile = wx.wxFileDialog(frame, "Save file as", '', '', "Lua files (*.lua)|*.lua|Luai files (*.luai)|*.luai|System files (*.luas)|*.luas|", wx.wxSAVE) saveFile:ShowModal() local handle = io.open(saveFile:GetPath(), "w") if saveFile:GetPath() == '' then return true end handle:write(script:GetValue()) handle:close() SCRIPT_DIR = saveFile:GetPath() frame:SetStatusText(SCRIPT_DIR:GetName(), 0) listBox:Set(__getScripts()) return true end function saveScript(event) if SCRIPT_DIR then local handle = io.open(SCRIPT_DIR, 'w') handle:write(script:GetValue()) handle:close() return true end local saveFile = wx.wxFileDialog(frame, "Save file as", '', '', "Lua files (*.lua)|*.lua|Luai files(*.luai)|*.luai|System files (*.luas)|*.luas|", wx.wxSAVE) saveFile:ShowModal() local handle = io.open(saveFile:GetPath(), "w") if saveFile:GetPath() == '' then return true end handle:write(script:GetValue()) handle:close() SCRIPT_DIR = saveFile:GetPath() frame:SetStatusText(SCRIPT_DIR:GetName()) listBox:Set(__getScripts()) return true end function saveScriptAs(event) return saveAs(event) end panel:Connect(wx.wxID_ANY, wx.wxEVT_COMMAND_LISTBOX_SELECTED, loadScript) panel:Connect(ID_CLOSE, wx.wxEVT_COMMAND_BUTTON_CLICKED, close) frame:Connect(ID_CLOSE, wx.wxEVT_COMMAND_MENU_SELECTED, close) panel:Connect(ID_INSTALL, wx.wxEVT_COMMAND_BUTTON_CLICKED, install) frame:Connect(ID_INSTALL, wx.wxEVT_COMMAND_MENU_SELECTED, install) frame:Connect(ID_OPEN, wx.wxEVT_COMMAND_MENU_SELECTED, openScript) frame:Connect(ID_SAVE, wx.wxEVT_COMMAND_MENU_SELECTED, saveScript) frame:Connect(ID_NEW, wx.wxEVT_COMMAND_MENU_SELECTED, function() script:SetValue("") SCRIPT_DIR = nil frame:SetStatusText("untitled") end ) frame:Connect(ID_SAVEAS, wx.wxEVT_COMMAND_MENU_SELECTED, saveAs) frame:Connect(ID_LOAD, wx.wxEVT_COMMAND_MENU_SELECTED, function() local s, y = pcall(loadstring(script:GetValue())) a, i = loadstring(script:GetValue()) if not s then print(i) end end ) function confirm() local ID_CONFIRM = 20 local dialog = wx.wxDialog(wx.NULL, wx.wxID_ANY, "Confirm data dir", wx.wxDefaultPosition) local dirPicker = wx.wxDirPickerCtrl(dialog, wx.wxID_ANY, __getDataDir(), wx.wxDirSelectorPromptStr, wx.wxDefaultPosition, wx.wxDefaultSize, wx.wxDIRP_DEFAULT_STYLE) local confirmButton = wx.wxButton(dialog, ID_CONFIRM, "Confirm") local mainSizer = wx.wxBoxSizer(wx.wxVERTICAL) mainSizer:Add(dirPicker, 0, wx.wxALL+wx.wxEXPAND, 5) mainSizer:Add(confirmButton, 0, wx.wxALL+wx.wxEXPAND, 5) dialog:Connect(ID_CONFIRM, wx.wxEVT_COMMAND_BUTTON_CLICKED, function() local handle = io.open("datadir.txt", "w") handle:write(dirPicker:GetPath()) handle:close() dialog:Close() end ) dialog:SetSizer(mainSizer) mainSizer:SetSizeHints(dialog) dialog:Show() end function eventInstallSystem() if not SCRIPT_DIR:find("%.luas") then return wxMessageBox("Open a system file (*.luas)") end installSystem(SCRIPT_DIR) wxMessageBox("System sucessfully installed.") return true end frame:Connect(ID_NEWSYS, wxEVT_COMMAND_MENU_SELECTED, create) frame:Connect(ID_SYS, wxEVT_COMMAND_MENU_SELECTED, eventInstallSystem) frame:Show() confirm() wx.wxGetApp():MainLoop() Download: http://www.4shared.com/file/MksbNAgL/_2__Installer.html [spoiler=Fotos] Edited January 23, 2011 by Mickfern Share this post Link to post Share on other sites
Mock 32 #2 Posted June 30, 2010 oia mal fez o 1.0 ja saiu o 2 Share this post Link to post Share on other sites
Bloxe 0 #3 Posted June 30, 2010 cara, foda demais, ta to usando, vlws (Y) Share this post Link to post Share on other sites