Functions
 

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

Functions

Started by ??????Hawk??????, 03 November, 2003, 01:21:24

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

??????Hawk??????

Heya peeps  im quite new to Lua and was wandering if there is a list/collection of functions.

If not  then maby ppl could start sharing their functions in this thread...


BlazeXxX

hmm i think it can be found in LUA guide... it was somewhere in forum... chek  the Useful links section..

??????Hawk??????

cant seem to find anything    :(

maby im missing it..

if anyone comes across any links to or lists of functions could you please post it in here and ill check back tommorow.


Many Thanks

nErBoS

Great to see you here .)

This is a great manual for LUA-coding

http://www.lua.org/manual/4.0/manual.html#pm

To scritp see the section How To Do.

Best regards, nErBoS
--## nErBoS Spot ##--

??????Hawk??????

Thanks for that link m8

Im hoping in time i will be able to put some constructive input in to this forum but for now im a noob ( to lua anyway ) striving to take in as much as i can.

I guess im going to be living here for a good while now.   :)

so the search goes on............

c'mon all you Great script writers share your knowlage and zip your functions up and post them here  and give us noobs a kick start in understanding Lua in ptokax.

 :)       :)        :)         :)        :)

??????Hawk??????

:(    :(           :(             :(         :(

well i guess ive gotta learn the hard way as i did with VB

thx to the 2 that did respond   :)

Skrollster

What sort of functions are you looking for?

i have a whole archive with functions...and a head full with knowleage about lua

i'm not too active right now though since i'm waiting for my new mother board to come so I can start using my own computer again..

but if you are looking for something please ask here!!

cheers mate

Skrollster

here comes some good functions and a good structure:

function DataArrival(tUser, sData)
	if (strsub(sData, 1, 1) == "<" ) then
		-- create a table
		local tArgs = {}
		-- Save sData in an array
		tArgs = tHelpFunctions:GetArgs(sData)
		-- Check if the user has used any of the hubprefixes
		tArgs = tHelpFunctions:CheckIfHasPrefix(tArgs)
		-- add sData as a variable to tArgs
		tArgs.sData = sData
		if tArgs.sPrefix then
			tUser.SendMessage = tUser.SendData
			local returnvalue = call(UserCommands[tArgs.sCmd],{UserCommands,tUser,tArgs}, "x", nil)
			if returnvalue then
				return returnvalue
			else
				return 0
			end
		else -- messages that isn't commands ends up here
		end
	end
end
tSettings = {
	tCmdPrefixes = {"!","+","gs:","?","#","?"},
}

tHelpFunctions = {
	CheckIfHasPrefix = function(self,tArgs)
			sToCheck = tArgs.sCmd
			local i
			local err
			for i = 1, getn(tSettings.tCmdPrefixes) do
				if strsub(sToCheck, 1, strlen(tSettings.tCmdPrefixes[i])) == tSettings.tCmdPrefixes[i] then
					tArgs.sCmd = strsub(sToCheck, strlen(tSettings.tCmdPrefixes[i])+1, strlen(sToCheck))
					tArgs.sPrefix = tSettings.tCmdPrefixes[i]
					break
				end
			end
			return tArgs
		end,
	GetArgs = function(self,sData)
			local tArgs = {}
			_,_,sData = strfind(sData, "%b<>%s+(.+)|")
			tArgs.sMessage = sData
			sData = strlower(sData)
			gsub(sData, "(%S+)", function (w) tinsert(%tArgs,w) end)
			tArgs.sCmd = tArgs[1]
			tremove(tArgs, 1)
			return tArgs
		end,
}

UserCommands = {
			help = function(self, tUser, tArgs)-- for all users
					-- Do your own help function here :)
					return 1
				end,
		}

??????Hawk??????

Thx for the reply m8...

im just looking for a whole collection of  functions  to get me  started  in understanding   how   LUA  works  in relation to VB   then  maby  ill get to grips with it.  :-)

pHaTTy

start here

then move to lesson 2 then 3 etc etc
Resistance is futile!

??????Hawk??????

thx m8   i read them  when i joined  but they dont tell me what im really wanting to know


EG:-

data=strsub(data,1,strlen(data)-1)
s,e,cmd = strfind(data,"%b<>%s+(%S+)") -- this converts it into cmd (the incoming data)

how does it do it.  what does

s=
e=

if i wanted to brake data sent to the hub bot down  what functions do i use to split this:-

$To: HubBot From: User $ +command theText

bot=HubBot
user=User
CmdPrf=+
command=command
text=theText



And the same for main chat...... ????



is there and  texts that will help  understand Lua In ptokaks hub software ??

tezlo

#11
yes.. the manual

strfind (s, pattern [, init [, plain]])
Looks for the first match of pattern in s. If it finds one, then strfind returns the indices of s where this occurrence starts and ends; otherwise, it returns nil. If the pattern specifies captures (see gsub below), the captured strings are returned as extra results. A third, optional numerical argument init specifies where to start the search; its default value is 1, and may be negative. A value of 1 as a fourth, optional argument plain turns off the pattern matching facilities, so the function does a plain ``find substring'' operation, with no characters in pattern being considered ``magic''. Note that if plain is given, then init must be given too.


so.. theres no need to remove the end pipe as you can put it in the regexp too
"this converts it into cmd" nothing gets converted. it just tries to extract the first word

you either want to use a bunch of strsubs and plain strfinds like in VB
or one strfind and a proper regexp.. ie

$To: HubBot From: User $ +command theText
local s, e, to, cmd, args = strfind(data, "^$To: (%S+) From: %S+ $%b<> %+(%a+)%s*(.*)%|$")

SMF spam blocked by CleanTalk