Devtools-r0.1 
25 comments Devtools-r0.1 for CS2D
Note that this package is an early release and may not be fully stable. If you find any bugs, please either report them or submit a patch.
Lua Features: – Skip this part for now and go down to the next section.
string.lua:
Various string functions that can be accessed via str:func(...) including :split([delimiter]), :qsplit([delimiter]), :join(table), etc
Also added the syntactical sugar “%s”%object → string.format(“%s”,object)
table.lua:
Various table functions
struct.lua:
Allows manipulation of binary data structures
pickle.lua:
Fast serialization of lua objects via
The lua objects are serialized in pure lua code, so they will be easily modifiable both manually and pragmatically.
import.lua:
Allows conflict free imports of lua modules
The above code will only execute libname once.
The following syntax is allowed for both relative and absolute imports
import “name.space.module” -- “name/space/module.lua”
You may also add in more import paths by appending them into the importpaths table:
CS2D Features:
menu.lua:
Easy to use menus. You can now construct dynamic menu by using the Menu(title, item1, item2, …) constructor. See following for examples.
help.lua:
Automatically generate nice looking documentation and references for say commands
You can use !help in game to bring up a list of used commands.
You can also register command documentation via help.register{command = “text”}
Alternatively, a very powerful mechanism in devtools allows the developer to embed these documentations in their code by directly assigning the doctext to the __help__ variable, as illustrated:
Will generate
> !help test
Command 'test':
- Desc:
… Dummy command that displays “TEST”
- Usage:
… !test
cmds.lua:
Easy to use say commands with a powerful backend.
Devtools.cmds can automatically parse an argument based on the parameters of a function.
For example:
will create a command that will behave as follows:
> !msg hello
hello
> !msg
Insufficient number of parameters for the command 'msg'
Need 1 arguments: !msg <text>
Certain parameters are automatically built:
id: the id of the player who called the command – Does not count towards the number of required arguments
text: the entire string of text – Does count towards the required arguments, but do not actually take any position
this: metadata containing the command rank and other information from the command preprocessor.
…: all of the other unused arguments
Thus, the following rewrite of !msg:
will create a command that will behave as follows:
> !msg
Insufficient number of parameters for the command 'msg'
Need 2+ arguments: !msg <tag, text, [...]>
> !msg tag tag
tag
tag tag
Residual
>!msg tag text …
tag
tag text …
Residual
…
auth.lua:
Implements a smart users system for cs2d developers that extends the cmds module
will create the commands @sayhi and @say that will behave as follow:
> @sayhi asdf
lee says HI 'asdf'
>@say Am I an admin?
You do not have sufficient privilege to use the command 'say'
You need a rank of 'admin', you are currently 'user'
Included commands:
!help [<cmd>] – Displays the help menu. You can also use !help <cmd> to directly go to the cmd
!see <cmd> - Displays the parameter information for the given command
!login <username> <password>
!register <username> <password>
!logout
@usgn – Resets your USGN information
@username <username> - Lets you change your username
@password <password> - Lets you change your password
@who [<id>] - Lets you see the username of player @ id
@auth <username> <rank> [<rank2> […]] - Adds the listed ranks/privileges to username's account
@auth reset <rank> … - Resets username's ranks to the listed ranks.
This documentation will be subjected to modification in the future as I see fit. Currently, this is merely a preliminary outline of the devtool.
Note that this package is an early release and may not be fully stable. If you find any bugs, please either report them or submit a patch.


Various string functions that can be accessed via str:func(...) including :split([delimiter]), :qsplit([delimiter]), :join(table), etc
Also added the syntactical sugar “%s”%object → string.format(“%s”,object)

Various table functions

Allows manipulation of binary data structures

Fast serialization of lua objects via
Code:
1
2
3
4
2
3
4
import “pickle”
pickle.dump(object, filename)
– ETC CODE
object = pickle.load(filename)
pickle.dump(object, filename)
– ETC CODE
object = pickle.load(filename)
The lua objects are serialized in pure lua code, so they will be easily modifiable both manually and pragmatically.

Allows conflict free imports of lua modules
Code:
1
2
3
2
3
dofile “sys/lua/devtools/import.lua”
import “libname”
import “libname”
import “libname”
import “libname”
The above code will only execute libname once.
The following syntax is allowed for both relative and absolute imports
import “name.space.module” -- “name/space/module.lua”
You may also add in more import paths by appending them into the importpaths table:
Code:
1
table.insert(importpaths, “newpath”)


Easy to use menus. You can now construct dynamic menu by using the Menu(title, item1, item2, …) constructor. See following for examples.
Code:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
classes = Menu(“Choose your class”, “Police”, “Citizen”, “Superman”, “Batman”, “Other superheroes”, …)
classes(id) – Automatically shows the menu to player id
classes.add(“another hero”, “YAH”, “more heroes”, “blargh”, “blargh”) -- Add even more heroes
-- Note that menus with more than 9 items will automatically paginate themselves
function classes.hooks.Police(id) -- Police
msg2(id, “You're a Police”)
end
function classes.hooks.blargh(id) -- Any blargh
msg2(id, “You're a blargh”)
end
function classes.hooks.blargh_2(id) -- Second blargh
msg2(id, “You're the second blargh”)
end
function classes.hooks._(id, sel, menu) -- Anyone
msg2(id, “Thanks for playing”)
end
classes(id) – Automatically shows the menu to player id
classes.add(“another hero”, “YAH”, “more heroes”, “blargh”, “blargh”) -- Add even more heroes
-- Note that menus with more than 9 items will automatically paginate themselves
function classes.hooks.Police(id) -- Police
msg2(id, “You're a Police”)
end
function classes.hooks.blargh(id) -- Any blargh
msg2(id, “You're a blargh”)
end
function classes.hooks.blargh_2(id) -- Second blargh
msg2(id, “You're the second blargh”)
end
function classes.hooks._(id, sel, menu) -- Anyone
msg2(id, “Thanks for playing”)
end

Automatically generate nice looking documentation and references for say commands
You can use !help in game to bring up a list of used commands.
You can also register command documentation via help.register{command = “text”}
Alternatively, a very powerful mechanism in devtools allows the developer to embed these documentations in their code by directly assigning the doctext to the __help__ variable, as illustrated:
Code:
1
2
3
4
5
6
7
8
9
10
2
3
4
5
6
7
8
9
10
function act.test(id)
__help__ =
[[
- Desc:
... Dummy command that displays “TEST”
-Usage:
... !test
]]
msg2(id, "TEST")
end
__help__ =
[[
- Desc:
... Dummy command that displays “TEST”
-Usage:
... !test
]]
msg2(id, "TEST")
end
Will generate
> !help test
Command 'test':
- Desc:
… Dummy command that displays “TEST”
- Usage:
… !test

Easy to use say commands with a powerful backend.
Devtools.cmds can automatically parse an argument based on the parameters of a function.
For example:
Code:
1
2
3
2
3
function act.msg(text)
msg(text)
end
msg(text)
end
will create a command that will behave as follows:
> !msg hello

hello

> !msg
Insufficient number of parameters for the command 'msg'
Need 1 arguments: !msg <text>
Certain parameters are automatically built:




Thus, the following rewrite of !msg:
Code:
1
2
3
4
2
3
4
function act.msg(id, tag, text, …)
msg(tag..text)
msg(“Residual”,...)
end
msg(tag..text)
msg(“Residual”,...)
end
will create a command that will behave as follows:
> !msg
Insufficient number of parameters for the command 'msg'
Need 2+ arguments: !msg <tag, text, [...]>
> !msg tag tag
tag
tag tag
Residual
>!msg tag text …
tag
tag text …
Residual
…

Implements a smart users system for cs2d developers that extends the cmds module
Code:
1
2
3
4
5
6
7
2
3
4
5
6
7
function adm.sayhi(this, text)
msg(“%s says HI '%s'”%{this.user.username, text})
end
function adm.say.admin(this, text)
msg(“%s <admin>: %s”%{this.user.username, text})
end
msg(“%s says HI '%s'”%{this.user.username, text})
end
function adm.say.admin(this, text)
msg(“%s <admin>: %s”%{this.user.username, text})
end
will create the commands @sayhi and @say that will behave as follow:
> @sayhi asdf
lee says HI 'asdf'
>@say Am I an admin?
You do not have sufficient privilege to use the command 'say'
You need a rank of 'admin', you are currently 'user'












This documentation will be subjected to modification in the future as I see fit. Currently, this is merely a preliminary outline of the devtool.

Comments
25 commentsLog in!
You need to log in to be able to write comments!Log in
@
StrikerD2000: But... you forgot to press a special button..


08.09.11 01:13:00 pm

This Lua Awesome But
How I Make My Self Or Othere Player Admin Or SDM
How I Make My Self Or Othere Player Admin Or SDM

This is to help create your own admin type script, he included some examples. If you want this type of system just get AMX2D it's similar to this...I think

Nice and perfect lua script, Lee
Lee, can you make Devtools-r0.1 (Auth Only) I mean the /login /logout /register commands
Lee, can you make Devtools-r0.1 (Auth Only) I mean the /login /logout /register commands
edited 1×, last 22.07.11 11:42:27 am