Help with optimus's simple release scrip.
 

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

Help with optimus's simple release scrip.

Started by Envinyatar, 08 April, 2007, 02:22:32

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

Envinyatar

I guess you see that Ive modded this script (poorly).
Ive made it write 2 txtfiles, one is working with the script, and the one called release1.txt is used with "Rotating Message 1.1 by jiten for PtokaX 0.3.3.0 build 17.02 or Higher".
The reason why I have it write 2 txt files is so that I can go in release1.txt and remove old entries, so that the mainchatmsg wont totally flood my mainchat.
What I ask is: can someone help me fix a "cleaner" or something for this script, so that release.txt shows ALL releases and release1.txt only shows the last 10/15 or 20 releases?
I should also mention that I got some infotxt in the beginning of the release1.txt file, so that the script starts writing from line 5 in the release1.txt file.

-- Verry simple release script nothing fancy
-- Make a file called releases.txt in \Scripts Folder
-- Made By Optimus
-- Converted the script into LUA 5 by 6Marilyn6Manson6
-- Filehandling problem fixed by Madman
-- Requested by Shalla
-- Fixed so anyone can use !write not just vips and above

sBot = frmHub:GetHubBotName()

timedate = os.date()
file = "releases.txt" 
file1 = "releases1.txt"

display1 = "? Release"
display2 = "Genre"
display3 = "Releases"

function Main()
	frmHub:RegBot(sBot)
end

function ChatArrival(user, data)
	if (string.sub(data, 1, 1) == "<" ) then
		data=string.sub(data,1,string.len(data)-1) 
		s,e,cmd=string.find(data, "%b<>%s+(%S+)")

		if (cmd=="!read") then
			ReadRelease(user, data, cmd)
			return 1

		elseif (cmd=="!add") then
			local s,e,cmd,release,desc = string.find( data, "%b<>%s+(%S+)%s+(%S+)%s+(.+)" )

			if desc == nil then
				description = "No "..display2.." specified!"
				local s,e,cmd,release = string.find( data, "%b<>%s+(%S+)%s+(%S+)" )
			else
				description = desc
			end
			if release == nil then
				user:SendData(sBot, "*** No "..display1.." specified!")
				return 1
			end

			News(""..display1..": "..release.."\r\n" ..display2..": "..description.."\t By: "..user.sName.."\t Date: "..timedate.."")
			SendToAll(sBot, "A New "..display3.." Is Added By <"..user.sName.."> Type !read in mainchat to read!")
			return 1
		end
	end
end

function ReadRelease(user, data, cmd)
	local release = ""
--		readfrom(file)
	local file = io.input(file);
	while 1 do
	local line = io.read()
		if (line == nil) then 
		break
	else
		release = release.."	"..line.."\r\n"
		end
	end
		user:SendPM(sBot, "\r\n\r\n".."       "..display3.."s posted by users: ".."\r\n\r\n"..release)
--	readfrom()
	file:read()
end

function News(what)
-- 	appendto(file) 
-- 		write(what.."\n")
-- 	writeto()
	local file = io.open(file, "a+") -- "a+"
	file:write(what.."\n")
	file:close()
end

function News(what)
-- 	appendto(file1) 
-- 		write(what.."\n")
-- 	writeto()
	local file = io.open(file1, "a+") -- "a+"
	file:write(what.."\n")
	file:close()

end
"What is piracy? Piracy is the act of stealing an artist's work without any intention of paying for it. I'm not talking about Napster-type software. I'm talking about major label recording contracts." [Courtney Love]

SMF spam blocked by CleanTalk