Author Topic: Is it possible..  (Read 3289 times)

0 Members and 1 Guest are viewing this topic.

Offline Psycho_Chihuahua

  • Systemspecialist IT
  • Emperor
  • **
  • Posts: 1 054
  • Karma: +112/-1
  • I am wherever i want to be
    • PtokaX Luaboard
Is it possible..
« on: 12 April, 2006, 19:58:28 »
..to read out the active scripts from the hub from within a script?
i've had a look at the Scripting-Interface.txt but can't find it in there.

If it is possible, an example would be fine as i'm trying to learn this stuff ;)
PtokaxWiki ?PtokaX Mirror + latest Libs

01100001011011000111001101101111001000000110101101101110011011110111011101101110001000000110000101110011001000000101010001101111011010110110111101101100011011110111001101101000

PtokaX forum

Is it possible..
« on: 12 April, 2006, 19:58:28 »

Offline Typhoon

  • Lord
  • ***
  • Posts: 397
  • Karma: +22/-3
  • PGE Developer
    • PGE Homepage
Re: Is it possible..
« Reply #1 on: 12 April, 2006, 20:13:25 »
you mean something like the !getscripts command in PtokaX ? ..
it can be done but the enabled/disabled status of the script don't update when you disable it in the script window.. i think it only updates on startup and shutdown.

Typhoon?



Offline Psycho_Chihuahua

  • Systemspecialist IT
  • Emperor
  • **
  • Posts: 1 054
  • Karma: +112/-1
  • I am wherever i want to be
    • PtokaX Luaboard
Re: Is it possible..
« Reply #2 on: 12 April, 2006, 20:16:24 »
yes exactly like the !getscripts command

even if it doesn't update when scripts get deactivated that wouldn't be a problem for me :) the scripts i have running are always enabled ;)
PtokaxWiki ?PtokaX Mirror + latest Libs

01100001011011000111001101101111001000000110101101101110011011110111011101101110001000000110000101110011001000000101010001101111011010110110111101101100011011110111001101101000

Offline Typhoon

  • Lord
  • ***
  • Posts: 397
  • Karma: +22/-3
  • PGE Developer
    • PGE Homepage
Re: Is it possible..
« Reply #3 on: 12 April, 2006, 20:34:54 »
great :) ..
it's acually quite simple all you need to do is read the /Cfg/Scripts.xml file ...

string.find() the script name and also the current status of it ..

then stuff the results in a table and then do a small for loop and output the data ..

let's hear the progress :)

Typhoon?



Offline jiten

  • Scripter
  • Forum Legend
  • ******
  • Posts: 1 577
  • Karma: +71/-5
Get Scripts - LUA 5.1
« Reply #4 on: 12 April, 2006, 21:45:19 »
Code: [Select]
--[[

Get Scripts 1.0 - LUA 5.1 by jiten (4/12/2006)

]]--


ChatArrival = function(user, data)
local s,e,cmd = string.find(data,"^%b<>%s+[%!%+](%S+).*|$")
if cmd then
if tCommands[string.lower(cmd)] then
cmd = string.lower(cmd)
if tCommands[cmd].tLevels[user.iProfile] then
return tCommands[cmd].tFunc(user, data), 1
else
return user:SendData(frmHub:GetHubBotName(),"*** Error: You are not allowed to use this command!"), 1
end
end
end
end

tCommands = {
showscripts = {
tFunc = function(user)
local sMsg, sTmp = nil, ""
local f = io.open(frmHub:GetPtokaXLocation().."\\cfg\\Scripts.xml")
if f then sMsg = f:read("*all"); f:close(); end
if sMsg then
sMsg = string.gsub(sMsg,string.char(13,10),"");
local tTable = { [0] = "Disabled", [1] = "Enabled" }
for sScript,iStatus in string.gmatch(sMsg,"<Name>(.-)</Name>%s+<Enabled>(.-)</Enabled>") do
sTmp = sTmp.."\t* "..tTable[tonumber(iStatus)].." *\t\t"..sScript.."\r\n"
end
end
user:SendData(frmHub:GetHubBotName(),"\r\n\r\n\t"..string.rep("=",80).."\r\n\tStatus:\t\t\tScript:\r\n\t"..
string.rep("-",160).."\r\n"..sTmp)
end,
tLevels = {
[0] = 1, [1] = 1, [4] = 1, [5] = 1,
},
tRC = "Get Scripts$<%[mynick]> !{}"
},
}

NewUserConnected = function(user)
for i,v in pairs(tCommands) do
local sRC = string.gsub(v.tRC,"{}",i)
user:SendData("$UserCommand 1 3 "..sRC.."&#124;")
end
end

OpConnected = NewUserConnected

Offline Psycho_Chihuahua

  • Systemspecialist IT
  • Emperor
  • **
  • Posts: 1 054
  • Karma: +112/-1
  • I am wherever i want to be
    • PtokaX Luaboard
Re: Is it possible..
« Reply #5 on: 12 April, 2006, 22:17:51 »
nice one jiten - is it possible to do it in Lua 5.02? Sorry but i posted this in the wrong Section by mistake :(
PtokaxWiki ?PtokaX Mirror + latest Libs

01100001011011000111001101101111001000000110101101101110011011110111011101101110001000000110000101110011001000000101010001101111011010110110111101101100011011110111001101101000

Offline Psycho_Chihuahua

  • Systemspecialist IT
  • Emperor
  • **
  • Posts: 1 054
  • Karma: +112/-1
  • I am wherever i want to be
    • PtokaX Luaboard
Re: Is it possible..
« Reply #6 on: 12 April, 2006, 22:24:04 »
i know that Mutor - i want to build it into your InfoBot script to show the active scripts on hub connection
well at least thats what i'm trying to do
PtokaxWiki ?PtokaX Mirror + latest Libs

01100001011011000111001101101111001000000110101101101110011011110111011101101110001000000110000101110011001000000101010001101111011010110110111101101100011011110111001101101000

Offline Psycho_Chihuahua

  • Systemspecialist IT
  • Emperor
  • **
  • Posts: 1 054
  • Karma: +112/-1
  • I am wherever i want to be
    • PtokaX Luaboard
Re: Is it possible..
« Reply #7 on: 12 April, 2006, 22:37:24 »
cause i would like it to show the active scripts on connection in the InfoBot  ;D
PtokaxWiki ?PtokaX Mirror + latest Libs

01100001011011000111001101101111001000000110101101101110011011110111011101101110001000000110000101110011001000000101010001101111011010110110111101101100011011110111001101101000

Offline jiten

  • Scripter
  • Forum Legend
  • ******
  • Posts: 1 577
  • Karma: +71/-5
Re: Is it possible..
« Reply #8 on: 13 April, 2006, 07:02:01 »
nice one jiten - is it possible to do it in Lua 5.02? Sorry but i posted this in the wrong Section by mistake :(

Yes, it's possible. For the LUA 5.0.2 version, you just need to replace string.gmatch with string.gfind

Best regards

PtokaX forum

Re: Is it possible..
« Reply #8 on: 13 April, 2006, 07:02:01 »