Several questions...
 

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

Several questions...

Started by Psycho_Chihuahua, 25 August, 2004, 17:47:42

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

Psycho_Chihuahua

how do i make an on/off switch for certain functions?

this one for instance:
function DataArrival( user , data )
	if strsub( data , 1 , 7 ) == "$MyINFO" then
		local _,_,openhubs = strfind( data , ".+H:(%d+)" );
		if ( openhubs ~= "0" ) then
			SendToNick( user.name , DisconnectMessage )
			user:Disconnect()
		end
	end
end


Reason: I'm working on Black_Pearl 1.2 atm and i guess some (public) hubowners dont want this check to be done.

The other possibility would be to use it as an addon, hmmm dont know how to do that yet either.

Thanks for the effort ;)
PtokaxWiki ?PtokaX Mirror + latest Libs

01100001011011000111001101101111001000000110101101101110011011110111011101101110001000000110000101110011001000000101010001101111011010110110111101101100011011110111001101101000

Typhoon

tt
#1
you can do it like this ..

OpenCheck = 1  -- 1=on/0=off

function DataArrival( user , data )
      if strsub( data , 1 , 7 ) == "$MyINFO" then
         local _,_,openhubs = strfind( data , ".+H:(%d+)" );
         if OpenCheck == 1 then
            if (openhubs ~= "0") then
               SendToNick( user.name , DisconnectMessage )
               user:Disconnect()
            end
         end
      end
end

Hope it helps you to see the point ;)

Typhoon?



Psycho_Chihuahua

Thnx Typhoon


Well i got another Question:

How do i make a Bot read its variable (on/off) settings out of an *.ini file?

Settings needed are:
GuardianCheck = 1 
notifyOps = 1
banuser = 1
GuardianFile = "scripts/Data/Blocklist/guarding.p2p"
denyMsg = "*** This is a private hub. You have no business here. - Dies ist ein privater Hub. Du hast hier nichts verloren." 
banMsg = "*** Your IP has been banned. - Deine IP wurde gebannt" 
OpenCheck = 1  -- 1=on/0=off
DisconnectMessage = "Du bist in einen oder mehreren Open Hubs. Dies verst?sst gegen unsere Regeln. Deshalb wird die Verbindung zur?ckgesetzt! - You are in one or more Open Hubs which is against our Rules!! Connection Terminated..."
PtokaxWiki ?PtokaX Mirror + latest Libs

01100001011011000111001101101111001000000110101101101110011011110111011101101110001000000110000101110011001000000101010001101111011010110110111101101100011011110111001101101000

BottledHate

tt
#3
this should help....

readfrom("yourfile.bleh")
while 1 do
   local line = read()
   if (line == nil) then
      break
   else
      if strsub(line,1,9) =="Status =" then
         setting1=strsub(line,9,srlen(line))
      elseif strsub(line..........................
         setting2=strsub(line...............
      end
end
readfrom()

-BH
Homepage: www.bottledhate.webhop.org

Compiling  Lua scripts is LAME!!!!!

Psycho_Chihuahua

ok..

lets say i have a script that has this in its Settings:
SendToMain = 0  -- Send in Main [if 0 send as PM]

then how would i make a cmd Trigger to change that

like !sendmainon sets it to 1 and !setmainoff sets it to 0?


The context its used by is
   if SendToMain==0 then
	SendPmToAll(bot,tmp)
    else
	SendToAll(bot,tmp)
    end
end
PtokaxWiki ?PtokaX Mirror + latest Libs

01100001011011000111001101101111001000000110101101101110011011110111011101101110001000000110000101110011001000000101010001101111011010110110111101101100011011110111001101101000

BottledHate

Homepage: www.bottledhate.webhop.org

Compiling  Lua scripts is LAME!!!!!

sidetrack

Quote from: BottledHate on 28 September, 2004, 03:31:53
Psycho_Chihuahua:
http://board.univ-angers.fr/thread.php?threadid=2847&boardid=4&styleid=1


-BH

That board is dead again.. and I am so needing to figure out how to edit or make changes to a txt/ini file that I have been struggleing with for a long time now.. this thread looked like what I wanted to finally find out. then hit a dead link ARRRRGGGG!

plop

push all settings into a table.
opening works a bit like this.
function OpenIni()
	tSettings = {}
	for line in io.lines("settings.ini") do
		local s,e,sSet,sVar = string.find(line, "^([^=]+)=([^=]+)")
		if sSet and sVar then
			tSettings[sSet] = sVar
		end
	end
end


changing a value for a settings becomes really easy now.
tSettings[sSet] = "new value"

plop
http://www.plop.nl lua scripts/howto\'s.
http://www.thegoldenangel.net
http://www.vikingshub.com
http://www.lua.org

>>----> he who fights hatred with hatred, drives the spreading of hatred <----<<

Herodes

Wanna try a more advanced one ? :)
Not really tested .. it just my inspiration typing ..

--- can detect:
-- setting = 'value' | "value" | 0-9* | {...}
-- setting_boolean_like-constant
-- use like: tSettings = OpenIni( 'path/to/filename.ini' )

function OpenIni( file )
	t = {}
	for line in io.lines(file) do
		local s,e,sSet,sVar = string.find(line, "^%s*([^=]+)=([^=]+)%s*$")
		if sSet and sVar then
			sVar = string.gsub( sVar, "^%s*(.-)%s*$", "%1" )
			if string.sub(sVar, 1,1) == "'" or string.sub(sVar, 1,1 ) == "\"" then
				t[sSet] = sVar
			elseif string.find( sVar, "%d+" )then
				local s,e, sNum = string.find( sVar, "(%d+)" )
				t[sSet] = tonumber( sNum )
			elseif string.sub( sVar, 1,1 ) = '{' and string.sub( sVar, -1 ) == '}' then
				t[sSet] = dostring( sVal )
			elseif string.lower(sVar) == 'true' or string.lower(sVar) == 'false' then
				t[sSet] = true
			end
		else -- in this way you may do things in an other maybe more convenient way in some cases.
			s,e, sSet = string.find( line, "^%s*(%S+)%s*$" )
			if sSet then
				t[sSet] = true
			end
		end
	end
end

bastya_elvtars

The file management wikipage is being worked on...
Everything could have been anything else and it would have just as much meaning.

SMF spam blocked by CleanTalk