+ Reply to Thread
Page 1 of 2 1 2 LastLast
Results 1 to 15 of 21

  Click here to go to the first Rift Team post in this thread.   Thread: Sleep() function in Rift

  1. #1
    Shadowlander
    Join Date
    Jan 2011
    Posts
    36

    Default Sleep() function in Rift

    Hey everyone,

    I'm sorry if this has been posted before; I searched for it and didn't see it anywhere however.
    I'm implementing an addon that constantly scans for nearby creatures, and alerts you when it's found a rare.

    Instead of it scanning as often as the function returns, I'd like to implement a sleep function to allow the servers and the client some "time off" from scanning local NPC's.

    That said, since Lua doesn't have a built in sleep function, I know that normally you'd wrap the sleep into C or a derivative of your specific OS. Which is fine. My main question is, is that still possible inside of Rift's Lua execution? If not, does Rift have another means to allow a script to sleep?

    Thanks!

  2. #2
    Shadowlander
    Join Date
    Jun 2011
    Posts
    44

    Default

    Lua doesn't really have a threading model and thus doesn't have Sleep. Your best bet is to hook Event.System.Update.Begin and do something like:

    if (Inspect.Time.Frame() - lastUpdate) < 0.1 then
    return
    end
    lastUpdate = Inspect.Time.Frame()

    That'll give you about 10 updates a second.

    Alternatively, you can hook Event.Unit.Add and that will tell you when the client finds a new unit, so you don't even need to scan.
    Last edited by Jorast; 12-03-2011 at 07:11 PM.
    Author of SimpleMeter

  3. #3
    RIFT Community Ambassador the_real_seebs's Avatar
    Join Date
    Jan 2011
    Posts
    16,859

    Default

    Basically, yeah -- look for events and process things based on them. The most likely thing would be to hook the unit change events, because those will necessarily fire if there's any benefit to you scanning.

    Sleeping for a specific period of time is useful only if there's a known event coming at a particular upcoming time, generally.
    You can play WoW in any MMO. You don't have to play WoW in RIFT. Oh, and no, RIFT is not a WoW clone. Not having fun any more? Learn to play, noob! I don't speak for Riftui, but I moderate stuff there. Just came back? Welcome back! Here's what's changed. (Updated for 2.5!)

  4. #4
    Shadowlander
    Join Date
    Jan 2011
    Posts
    36

    Default

    Oh, hooking Event.Unit.Add seems to be a good solution, thanks so much.

    Here's a question, though: What happens if two (or more) units are added at the same time? As in, how long does a unit stay in the table? I ask because if needed, I'll make a function that pulls units out of the Event.Unit.Add table and adds them to a queue to be scanned for their name, so that the system can scan all the names in the table before they expire.

    Also, the RiftUI wiki documentation for it seems to indicate that it only triggers on a new group/raid member, a new target, and a mouseover; is that accurate or is it just incomplete? I looked on the official "Documentation" pastebin, and it gave less information.

  5. #5
    Plane Touched Levva's Avatar
    Join Date
    Jan 2011
    Location
    Aberdeen, Scotland
    Posts
    243

    Default

    My understanding is that for every unit added you will get a new Event.Unit.Add. Also note that Event.Unit.Remove fires when unit removed so perhaps you need that one as well to check when units leave scope.

    I'd suggest that you should look at the sticky thread for example addons and grab Zorba's Trion Development Tools from there. Once installed you can do things like /eventlog to display events as they happen in chat. This helps a lot in understanding the order and frequency of events being fired. This sounds like it would help you a lot to understand what is going on.

  6. #6
    General of Telara
    Join Date
    Apr 2011
    Posts
    944

    Default

    Quote Originally Posted by koresho View Post
    Also, the RiftUI wiki documentation for it seems to indicate that it only triggers on a new group/raid member, a new target, and a mouseover; is that accurate or is it just incomplete? I looked on the official "Documentation" pastebin, and it gave less information.
    For all the unit events you'll only be able to "see" what your character is "targeting" (in a very large way). From my testing it includes:
    - Your target, target's target, focus (maybe focus' target, not 100% sure)
    - Whatever you mouseover
    - Whoever is in the same group/raid than you
    - Whatever is directly targeted by group/raid members

    (A while back I wanted to use that Event.Unit.Add to get an improved view of all relevant adds in a raid boss fight, thinking the Event would fire for anything my character could see and found about those limitations the hard way)

  7. #7
    RIFT Fan Site Operator Aieny's Avatar
    Join Date
    Feb 2011
    Location
    Earth
    Posts
    472

    Default

    Quote Originally Posted by Ethanol View Post
    For all the unit events you'll only be able to "see" what your character is "targeting" (in a very large way). From my testing it includes:
    - Your target, target's target, focus (maybe focus' target, not 100% sure)
    - Whatever you mouseover
    - Whoever is in the same group/raid than you
    - Whatever is directly targeted by group/raid members

    (A while back I wanted to use that Event.Unit.Add to get an improved view of all relevant adds in a raid boss fight, thinking the Event would fire for anything my character could see and found about those limitations the hard way)
    The add event only triggers if the unit being added can be accessed by a unit specifier (that is, a combination of player, pet, focus, groupXX, target, mouseover). The remove event fires when a unit loses the specifier.
    a community-oriented site for all things Rift

  8.   Click here to go to the next Rift Team post in this thread.   #8
    Rift Team
    Join Date
    Oct 2010
    Posts
    927

    Default

    Quote Originally Posted by Ethanol View Post
    For all the unit events you'll only be able to "see" what your character is "targeting" (in a very large way). From my testing it includes:
    - Your target, target's target, focus (maybe focus' target, not 100% sure)
    - Whatever you mouseover
    - Whoever is in the same group/raid than you
    - Whatever is directly targeted by group/raid members
    Start at every possible root. These include:

    * The player
    * The player's focus
    * The player's mouseover
    * All 20 groupmembers, if you have them

    For each unit you can see, add:

    * Its target
    * Its owner (if it's a pet)
    * Its main pet (if it has one)

    Repeat that last step indefinitely.

    If you're targeting someone, and they're targeting someone else, and they're targeting someone else, you'll be able to "see" that entire chain. Same goes if you're focusing someone.

  9. #9
    RIFT Community Ambassador the_real_seebs's Avatar
    Join Date
    Jan 2011
    Posts
    16,859

    Default

    Idle question:

    Purely hypothetically, if we were to try to set up a "conga line" of targeting, such that each of a couple hundred people were targeting the next, would we break anything?

    Is there loop detection? Will it handle loops of several hundred?
    You can play WoW in any MMO. You don't have to play WoW in RIFT. Oh, and no, RIFT is not a WoW clone. Not having fun any more? Learn to play, noob! I don't speak for Riftui, but I moderate stuff there. Just came back? Welcome back! Here's what's changed. (Updated for 2.5!)

  10. #10
    Plane Touched Levva's Avatar
    Join Date
    Jan 2011
    Location
    Aberdeen, Scotland
    Posts
    243

    Default

    Quote Originally Posted by the_real_seebs View Post
    Idle question:

    Purely hypothetically, if we were to try to set up a "conga line" of targeting, such that each of a couple hundred people were targeting the next, would we break anything?

    Is there loop detection? Will it handle loops of several hundred?
    I'd hope that it played a tune. Tarrara-rara-Conga! Tarrara-rara-Conga! Ooohh oh Yay! Ooohh oh Yay!

    Sadly you couldn't do this in your own addon as we can't play sounds yet!!

  11. #11
    General of Telara
    Join Date
    Apr 2011
    Posts
    944

    Default

    Quote Originally Posted by ZorbaTHut View Post
    Start at every possible root. These include:

    * The player
    * The player's focus
    * The player's mouseover
    * All 20 groupmembers, if you have them

    For each unit you can see, add:

    * Its target
    * Its owner (if it's a pet)
    * Its main pet (if it has one)

    Repeat that last step indefinitely.

    If you're targeting someone, and they're targeting someone else, and they're targeting someone else, you'll be able to "see" that entire chain. Same goes if you're focusing someone.
    Thanks for the complete list, obviously missed a lot by testing it only in the closed environment that are raids. Will do some extra outdoor testing (most likely during zone events to maximize the potential), might be able to do some interesting stuff

    And additionnal question with seebs' one: does the "target chain" allows the API to see people that are far enough from your character to not even be displayed on screen? (or even further away than "tab" range)

  12. #12
    Plane Touched Levva's Avatar
    Join Date
    Jan 2011
    Location
    Aberdeen, Scotland
    Posts
    243

    Default

    Quote Originally Posted by Ethanol View Post
    Thanks for the complete list, obviously missed a lot by testing it only in the closed environment that are raids. Will do some extra outdoor testing (most likely during zone events to maximize the potential), might be able to do some interesting stuff

    And additionnal question with seebs' one: does the "target chain" allows the API to see people that are far enough from your character to not even be displayed on screen? (or even further away than "tab" range)
    I'm fairly sure this is true. To test create a group of two people. Have one of them stay in main city and other teleport to Ember Isle. Have each player target something and then test what you can see. I'm fairly sure you will still get both group01.target and group02.target and be able to do Inspect.Unit.Detail() even though there is a lot of distance between you.

  13. #13
    Telaran
    Join Date
    Jan 2011
    Posts
    71

    Default

    Quote Originally Posted by Levva View Post
    I'm fairly sure this is true. To test create a group of two people. Have one of them stay in main city and other teleport to Ember Isle. Have each player target something and then test what you can see. I'm fairly sure you will still get both group01.target and group02.target and be able to do Inspect.Unit.Detail() even though there is a lot of distance between you.
    From my personal experience I'd say you will be able to see the target (= unitId) but when inspecting the details you will get nil.
    Last edited by Matrix; 12-06-2011 at 10:56 AM.

  14.   Click here to go to the next Rift Team post in this thread.   #14
    Rift Team
    Join Date
    Oct 2010
    Posts
    927

    Default

    Quote Originally Posted by Ethanol View Post
    And additionnal question with seebs' one: does the "target chain" allows the API to see people that are far enough from your character to not even be displayed on screen? (or even further away than "tab" range)
    What will eventually happen is that Inspect.Unit.Lookup("player.target.target.target") will return a unit ID, but Inspect.Unit.Detail() on that unit ID will return nil. Trying to chain further out will just result in nils.

    Being aware of the existence of a unit does not necessarily imply being aware of information about that unit.

  15. #15
    Plane Touched Levva's Avatar
    Join Date
    Jan 2011
    Location
    Aberdeen, Scotland
    Posts
    243

    Default

    Quote Originally Posted by ZorbaTHut View Post
    What will eventually happen is that Inspect.Unit.Lookup("player.target.target.target") will return a unit ID, but Inspect.Unit.Detail() on that unit ID will return nil. Trying to chain further out will just result in nils.

    Being aware of the existence of a unit does not necessarily imply being aware of information about that unit.
    Are you implying and can we infer that if Inspect.Unit.Detail() returns nil in these circumstances that the unit is out of range or otherwise unavailable? Are there specific circumstances that would result in nil? ie: can we assume that if the unit is in range and a member of our group that we will always get a result from Inspect.Unit.Detail() or are there circumstances where we would get a nil?

+ Reply to Thread
Page 1 of 2 1 2 LastLast

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