TriggerBoy Script
Moderator: Moderators
-
bugayev
- Posts: 9
- Joined: 2005-01-05 05:02
TriggerBoy Script
Ok. I have my hub up and running (thanks again to everyone who helped with that) and I've installed the TriggerBoy script.
However, I want to edit it slightly so that it will trigger when i type, say -punch hub --> then displaying "bugayev punches hub".
I can get it to do this quite easily - I just added a new variable called [parm] which subsitutes everything EXCEPT the trigger word.
This is great.
BUT
How can I tell the script to only trigger if -punch appears at the start of a line:
so it works for "-punch hub"
but not for "to punch, type -punch followed by the name of the thing you want to hit."
(at the moment, it says "bugayev punches followed by the name of the thing you want to hit")
Can anyone shed any light on how I can do this?
However, I want to edit it slightly so that it will trigger when i type, say -punch hub --> then displaying "bugayev punches hub".
I can get it to do this quite easily - I just added a new variable called [parm] which subsitutes everything EXCEPT the trigger word.
This is great.
BUT
How can I tell the script to only trigger if -punch appears at the start of a line:
so it works for "-punch hub"
but not for "to punch, type -punch followed by the name of the thing you want to hit."
(at the moment, it says "bugayev punches followed by the name of the thing you want to hit")
Can anyone shed any light on how I can do this?
-
shufty
- Posts: 11
- Joined: 2004-01-30 08:08
Code: Select all
local punch = string.sub( msg, 1, 10 )
if punch == "-punch hub" then
dchpp.sendToAll( "* "..client:getNick().." punches hub|" )
return dchpp.ACTION_STOP
end-
bugayev
- Posts: 9
- Joined: 2005-01-05 05:02
sorry, i completely forgot!
It's not the most efficient way of doing it, obviously. The script DOES work when i comment out everything after the /me, but doesnt work for any of the other conditions. I've tried it with /me commented out and other stuff active, but that doesn't work. I'm completely stumped.
Code: Select all
--Action script by Ben Carmichael
--Taken from the /me script by Sedulus
dchpp.loadLib( "math" )
function dchpp.clientMessage( client, msg )
local user = client:getNick()
local cmd = nil
local parm = nil
--substitutes for 3 letter commands
local cmd = string.sub( msg, 1, 4 )
if cmd == "+me " or cmd == "/me " then
dchpp.sendToAll( "* "..user.." "..string.sub( msg, 5 ).."|" )
return dchpp.ACTION_STOP
end
--substitutes for 4 letter commands
cmd = string.sub( msg, 1, 5 )
parm = string.sub( msg, 5 )
local answer
local action
if cmd == "-slap " or cmd == "+slap " then
local numberOfOptions = 3
action = {
[1] answer = user.." slaps "..parm,
[2] answer = user.." hits "..parm.." in the face with a rotting fish!",
[3] answer = user.." spanks "..parm.."!",
}
local p = math.random(numberOfOptions)
action[p]
answer = user.." slaps "..parm
dchpp.sendToAll( "* "..user.." slaps "..parm.."|" )
return dchpp.ACTION_STOP
end
if cmd == "-nuke " or cmd == "+nuke " then
local numberOfOptions = 2
action = {
[1] answer = user.." authorises a nuclear strike against "..parm.." and launches missiles!",
[2] answer = "Forces under the control of "..user.." find "..parm.." and carry out a deadly nuclear strike!",
}
local p = math.random(numberOfOptions)
action[p]
end
--substitutes for 5 letter commands
cmd = string.sub( msg, 1, 6 )
parm = string.sub( msg, 6 )
if cmd == "-punch " or cmd == "+punch " then
local numberOfOptions = 2
action = {
[1] answer = user.." punches "..parm.." in the nose!",
[2] answer = user.." punches "..parm.."!",
}
local p = math.random(numberOfOptions)
action[p]
end
dchpp.sendToAll( "* "..answer.."|" )
return dchpp.ACTION_STOP
endIt's not the most efficient way of doing it, obviously. The script DOES work when i comment out everything after the /me, but doesnt work for any of the other conditions. I've tried it with /me commented out and other stuff active, but that doesn't work. I'm completely stumped.
-
PseudonympH
- Forum Moderator
- Posts: 366
- Joined: 2004-03-06 07:46
Code: Select all
if cmd == "-slap " or cmd == "+slap " then
local numberOfOptions = 3
action = {
[1] answer = user.." slaps "..parm,
[2] answer = user.." hits "..parm.." in the face with a rotting fish!",
[3] answer = user.." spanks "..parm.."!",
}
local p = math.random(numberOfOptions)
action[p]
answer = user.." slaps "..parm
dchpp.sendToAll( "* "..user.." slaps "..parm.."|" )
return dchpp.ACTION_STOP
end
I don't know what you're trying to do here, but that sure as hell looks like incorrect lua code to me. Try this:
Code: Select all
if cmd == "-slap " or cmd == "+slap " then
local action = {
user.." slaps "..parm,
user.." hits "..parm.." in the face with a rotting fish!",
user.." spanks "..parm.."!",
}
local p = math.random( table.getn(action) )
dchpp.sendToAll( "* "..action[p].."|" )
return dchpp.ACTION_STOP
end
You'll need to make the rest look like this code as well, of course.
-
yakko
- Posts: 258
- Joined: 2003-01-27 06:04
the /me script appends what the user adds so would say
You don't need to add a bunch of stuff then...let the users get creative with it themselves.
Code: Select all
/me slaps everyone in the hubCode: Select all
*yakko slaps everyone in the hubYou don't need to add a bunch of stuff then...let the users get creative with it themselves.
-
bugayev
- Posts: 9
- Joined: 2005-01-05 05:02
Well, I tried substituting PseudoNymph's LUA for my own and there's still nothing. i even went so far as to put it into a new script, but nothing happened.
Is there some kind of restriction on the use of SendToAll which could be stopping the message from being sent?
Am I missing some critical piece of code?
This is really starting to frustrate me.
Yakko - my users do use /me for a lot of the stuff they do to each other! Its a great script, I just want to provide a few shortcuts and fun ones for them to have without having to type the full sentence. I managed to get it working under SDCH, but that was vbscript and I have to say I'm a lot better at that than LUA!
Is there some kind of restriction on the use of SendToAll which could be stopping the message from being sent?
Am I missing some critical piece of code?
This is really starting to frustrate me.
Yakko - my users do use /me for a lot of the stuff they do to each other! Its a great script, I just want to provide a few shortcuts and fun ones for them to have without having to type the full sentence. I managed to get it working under SDCH, but that was vbscript and I have to say I'm a lot better at that than LUA!
-
FleetCmd
- Posts: 22
- Joined: 2003-05-20 17:19
- Location: Hungary
cmd = string.sub( msg, 1, 5 )
parm = string.sub( msg, 5 )
local answer
local action
if cmd == "-slap " or cmd == "+slap " then
Your substring is only five characters long (string.sub: 1, 5), but in the if-then-condition, the "-slap " is 6... You should modify the cmd = ... lines to add one more character because of the spaces.
-
Sedulus
- Forum Moderator
- Posts: 687
- Joined: 2003-01-04 14:32
Code: Select all
-- vim:ts=4:sw=4:noet
dchpp.loadLib( "math" )
local function oneOf( tbl ) return tbl[math.random( table.getn( tbl ) )] end
local Actions = {
["+me"] = function( nick, arg )
return "* " .. nick .. " " .. arg
end,
["/me"] = function( nick, arg )
return "* " .. nick .. " " .. arg
end,
["+slap"] = function( nick, arg )
return oneOf( {
"* " .. nick .. " slaps " .. arg,
"* " .. nick .. " hits " .. arg .. " in the face with a rotten fish",
"* " .. nick .. " spanks " .. arg,
} )
end,
}
function dchpp.clientMessage( client, msg )
local ret,_,cmd,arg = string.find( msg, "^(%S+)%s+(.*)$" )
if not ret then
return
end
if Actions[cmd] then
dchpp.sendToAll( Actions[cmd]( client:getNick(), arg ) .. "|" )
return dchpp.ACTION_STOP
end
endhttp://dc.selwerd.nl/hublist.xml.bz2
http://www.b.ali.btinternet.co.uk/DCPlusPlus/index.html (TheParanoidOne's DC++ Guide)
http://www.dslreports.com/faq/dc (BSOD2600's Direct Connect FAQ)
http://www.b.ali.btinternet.co.uk/DCPlusPlus/index.html (TheParanoidOne's DC++ Guide)
http://www.dslreports.com/faq/dc (BSOD2600's Direct Connect FAQ)
Who is online
Users browsing this forum: Google [Bot] and 0 guests