Posted 19 March 2013 - 04:17 PM
Ever wanted to make your own commands to use for your server? Like /gamemode and /say, but your OWN ones? Well, now you can with:
This awesome tool allows you to make your own commands run via chat like all the vanilla ones! With CC code! How awesome!? It requires Immibis Peripherals' adventure map interface and a command block set up in any fashion around a computer.
How to use:
Note: eventually you will be able to create commands within the program itself
Documentation:
Note: you do not need the name of CCCC and a '.' before function names as they are being used from inside the CCCC program.
Examples:
'Awesome' command example:
'Murder' command example:
Download:
CODE:
Use this however you like!
CCCustomCommands By Shnupbups100 (yes I know it's abbreviated CCCC)
This awesome tool allows you to make your own commands run via chat like all the vanilla ones! With CC code! How awesome!? It requires Immibis Peripherals' adventure map interface and a command block set up in any fashion around a computer.
How to use:
Spoiler
- On first use it will create the 'Commands' folder.
- CTRL-T the program.
- Make a file in the Commands folder and call it whatever you want, it doesn't need a '/'.
- If you want to know who ran the command, capture the arguments. The first argument is the person who ran the command.
- Code what you want the command to do using the Adventure map interface's API and the program's own API. (see Documentation section)
- Save, exit and run CCCustomCommands.
- When you type '/<nameOfCommand>' in the chat, it will execute the program! Hooray!
- ????
- PROFIT?!
Note: eventually you will be able to create commands within the program itself
Documentation:
Spoiler
runCmd(<cmd>,<user>)
More for internal usage, but used to run commands a user has made. <cmd> is the command name (without the '/' or the location, just the command name) and <user> is the user who ran it.
cmdBlockRun(<side>,<cmd>,[player])
Used to run vanilla commands through the command block on <side>. <cmd> is the command to use (the whole thing, e.g. "say I am awesome") and [player] is an optional argument which, when used, will replace all occurrences of '&p' in <cmd> with itself, so you can direct commands on players. e.g.
cmdBlockRun("left","tell &p &p is awesome","Shnupbups100")
would output in the chat, to only Shnupbups100,
@ whispers to you: Shnupbups100 is awesome
Note: you do not need the name of CCCC and a '.' before function names as they are being used from inside the CCCC program.
Examples:
Spoiler
TeamFortress 2 'Medic' command example:Spoiler
args = {...}
local chance = math.random(6)
if chance == 1 then
cmdBlockRun("left","say &p: Medic!",args[1])
elseif chance == 2 then
cmdBlockRun("left","say &p: MEDIC!",args[1])
elseif chance == 3 then
cmdBlockRun("left","say &p: Doctor!",args[1])
elseif chance == 4 then
cmdBlockRun("left","say &p: DOCTOR!",args[1])
elseif chance == 5 then
cmdBlockRun("left","say &p: I need a medic over here!",args[1])
elseif chance == 6 then
cmdBlockRun("left","say &p: HELP!",args[1])
end
'Awesome' command example:
Spoiler
args = {...}
cmdBlockRun("left","say &p is awesome!",args[1])
Spoiler
args = {...}
cmdBlockRun("left","tell &p Whom are we murdering, &p? (Say after a slash, like a command)",args[1])
local _,user,msg = os.pullEvent("chat_message")
if user == args[1] and string.byte(msg) == 47 then
local msg = string.gsub(msg,"/","",1)
local adv = peripheral.wrap("right")
local pl = adv.getPlayerByName(msg)
if pl ~= nil then
if pl.getGamemode() ~= 1 then
pl.damage(50)
cmdBlockRun("left","tell &p The deed is done, my lord &p.",args[1])
else
cmdBlockRun("left","tell &p The deed could not be done, for the player you wish to kill is in creative, my lord &p.",args[1])
end
else
cmdBlockRun("left","tell &p That player could not be found...",args[1])
end
else
cmdBlockRun("left","tell &p Invalid answer.",args[1])
end
Download:
Spoiler
Get it here or by typing:
pastebin get qL9Ed16V startup
I recommend you save it as startup. DO NOT SAVE IT AS 'commands'! Please read how to use and documentation before using!CODE:
Spoiler
function runCmd(cmd,user)
shell.run("commands/"..cmd,user)
end
function cmdBlockRun(side,cmd,player)
local cmdB = peripheral.wrap(side)
if player then
local cmd = string.gsub(cmd,"&p",player)
cmdB.setCommand(cmd)
else
cmdB.setCommand(cmd)
end
cmdB.runCommand()
cmdB.setCommand("")
end
if not fs.exists("commands") then
fs.makeDir("commands")
end
while true do
local _,user,cmd = os.pullEvent("chat_message")
print(user.." typed "..cmd)
if string.byte(cmd) == 47 then
local cmd = string.gsub(cmd,"/","",1)
if fs.exists("commands/"..cmd) then
print("Valid command! Running...")
runCmd(cmd,user)
else
print("Invalid command!")
end
else
print("Not a command!")
end
end
Use this however you like!