Is it possible..
 

News:

29 December 2022 - PtokaX 0.5.3.0 (20th anniversary edition) released...
11 April 2017 - PtokaX 0.5.2.2 released...
8 April 2015 Anti child and anti pedo pr0n scripts are not allowed anymore on this board!
28 September 2015 - PtokaX 0.5.2.1 for Windows 10 IoT released...
3 September 2015 - PtokaX 0.5.2.1 released...
16 August 2015 - PtokaX 0.5.2.0 released...
1 August 2015 - Crowdfunding for ADC protocol support in PtokaX ended. Clearly nobody want ADC support...
30 June 2015 - PtokaX 0.5.1.0 released...
30 April 2015 Crowdfunding for ADC protocol support in PtokaX
26 April 2015 New support hub!
20 February 2015 - PtokaX 0.5.0.3 released...
13 April 2014 - PtokaX 0.5.0.2 released...
23 March 2014 - PtokaX testing version 0.5.0.1 build 454 is available.
04 March 2014 - PtokaX.org sites were temporary down because of DDOS attacks and issues with hosting service provider.

Main Menu

Is it possible..

Started by Psycho_Chihuahua, 12 April, 2006, 19:58:28

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

Psycho_Chihuahua

..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

Typhoon

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?



Psycho_Chihuahua

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

Typhoon

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?



jiten

--[[

	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

Psycho_Chihuahua

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

Psycho_Chihuahua

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

Psycho_Chihuahua

cause i would like it to show the active scripts on connection in the InfoBot  ;D
PtokaxWiki ?PtokaX Mirror + latest Libs

01100001011011000111001101101111001000000110101101101110011011110111011101101110001000000110000101110011001000000101010001101111011010110110111101101100011011110111001101101000

jiten

Quote from: Psycho_Chihuahua 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 :(

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

Best regards

SMF spam blocked by CleanTalk