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

Thread: Chat targets entities

  1. #1
    Wire Sofaking ktccd's Avatar
    Join Date
    Sep 2009
    Posts
    751

    Default Chat targets entities

    Ok, I got some trouble here with my expression.
    I use this code to find an entity I say in chat:
    Code:
    @name target ent chat
    @outputs Target:entity
    @persist Targ Strings:string
    runOnTick(1)
    if ((lastSpoke()==owner())&(lastSaid() =="!target_on")) {Targ = 1}
    if ((lastSpoke()==owner())&(lastSaid() =="!target_off")) {Targ = 0}
    if ((Targ == 1)&(owner():lastSaid()!="!target_on")|(owner():lastSaid()!="!target_off"))
    {
        Strings=(owner():lastSaid())
        Target=(findPlayerByName(Strings))
    }
    This must be wrong, because the object just fly to a blank spot.
    If needed, in case this is correct, I will post the code I use to move towards the target, but I think the problem is inside this expression.

  2. #2
    Wire Sofaking Wodden's Avatar
    Join Date
    Sep 2007
    Location
    location.sh &> /dev/null
    Posts
    446

    Default Re: Chat targets entities

    You don't need runOnTick, you need runOnChat & chatClk() cause' youre checking for chat commands. You also dont need all that "LastSpoke() == owner()" stuff, it's shorter to use "owner():lastSaid()". And for the 3rd if-statement you don't need to check if you last said !target_off, because Targ can't equal 1 if you've done so .
    Well, that String and Target stuff, just combine it.

    Use this:
    [highlight=e2]@name Player Chat Target
    @outputs Target:entity
    @persist Targ

    runOnChat(1)

    if (first()) {Targ = 0}
    if (chatClk() & owner():lastSaid() == "!target_on") {Targ = 1}
    if (chatClk() & owner():lastSaid() == "!target_off") {Targ = 0}

    if (chatClk() & Targ == 1 & owner():lastSaid() != "!target_on")
    {
    Target = findPlayerByName(owner():lastSaid())
    }
    [/highlight]
    !target_on enables player name targeting, after entering this, enter the players name you want to target
    !target_off disables player name targeting
    Last edited by Wodden; 09-15-2009 at 01:19 AM.
    “Saying Java is good because it works on all operating systems is like saying anal sex is good because it works on all genders.”

  3. #3
    Wirererer Liquos's Avatar
    Join Date
    Jul 2009
    Posts
    216

    Default Re: Chat targets entities

    Just a little note, Wodden. I would suggest explaining what you changed, why you changed it, and what it does. It's just that ktccd might not understand what is going on in the code. He might be happy and say "yay, it works!" but he might not know exactly what chatclk() does, for example. Just a little thing that I used to do all the time too (and with which I had problems back when I was learning the basics of wiremod).
    Last edited by Liquos; 09-15-2009 at 12:52 AM.

  4. #4
    Wire Sofaking Wodden's Avatar
    Join Date
    Sep 2007
    Location
    location.sh &> /dev/null
    Posts
    446

    Default Re: Chat targets entities

    Quote Originally Posted by Liquos View Post
    Just a little note, Wadden. I would suggest explaining what you changed, why you changed it, and what it does. It's just that ktccd might not understand what is going on in the code. He might be happy and say "yay, it works!" but he might not know exactly what chatclk() does, for example. Just a little thing that I used to do all the time too (and with which I had problems back when I was learning the basics of wiremod).
    :zing::spelling: My name is Wodden BTW i'm editing my post already...
    “Saying Java is good because it works on all operating systems is like saying anal sex is good because it works on all genders.”

  5. #5
    Wirererer Liquos's Avatar
    Join Date
    Jul 2009
    Posts
    216

    Default Re: Chat targets entities

    Oh sorry about that. It is kinda late and my spelling starts to deteriorate as it gets later and later.

  6. #6
    Wire Sofaking ktccd's Avatar
    Join Date
    Sep 2009
    Posts
    751

    Default Re: Chat targets entities

    Wow, replies so fast ^^. I like this comunity already (just started gmod last week, though programing is not hard as long as I get an explaination what does what).

    Now, yes an explanation is great, but I took someone elses code and removed the chatclk when nothing worked. I tested everything, from start to end in the code, tryign out what everything did. as a final resort I removed chatclk, and the command to turn the door on and off worked.

    So IDK what chatclk does, it just messed up my code.
    Also, the owner():lastSaid() is what I use in code I made myself, but I took the text-recogninser (spelling?) from someone elses suggestion.

  7. #7
    Wire Sofaking Wodden's Avatar
    Join Date
    Sep 2007
    Location
    location.sh &> /dev/null
    Posts
    446

    Default Re: Chat targets entities

    Quote Originally Posted by ktccd View Post
    -snip- :v:
    chatClk() equals 1 if something is entered in chat. Even with it my code worked for me :|. And for owner():lastSaid(), you checked twice if you said something. I've got anotner e2:
    [highlight=e2]@name Player Chat Target
    @outputs Target:entity
    @persist Targ

    runOnChat(1)

    if (first()) {Targ = 0}

    if (chatClk() & owner():lastSaid() == "!target") {
    Targ = !Targ
    if (Targ) { hint("Targeting enabled", 2) }
    elseif (!Targ) { hint("Targeting disabled", 2) }
    }

    if (chatClk() & Targ == 1 & (owner():lastSaid() != "!target"))
    {
    Target = findPlayerByName(owner():lastSaid())
    Targ = 0
    hint("Target: " + Target:name() + "", 2)
    }
    [/highlight]
    “Saying Java is good because it works on all operating systems is like saying anal sex is good because it works on all genders.”

  8. #8
    Wirererer Elmo the Emo Emperor's Avatar
    Join Date
    Feb 2008
    Location
    Lagville(Austrlia)
    Posts
    278

    Default Re: Chat targets entities

    chatClk() returns true if the execution was triggered by runOnChat(1)
    You can also put an entity into the chatclk to check if the chat was by that entities. The thing you have to be careful of is giving it a non-player entiy as i assume this would give script error.
    For example to check if the last person to talk was you, you would go.
    runOnChat(1)
    if(chatClk(owner())){ do stuff here }
    if you do that you can assume that last said will equal what the owner last said, so you won't have to go owner():lastSaid() you can just go lastSaid()
    Last edited by Elmo the Emo Emperor; 09-15-2009 at 02:28 AM.

  9. #9
    Wire Sofaking ktccd's Avatar
    Join Date
    Sep 2009
    Posts
    751

    Default Re: Chat targets entities

    This is very good stuff ^^.
    I used the last posted script there, and it works perfectly. I'll modify and use it for about all of my chat-commands. TY all ^^.

  10. #10
    Wire Sofaking Wodden's Avatar
    Join Date
    Sep 2007
    Location
    location.sh &> /dev/null
    Posts
    446

    Default Re: Chat targets entities

    Rep. And Credit mah?
    “Saying Java is good because it works on all operating systems is like saying anal sex is good because it works on all genders.”

+ Reply to Thread
Page 1 of 2 12 LastLast

Similar Threads

  1. Getting Vector Between Targets
    By RabidCrab in forum Expression 2 Discussion & Help
    Replies: 4
    Last Post: 04-19-2009, 02:52 AM
  2. How do i track more then 10 targets?
    By Nikolas in forum Installation and Malfunctions Support
    Replies: 4
    Last Post: 04-03-2009, 12:53 AM
  3. more that two targets
    By rvdm88 in forum Installation and Malfunctions Support
    Replies: 2
    Last Post: 01-24-2008, 05:11 PM
  4. Cycling Targets?
    By Celto in forum Installation and Malfunctions Support
    Replies: 2
    Last Post: 01-03-2008, 01:32 PM
  5. Latching targets
    By ufoslava in forum Installation and Malfunctions Support
    Replies: 5
    Last Post: 11-08-2007, 10:32 PM

Tags for this Thread

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