Results 1 to 4 of 4

Thread: takeObject() GUID bug or intended behaviour?

  1. #1

    takeObject() GUID bug or intended behaviour?

    So I have a weird scripting issue with the bag.takeObject() function that might possibly be a bug.

    If I have my Global script or another object script run the takeObject() function on a remote bag the object will come out of the bag with it's GUID unmodified.

    If on the other hand I put a script in that object / bag itself and use self.takeObject() to put an item out on the table the item acts like a copy and takes on a new GUID. Using bag = getObjectFromGUID(idHere) and then calling bag.takeObject(params) still results in a new GUID as long as the script that is calling it resides in the same object. I've tried this with multiple bags and configurations and it seems to hold true. I've tried putting my takeObject() code in a function in the Global script and then using Global.call to call that function but it still modifies the GUID (Even without passing any references). I also tried setting up a coroutine to execute the code while my object just calls coroutine.resume() but that also fails.

    This is causing me some headaches. I'm using the onCollisionEnter() function so I think I need the bag to be the trigger. The code basically runs a quick check on the contents of the bag and spits out any unwanted items but I need these items returned to the table with their GUIDs intact.

    Any advice would be appreciated.

  2. #2
    Join Date
    May 2016
    Posts
    1,072
    I will leave this behavior to other to comment on. Because I don't know haha

    But a possible solution might be using onCollisionEnter to detect the item entering the bag and then using Global.call("functionNameInGlobal", {table of parameters if needed}) to trigger takeObject in global instead.

  3. #3
    Quote Originally Posted by MrStump View Post
    I will leave this behavior to other to comment on. Because I don't know haha

    But a possible solution might be using onCollisionEnter to detect the item entering the bag and then using Global.call("functionNameInGlobal", {table of parameters if needed}) to trigger takeObject in global instead.
    I tried that and unfortunately the script still modified the GUID but if that same function was called by another object or the global script as a source it works correctly and leaves the GUID intact. I don't even really need to pass a reference to know which object collided because I just run a loop to process the bag contents. It's just triggering it that's the problem.

    Edit: Example of what I tried.

    Global script:
    function bagCheck ()
    local targetBag = getObjectFromGUID('1c2ce8')
    local bagContents = targetBag.getObjects()
    for i in pairs(bagContents) do
    if bagContents[i].guid ~= 'fed466' and bagContents[i].guid ~= 'e00040' and bagContents[i].guid ~= 'e12a2b' then
    local params = {}
    params.position = {-50, 3, 0}
    targetBag.takeObject(params)
    end
    end
    end
    (I also tried this with params.guid = bagContents[i].guid and params.index = i - 1 for more precise targeting but they also modify the GUID)

    Bag script:
    function onCollisionEnter()
    Global.call("bagCheck", {})
    end
    If I just call bagCheck() from the Global script instead there's no problems.
    Last edited by Kronark; 02-16-2017 at 01:53 AM. Reason: Add details

  4. #4
    Join Date
    May 2016
    Posts
    1,072
    That is odd. The only other solution I could think of would be to name the objects and use bagContents[i].name for exclusion instead of the GUIDs.

    Not ideal behavior though, for sure

Similar Threads

  1. Copy text guid
    By Crazy in forum Scripting Bug Reports
    Replies: 1
    Last Post: 02-14-2017, 09:22 AM
  2. Sorting a Deck Causes it to Have a New GUID
    By urenoiro in forum Scripting
    Replies: 8
    Last Post: 10-31-2016, 10:59 PM
  3. Replies: 4
    Last Post: 04-12-2016, 08:23 PM
  4. Replies: 3
    Last Post: 03-15-2016, 08:43 AM
  5. Replies: 14
    Last Post: 01-22-2016, 06:26 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •