Results 1 to 3 of 3

Thread: Pasting an object triggers onLoad()

  1. #1

    Pasting an object triggers onLoad()

    I've got the following code, and I've noticed that copying and then pasting that object causes the onload portion of the original to trigger

    Code:
    function onLoad()
        --Start timer which repeats forever, running countItems() every second
    
        broadcastToAll(self.guid .. "   0      " .. self.getPosition().x,stringColorToRGB("White"))
        Timer.create({
            identifier=self.getGUID().."_timer",
            function_name="countItems", function_owner=self,
            repetitions=0, delay=1
        })
        broadcastToAll(self.guid .. "   1      " .. self.getPosition().x,stringColorToRGB("White"))
    end
    
    function onObjectSpawn(object)
        selfGUID = self.getGUID()
        broadcastToAll(self.guid .. "   2      " .. self.getPosition().x,stringColorToRGB("White"))
        if object.guid == selfGUID then
            --Start timer which repeats forever, running countItems() every second
            Timer.create({
                identifier=self.getGUID().."_timer",
                function_name="countItems", function_owner=self,
                repetitions=0, delay=1
            })
        end
    end
    
    function onObjectDestroy(object)
        Timer.destroy(self.getGUID().."_timer")
    end
    The broadcasting is to help me find out what's happening, and the GUID of the original shows up at 0 and at 1 on every paste.

    Furthermore, when the copy is created it seems to be creating its timer with the GUID of the original, which is weird.. Deleting the copy creates an error every second as the timer of the original stops existing, which confirms that it used the same ID as the original. I can create another thread for that bug if needed

  2. #2
    Moved to Scripting Bug Section.

  3. #3
    Join Date
    Apr 2016
    Posts
    175
    I wasn't the only one that noticed and reported... If they read this thread and not mine, the onspawn triggers each time as well.

Similar Threads

  1. Replies: 2
    Last Post: 04-09-2017, 09:22 PM
  2. Replies: 0
    Last Post: 06-20-2016, 09:36 PM
  3. [SOLVED] (v 6.9) These grouped boards aren't copy and pasting correctly...
    By Mark in forum Technical Support
    Replies: 5
    Last Post: 03-31-2016, 01:02 PM
  4. [ADDED] [v8.0] Triggers and Motor Mechanics
    By Kazkade in forum Suggestions
    Replies: 1
    Last Post: 03-29-2016, 06:00 PM
  5. Copy/Pasting URLs in Linux doesn't work
    By rmblr in forum Bug Reports
    Replies: 2
    Last Post: 09-26-2015, 06:44 PM

Tags for this Thread

Posting Permissions

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