+ Reply to Thread
Page 1 of 2 12 LastLast
Results 1 to 10 of 17

Thread: E2: Built In text-receiver

  1. #1
    Wire Sofaking ahref's Avatar
    Join Date
    Jul 2008
    Posts
    520

    Default E2: Built In text-receiver

    Could you build into e2 a text reciever?. Id imagine it would work like this

    Phrase = listenFor(S[string phrase],Boolean[case insensitive or not],boolean[exact or anywhere])

    You could then do

    If (Phrase) {
    Player = Phrase:Name()
    }

    Thankyou

  2. #2
    Wire Sofaking ZeikJT's Avatar
    Join Date
    Dec 2008
    Location
    California
    Posts
    1,391

    Default Re: E2: Built In text-receiver

    I already made en E2 text receiver.
    It fetches the last thing the input player has said:
    Code:
    wire_exp2_TextList = {}
    
    registerFunction("lastSaid", "e:", "s", function(self, args)
        local op1 = args[2]
        local rv1 = op1[1](self, op1)
        local entity = checkEntity(rv1)
    	if(!entity || !rv1:IsValid()) then return nil end
    	if(!entity:IsPlayer()) then return nil end
    	if !wire_exp2_TextList[entity] then return "" end
        return wire_exp2_TextList[entity][1]
    end)
    
    function Exp2TextReceiving( ply, text, toall )
    	wire_exp2_TextList[ply] = {text,toall}
    end
    hook.Add("PlayerSay","Exp2TextReceiving",Exp2TextReceiving)
    You pretty much have to use it in an interval. Use it like this to keep track of what you have said:
    Said = entity():owner():lastSaid()
    Last edited by ZeikJT; 02-14-2009 at 05:07 PM. Reason: ridding clearLastSaid, it's a bad idea
    Against stupidity the Gods themselves contend in vain.
    -Friedrich Schiller

    The flame puts me in the mood to "Do it!".
    -Dart, Legend of Dragoon

  3. #3
    Wire Sofaking ahref's Avatar
    Join Date
    Jul 2008
    Posts
    520

    Default Re: E2: Built In text-receiver

    hmm that only works with a set entity though i was wanting something more global. thankyou @D

  4. #4
    Wire Sofaking ZeikJT's Avatar
    Join Date
    Dec 2008
    Location
    California
    Posts
    1,391

    Default Re: E2: Built In text-receiver

    Quote Originally Posted by ahref View Post
    hmm that only works with a set entity though i was wanting something more global. thankyou @D
    What do you mean? I could add a function that gets the last thing anyone said.
    Against stupidity the Gods themselves contend in vain.
    -Friedrich Schiller

    The flame puts me in the mood to "Do it!".
    -Dart, Legend of Dragoon

  5. #5
    Wire Sofaking ahref's Avatar
    Join Date
    Jul 2008
    Posts
    520

    Default Re: E2: Built In text-receiver

    Quote Originally Posted by ZeikJT View Post
    What do you mean? I could add a function that gets the last thing anyone said.
    I was gonna sugest that but that wouldnt that be a bit laggy?

    it would work though

  6. #6
    Wire Sofaking ZeikJT's Avatar
    Join Date
    Dec 2008
    Location
    California
    Posts
    1,391

    Default Re: E2: Built In text-receiver

    Quote Originally Posted by ahref View Post
    I was gonna sugest that but that wouldnt that be a bit laggy?

    it would work though
    No way, just index them in a unique slot specific for this purpose:
    Code:
    wire_exp2_TextList = {}
    
    registerFunction("lastSaid", "e:", "s", function(self, args)
        local op1 = args[2]
        local rv1 = op1[1](self, op1)
        local entity = checkEntity(rv1)
    	if(!entity || !rv1:IsValid()) then return nil end
    	if(!entity:IsPlayer()) then return nil end
    	if !wire_exp2_TextList[entity] then return "" end
        return wire_exp2_TextList[entity][1]
    end)
    
    
    registerFunction("lastSaid", "", "s", function(self, args)
    	if (!wire_exp2_TextList['last'] || !wire_exp2_TextList['last'][2] then return "" end
        return wire_exp2_TextList['last'][2]
    end)
    
    registerFunction("lastSpoke", "", "e", function(self, args)
    	if (!wire_exp2_TextList['last'] || !wire_exp2_TextList['last'][1] then return null end
    	local ply = wire_exp2_TextList['last'][1]
    	if (!ply:IsValid() || !ply:IsPlayer()) then return null end
        return wire_exp2_TextList['last'][1]
    end)
    
    function Exp2TextReceiving( ply, text, toall )
    	wire_exp2_TextList[ply] = {text,toall}
    	wire_exp2_TextList['last'] = {ply, text, toall}
    end
    hook.Add("PlayerSay","Exp2TextReceiving",Exp2TextReceiving)
    There, two more functions added:
    LastPersonToSpeak = lastSpoke()
    LastPersonSaid = lastSaid()
    Against stupidity the Gods themselves contend in vain.
    -Friedrich Schiller

    The flame puts me in the mood to "Do it!".
    -Dart, Legend of Dragoon

  7. #7
    Wirererer pl0x's Avatar
    Join Date
    Aug 2008
    Posts
    238

    Default Re: E2: Built In text-receiver

    can we have the reciever committed to th SVN? it seems good, i could use it.

  8. #8
    Wire Sofaking ahref's Avatar
    Join Date
    Jul 2008
    Posts
    520

    Default Re: E2: Built In text-receiver

    Quote Originally Posted by ZeikJT View Post
    No way, just index them in a unique slot specific for this purpose:
    Code:
    wire_exp2_TextList = {}
    
    registerFunction("lastSaid", "e:", "s", function(self, args)
        local op1 = args[2]
        local rv1 = op1[1](self, op1)
        local entity = checkEntity(rv1)
    	if(!entity || !rv1:IsValid()) then return nil end
    	if(!entity:IsPlayer()) then return nil end
    	if !wire_exp2_TextList[entity] then return "" end
        return wire_exp2_TextList[entity][1]
    end)
    
    
    registerFunction("lastSaid", "", "s", function(self, args)
    	if (!wire_exp2_TextList['last'] || !wire_exp2_TextList['last'][2] then return "" end
        return wire_exp2_TextList['last'][2]
    end)
    
    registerFunction("lastSpoke", "", "e", function(self, args)
    	if (!wire_exp2_TextList['last'] || !wire_exp2_TextList['last'][1] then return null end
    	local ply = wire_exp2_TextList['last'][1]
    	if (!ply:IsValid() || !ply:IsPlayer()) then return null end
        return wire_exp2_TextList['last'][1]
    end)
    
    function Exp2TextReceiving( ply, text, toall )
    	wire_exp2_TextList[ply] = {text,toall}
    	wire_exp2_TextList['last'] = {ply, text, toall}
    end
    hook.Add("PlayerSay","Exp2TextReceiving",Exp2TextReceiving)
    There, two more functions added:
    LastPersonToSpeak = lastSpoke()
    LastPersonSaid = lastSaid()
    you appear to have 2 functions set to the same name.
    registerFunction("lastSaid", "e:", "s", function(self, args)
    and
    registerFunction("lastSaid", "", "s", function(self, args)

  9. #9
    Wire Sofaking ZeikJT's Avatar
    Join Date
    Dec 2008
    Location
    California
    Posts
    1,391

    Default Re: E2: Built In text-receiver

    Quote Originally Posted by ahref View Post
    you appear to have 2 functions set to the same name.
    registerFunction("lastSaid", "e:", "s", function(self, args)
    and
    registerFunction("lastSaid", "", "s", function(self, args)
    Yep, it's called overloading.
    It will act differently depending on whether you give it an input or not.

    EX:
    lastSaid()
    and
    lastSaid(entity():owner())

    Act differently

    A lot of things do this, think of the addition symbol +
    It adds numbers, vectors, angles, whatever. It too is overloaded.
    Against stupidity the Gods themselves contend in vain.
    -Friedrich Schiller

    The flame puts me in the mood to "Do it!".
    -Dart, Legend of Dragoon

  10. #10
    Wire Sofaking ahref's Avatar
    Join Date
    Jul 2008
    Posts
    520

    Default Re: E2: Built In text-receiver

    oh i see

+ Reply to Thread
Page 1 of 2 12 LastLast

Similar Threads

  1. Text Receiver
    By high6 in forum Wiremod Addons & Coding
    Replies: 74
    Last Post: 01-13-2009, 01:46 PM
  2. Text Receiver & Server Console
    By Captain Maim in forum Ideas & Suggestions
    Replies: 5
    Last Post: 12-31-2008, 02:01 AM
  3. Text receiver question
    By Spencenator in forum Installation and Malfunctions Support
    Replies: 4
    Last Post: 12-10-2008, 04:28 PM
  4. concmd not working with text receiver
    By Captain Maim in forum Bug Reports
    Replies: 7
    Last Post: 10-30-2008, 01:55 PM
  5. Text Receiver Won't update in AdvDup
    By Captain Maim in forum Installation and Malfunctions Support
    Replies: 1
    Last Post: 10-12-2008, 12:45 PM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
proceed-collector
proceed-collector
proceed-collector
proceed-collector
linguistic-parrots
linguistic-parrots
linguistic-parrots
linguistic-parrots