PtokaX forum

PtokaX => Feature Proposals => Topic started by: Herodes on 24 September, 2006, 12:40:10

Title: lesser the 'return 1' feature ;)
Post by: Herodes on 24 September, 2006, 12:40:10
Can we have the following API calls return 1 pls ?

SendToAll(FromNick, Data)
SendToAll(Data)
SendPmToAll(FromNick, Data)
SendToNick(Nick, Data)
SendPmToNick(ToNick, FromNick, Data)
SendToOps(FromNick, Data)
SendToOps(Data)
SendPmToOps(FromNick, Data)
userObj:SendData(FromNick, Data)
userObj:SendPM(FromNick, Data)

so that we get less of
user:SendData( "bot", "look you I don't send what you sent me!!" )
return 1

and more of
return user:SendData( "bot", "look you I don't send what you sent me!!" )
Title: Re: lesser the 'return 1' feature ;)
Post by: GeceBekcisi on 24 September, 2006, 18:45:08
What if we need to use

Code (lua) Select
user:SendData( "bot", "look you I don't send what you sent me!!" )
SendPmToOps( "bot", user.sName.." has tried to check our new feature" )


?
Title: Re: lesser the 'return 1' feature ;)
Post by: Herodes on 24 September, 2006, 20:20:44
Quote from: GeceBekcisi on 24 September, 2006, 18:45:08
What if we need to use

Code (lua) Select
user:SendData( "bot", "look you I don't send what you sent me!!" )
SendPmToOps( "bot", user.sName.." has tried to check our new feature" )


?
no problem at all... check this...
Code (lua) Select
function foo()
  return 1;
end

function bar()
  return "ok"
end

function foobar()
  foo()
  bar()
end

foobar() --> returns nothing,...

function foobar()
  foo()
  return bar()
end

foobar() --> returns "ok"

function foobar()
  return foo()
  bar()
end

foobar() --> returns 1 (bar() doesn't get a chance to be processed ;)

Title: Re: lesser the 'return 1' feature ;)
Post by: bastya_elvtars on 24 September, 2006, 22:26:26
Hmmm.... what is the problem? I have a bad flu, but I wouldn1t understand even if I were healthy.
Title: Re: lesser the 'return 1' feature ;)
Post by: Herodes on 24 September, 2006, 22:41:30
Quote from: bastya_elvtars on 24 September, 2006, 22:26:26
Hmmm.... what is the problem? I have a bad flu, but I wouldn1t understand even if I were healthy.
notin,... but it will save ppl from coding like dogs, have you seen how much the following function is saving scripts ?
function SendBack( user, msg, how )
    if how then user:SendPM( sBot, msg ); return 1; end
    user:SendData( sBot, msg ); return 1;
end


if not I'll post smth here ;)
Title: Re: lesser the 'return 1' feature ;)
Post by: bastya_elvtars on 24 September, 2006, 22:55:14
function SendBack( user, msg, how )
    return {["pm"]=user.SendPM}[how](user,sBot,msg) or user.SendData(user,sBot,msg),1
end
Title: Re: lesser the 'return 1' feature ;)
Post by: Herodes on 24 September, 2006, 23:01:00
Quote from: bastya_elvtars on 24 September, 2006, 22:55:14
function SendBack( user, msg, how )
    return {["pm"]=user.SendPM}[how](user,sBot,msg) or user.SendData(user,sBot,msg),1
end

now,... this is so c00l it can be the cause of your flu!
Title: Re: lesser the 'return 1' feature ;)
Post by: bastya_elvtars on 24 September, 2006, 23:02:42
Quote from: Herodes on 24 September, 2006, 23:01:00
now,... this is so c00l it can be the cause of your flu!
Some of my chunks are not for the weak of mind. :-P