DiXBoT - "HowTo" create your own Modules.
 

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

DiXBoT - "HowTo" create your own Modules.

Started by Snooze, 26 January, 2007, 13:31:01

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

Snooze

I've added support for anyone writing/adding modules to DiXBoT and having them  loaded 'almost' on-the-fly (require a cmd to check for new modules <g>).

This will be available from the next major update comming in the very near future..

I've make the first draft on a 'HowTo' including a sample "hello world" script, script template and API instructions and will post it this weekend after a quick review from a few scripters <g>

This is just a heads-up post :)

-Snooze

smeg568

Thanks for the advance warning Snooze.

Any ETA on the revised version?

Snooze

Both yes and no..

I made a poll on www.dixbot.com on what should be the next major update.. It's currently a tie so gonna do them all lol

I've had a few scripters from this forum checking the HowTo script ive made and most have "signed off" on it.. So I'll finish that this weekend and could have a small version of DiXBoT ready for those of you who wanna make your own Modules..

If you wanna get a preview you could contact me in the Demo Hub ..


-Snooze


Snooze

This is a first draft of the HowTo file.. API section is missing more than a few entry's but it should give you a good idea of what it would look like..

Please let me know if this is easy enough to follow .. well.. any feedback will be appreciated :-)

--[[

	=============================================
	README before starting your code!!
	=============================================


	DiXBoT API
	---------------------

	Seconds --> DD, HH, MM, SS
		doTimeCal(time_in_sec, short/long) -- two modes. nil will return long
	
	k --> kb, mb, gb, tb
		doShareCal(k, dec) -- k = share in b - dec = amount of decimals (If dec = nil then dec = 2)

	Args:
		doArg1(data) -> arg
		doArg2(data) -> arg, arg2
		doArg3(data) -> arg, arg2, arg3
		doArg4(data) -> arg, arg2, arg3, arg4
		-- all args return nil if either of them is nil

	DiXBoT Global Config:
	----------------------

	tCoreConfig <-- Holds the settings
		.System <-- Holds Basic system settings

			.Bot <-- Main Bot Name -  (!botname [ NewName ]) - require reloading functions by calling Main()
			.Prefix = {} <-- table of cmd prefix's
			.HubMail <-- Contact Mail Addy (!mail [ NewMailAddy ])
			.Web <-- Hub Website (!website [ NewAddy ])

		.Modules = {} <-- Tables of Modules (set to true/false)
				  Changing a Module's Status require reloading functions by calling Main()

	Ex: Calling tCoreConfig.System.Bot will return the MainBot Name.

	New Settings can be addy as you please - Just note that these settings migt be overwritten by updates if there's changes to table structure 

	

	Language File Creation
	----------------------
	I will do a 2nd Demo Script on howto add Language File Support to a Module.
	It's really fairly simple and easy to do, but all in due time :)

	General Notes:
	----------------------
	There will be added a section on my website where you can upload your Modules.. 

	Website: www.dixbot.com

	Support:
		You can contact me here:

		Lua Language Board - http://forum.ptokax.org/
		DiXBoT Website - www.dixbot.com
		DixBoT Demo Hub - demo.dixbot.com:1209
		

	All suggestions will be highly appreciated :)

]]
--====================================================================================================
-- [   Code Example with comments :: Play around with it ;-)   ] --
--====================================================================================================


HelloWorld = { -- Name of Script - the filename of the script MUST be the same - ex: HelloWorld.lua

	-- All PtokaX Functions can be called as shown in the NewUserConnected example. PtokaX Functions can be found in the Scripting-Interface.txt that comes with PtokaX.

	["NewUserConnected"] = { -- You should know this one ;-)

		doHelloWorld1 = function(user,data) -- Example function

			user:SendData(tCoreConfig.System.Bot, "Hello World, "..user.sName) -- Note, This is using the default Bot Name!

		end,

	},

	["OpConnected"] = {

		doHelloWorld2 = function(user,data) -- Example function

			user:SendData(tCoreConfig.System.Bot, "Hello World, "..user.sName) -- Note, This is using the default Bot Name!

		end,

	},

	-- All non PtokaX Functions lives in "Func"
	["Func"] = {

		doStuff = function(user,data)
			SendToAll(tCoreConfig.System.Bot, "Doing Timed Stuff..")
		end,

		doMoreStuff = function(user,data)
			doReturn = "Stuff Done :-)" -- 'doReturn' will return to same place as cmd is run(main/PM) + allows for calling language files (inludes return 1 to stop cmds from showing in main)
		end,

		doMoreStuff2 = function(user,data)
			doArg1(data)
			if arg == nil then
				doReturn = "Error! - Type !stuff2 [ Blah ]."
			elseif string.lower(arg) == "blah" then
				doReturn = "Ok ok .. Your Share is [ "..doShareCal(user.iShareSize, 5).." ]."
			else
				doReturn = "Error! - Type !stuff2 [ Blah ]."
			end
		end,

	},

	["Timers"] = { -- minimum timer interval is 1 sec!

		["doStuff"] = {20,0,"Do Stuff Timer",},

		--Syntax is ["Function Name"] = {time_to_exe_in_sec, start_time_on_first_run, "Description",},
		--Timers can be viewed by typing !timers

	},

	--NOTE: CMD and Rightclick is in the proccess of being Merged to allow for easy translation and Cmd Profile Changes

	["CMD"] = {

		["doMoreStuff"] = {"stuff",-1,"Calling the doMoreStuff function",},
		["doMoreStuff2"] = {"stuff2",-1,"Calling the doMoreStuff2 function",},
		--Syntax is ["Function Name"] = {"command", min_profile,"Description",}, (Note: description is also used for !help)

	},

	["Rightclick"] = {
		["Stuff Cmd"] = { --Rightclick Title

			[1] = {"$UserCommand 1 3  ? Stuff\\ Do Stuff$<%[mynick]> !stuff&#124;",-1,},
			[2] = {"$UserCommand 1 3  ? Stuff\\ Do Stuff2$<%[mynick]> !stuff2&#124;",-1,},
			--Syntax is [Table index] = {"raw_rightclick",min_profile,}, - min_profile should match that of the CMD min_profile!
		},
	},

	["Asserts"] = {
		-- Load Extra files into DiXBoT.		
		--[1] = "DiXBoT/CoreSystem/FolderName/Filename.lua",
		--[2] = "DiXBoT/CoreSystem/FolderName/Filename2.lua",
	},

}

DxbModule = HelloWorld -- Used to load functions into DiXBoT. MUST be the name of script AND the same as the filename without ext.
		       -- This line MUST be placed last in the script!



Some needed Updates will be added to this (CMD and Rightclick will be merged before a final version will be published)

Let me know if this structure is good enough :)

-Snooze

SMF spam blocked by CleanTalk