Author Topic: script manger conversion help  (Read 5500 times)

0 Members and 1 Guest are viewing this topic.

Offline rolipoli

  • Junior Member
  • **
  • Posts: 19
  • Karma: +0/-1
  • Transilvania-Erd?ly
script manger conversion help
« on: 29 March, 2008, 18:18:00 »
Hello all!Please help me to convert this script for the new API.Here is the script:

Code: [Select]
-- modified Textfile manager to Scripts manager by Achiever 21/05/2007
-- added right click functions also
-- also change a bit of pattern matching
-- main chat block bug fixed thks to brock for report 24/05/2007

-- TEXtfile Manager
-- Made by Madman

-- Fixed: small path bug
-- Added: Syntax error to addscript
-- Changed: better pattern matching, thanks bastya
-- Revision by American Idiot [ mod by achiever as 'Scripts Mgr.']

-- Commands
-- addscript NewFile [New script to add]
-- delscript DelFile
-- showtxt

local HUB = frmHub:GetHubName()
local sBot = "[ScriptManager]"

function Main()
frmHub:RegBot(sBot)
end

local tCmds = {
["addscript"] = function(curUser,data)
local method = "added"
local _,_,flag = data:lower():find("%b<> %p%a+ %S+ (%/o)")
local _,_,file,script = data:find("%b<> %p%a+ (%S+) [%/o ]*(.+)")
if file and script then
--Add more codes to replace here, if needed
local t = {
[1] = {"\r\n","\n"},
[2] = {"&amp;","&"},
}
for i, v in pairs(t) do
script = script:gsub(v[1],v[2])
end
for code in script:gmatch("&#(%d+);") do
code = tonumber(code)
if code ~= 124 then
script = script:gsub("%&%#"..code.."%;",string.char(code))
end
end
file = file:gsub("%.lua","")..".lua"
local r,e = os.rename(file,file)
if r then
if not flag then
return curUser:SendPM(sBot,file.." exists, syntax: !addscript"..
" filename script [filename /o script  to overwrite])")
else
method = "updated"
end
end
local txt = io.open(file,"w+")
txt:write(script)
txt:flush()
txt:close()
curUser:SendPM(sBot,file.." "..method..", please reload scripts")
else
curUser:SendPM(sBot,"syntax: !addscript filename [script to add]")
end
end,
["delscript"] = function(curUser,data)
local s,e,file = data:find("%b<>%s+%S+%s+(%w+)%.*.*")
if file then
os.remove(file..".lua")
curUser:SendPM(sBot,file.. ".lua removed, please reload scripts")
end
end,
}

function ChatArrival(curUser,data)
if curUser.iProfile == 0 then
data = data:sub(1,-2)
local s,e,cmd = data:find("%b<> %p(%S+)")
if cmd and tCmds[cmd] then
return tCmds[cmd](curUser,data),1
end
end
end
ToArrival = ChatArrival

function OpConnected(user)
if user.iProfile == 0 then
user:SendData("$UserCommand 1 3 "..HUB.."\\Script Commands\\"..sBot.."\\Add Script$<%[mynick]> +addscript %[line:Filename (filename -o  to overwrite))] %[line:Script body]&#124;")
user:SendData("$UserCommand 1 3 "..HUB.."\\Script Commands\\"..sBot.."\\Delete Script$<%[mynick]> +delscript %[line:Filename]&#124;")
user:SendData("$UserCommand 1 3 "..HUB.."\\Script Commands\\"..sBot.."\\Restart Script$<%[mynick]> +restartscript %[line:Filename]&#124;")
user:SendData("$UserCommand 1 3 "..HUB.."\\Script Commands\\"..sBot.."\\Start Script$<%[mynick]> +startscript %[line:Filename]&#124;")
user:SendData("$UserCommand 1 3 "..HUB.."\\Script Commands\\"..sBot.."\\Stop Script$<%[mynick]> +stopscript %[line:Filename]&#124;")
--user:SendData("$UserCommand 1 3 "..HUB.."\\Script Commands\\"..sBot.."\\Restart All Scripts$ <%[mynick]> +restartscripts&#124;")
user:SendData("$UserCommand 1 3 "..HUB.."\\Script Commands\\"..sBot.."\\Get Scripts$<%[mynick]> +getscripts&#124;")
end
end
I tried to convert it,but in the converted version didn't appear the right click menu,and the "delscript" command didn't work.I attached the converted version to.Please help!Sorry for my bad english.
Thanks in advance. rolipoli
« Last Edit: 29 March, 2008, 18:21:49 by rolipoli »

PtokaX forum

script manger conversion help
« on: 29 March, 2008, 18:18:00 »

Offline rolipoli

  • Junior Member
  • **
  • Posts: 19
  • Karma: +0/-1
  • Transilvania-Erd?ly
Re: script manger conversion help
« Reply #1 on: 30 March, 2008, 13:01:16 »
Thank you Sir for the quick answer :) ,but unfortunately there are some problems :
1.when i give the "restartscripts"from the rightclickmenu its disconnect me from the hub.
2.on the "addscript"command which i give in private to the bot the script it stops and the error message is:Syntax scriptmanager.lua:60: bad argument count to 'SendPmToUser'(3 expected,got 4).
3.and these error message appear: Syntax scriptmanager.lua:69: bad argument count to 'SendPmToUser'(3 expected,got 4)
on the "delscript" commnad from the right clicker, and in private, if i use the command nothing happend
What is the cause of this errors,and can be fixed it? ???

Offline Tw?sT?d-d?v

  • Lord
  • ***
  • Posts: 436
  • Karma: +79/-2
    • EURO-OP
Re: script manger conversion help
« Reply #2 on: 30 March, 2008, 14:25:47 »
having a quick look at script shouldnt Core:  be  Core.  ?
And the restartallscript in the first script is stoped/commeted   
Code: [Select]

user:SendData("$UserCommand 1 3 "..HUB.."\\Script Commands\\"..sBot.."\\Stop Script$<%[mynick]> +stopscript %[line:Filename]&#124;")
--user:SendData("$UserCommand 1 3 "..HUB.."\\Script Commands\\"..sBot.."\\Restart All Scripts$ <%[mynick]> +restartscripts&#124;")
user:SendData("$UserCommand 1 3 "..HUB.."\\Script Commands\\"..sBot.."\\Get Scripts$<%[mynick]> +getscripts&#124;")

That might be cause it didnt work b4  ??
« Last Edit: 30 March, 2008, 14:44:32 by Tw?sT?d-d?v »

Offline Madman

  • Scripter
  • Emperor
  • ******
  • Posts: 1 316
  • Karma: +75/-1
Re: script manger conversion help
« Reply #3 on: 30 March, 2008, 14:33:51 »
Yes. Core: should be Core.
Change that and it should work.
We suffer in silence, we lurk in the shadows, we kill in the night
Site currently down, ETA of returning online is 2099 ;p

Offline rolipoli

  • Junior Member
  • **
  • Posts: 19
  • Karma: +0/-1
  • Transilvania-Erd?ly
Re: script manger conversion help
« Reply #4 on: 31 March, 2008, 12:20:58 »
having a quick look at script shouldnt Core:  be  Core.  ?
And the restartallscript in the first script is stoped/commeted   
Code: [Select]

user:SendData("$UserCommand 1 3 "..HUB.."\\Script Commands\\"..sBot.."\\Stop Script$<%[mynick]> +stopscript %[line:Filename]&#124;")
--user:SendData("$UserCommand 1 3 "..HUB.."\\Script Commands\\"..sBot.."\\Restart All Scripts$ <%[mynick]> +restartscripts&#124;")
user:SendData("$UserCommand 1 3 "..HUB.."\\Script Commands\\"..sBot.."\\Get Scripts$<%[mynick]> +getscripts&#124;")

That might be cause it didnt work b4  ??
Hello all!It was my mistake to forgot to mention, in the first(unconverted) script the"restartscripts" command was commented/stoped by me because,it disconnect me too,and i decide to use the inbuild ptx commands instead of that.
American Idiot!In the script revised by you the "delscript" command still Not working, ??? I tried to give in pm to the bot,in the main,and in the rightclicker but whitout any results ,the rest of the commands are working fine now.
« Last Edit: 31 March, 2008, 12:22:46 by rolipoli »

Offline rolipoli

  • Junior Member
  • **
  • Posts: 19
  • Karma: +0/-1
  • Transilvania-Erd?ly
Re: script manger conversion help
« Reply #5 on: 01 April, 2008, 12:13:50 »
Sure it is, use simple filename without spaces.
File extension is not required.
I'm so stupid :D because i forgot to use just the filename without extensions in command.You have perfectly right ,now the script works fine thanks to You!
Thanks again American Idiot!
rolipoli

PtokaX forum

Re: script manger conversion help
« Reply #5 on: 01 April, 2008, 12:13:50 »