User Tag List

Page 3 of 4 FirstFirst 1 2 3 4 LastLast
Results 21 to 30 of 34

Thread: [Bug?] For each object in filter condition

  1. #21
    Clicker Fusion 2.5 (Steam)Fusion 2.5 Developer (Steam)Fusion 2.5+ DLC (Steam)Android Export Module (Steam)HTML5 Export Module (Steam)iOS Export Module (Steam)Universal Windows Platform Export Module (Steam)
    Volnaiskra's Avatar
    Join Date
    Jan 2014
    Location
    www.sprykegame.com
    Posts
    2,453
    Mentioned
    122 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by Phi View Post
    Reuploading my MFA:
    Attachment 29034
    I haven't followed the entire conversation (I skimmed it but got lost with the jargon ). So I might be saying something you already know. If so, forgive me.

    If you rearrange this event:




    ....to this:




    ...then it works as intended.

    So what's happening is that in the first example, the fast loop breaks the scope of the event. So when Fusion returns from the fastloop back to this event and change animation direction action fires, it has no scope. So it can't fire on the clicked active because it no longer knows which was clicked. Since it no longer knows which was clicked, it has to choose the active some other, more arbitrary, way. So it uses the time of creation instead. It fires on the most recently created active instead (you can confirm this by making more duplicates - the last duplicate you created will be the one to go red). So far, that all seems reasonable and logical to me, actually.

    The thing that I think is weird is not that it fires on the wrong active per se, but that it still only fires on one active. If the scope is broken, shouldn't it change direction on all actives?


    __________________________________________________ _______________________________


    I found similar oddities when I wrote my scoping article a while back. I'll point out some more idiosyncracies:

    Like I said, fusion is applying the change direction action to the most recently created active. So, if you create a new active in that fastloop, that will be the most recently created active, and it will become red:





    Interestingly, this actually applies to multiple actives if you create more than one in that fastloop:





    But then add in another action into the fastloop before the creation events, and it goes back to affecting only one:


  2. #22
    Clicker Fusion 2.5 MacFusion 2.5 DeveloperAndroid Export ModuleHTML5 Export ModuleiOS Export ModuleSWF Export ModuleXNA Export ModuleUnicode Add-on
    Fusion 2.5 (Steam)Fusion 2.5 Developer (Steam)Fusion 2.5+ DLC (Steam)Android Export Module (Steam)HTML5 Export Module (Steam)iOS Export Module (Steam)Universal Windows Platform Export Module (Steam)Firefly 3D Module (Steam)
    Phi's Avatar
    Join Date
    Jan 2010
    Location
    England
    Posts
    1,904
    Mentioned
    22 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by Volnaiskra View Post
    So what's happening is that in the first example, the fast loop breaks the scope of the event. So when Fusion returns from the fastloop back to this event and change animation direction action fires, it has no scope.
    Yeah, that doesn't make any sense. I can't see a single coding language (C, C++, C#, JS even...) where you go to a subfunction, or a sub-loop, and the parent function/parent loop has their selection discarded and not restored when the loop finishes... simply because of the principles of "if a subfunction wants its own variables, it makes a copy, unless explicitly asking for the original". Implicitly, you don't mess with parent stuff, because when you start getting into multiple layers (grandchildren) or multiple subloops (siblings), then you no longer know what's going on in the parent, and if something is changed you're no longer sure what's causing it.
    In this scenario, the fastloop retaining the selection makes sense. The fastloop having a blank slate selection also makes sense, and that's what happens. But, the parent event should have its selection restored when the fastloop ends. So event 4-5 shouldn't run any differently to 1-2.
    (arguably, blank slate makes more sense, as you can't get a blank slate mid-event otherwise.)

    I came across a related bug in Lacewing, when loop variables weren't copied out and the selection was shared between all loops; if a loop ran a subloop, the parent's selection would be overwritten by the subloop, and the parent loop would crash, because it was now in an invalid state.
    Now all the loops copy out the selection, and the user can mess with selection all they want in the loops without making an inconsistent state.
    Although this bug was somewhat hard to trigger, but here's an example scenario: if you were trying to find all clients that were visible to a particular client; you'd select the particular client, loop that client's channels, in the channel-loop, loop that channel's client list, and now you had particular client being overwritten... because selected-client was being selected as the "client on channel" loop.
    That's just confusing, as now you've lost the selection and at no point were you intending that.
    And worst, now what client is now selected to continue looping the joined-channel list from? Selection of client has been altered.

    That's why it must be explicit. The principle is reflected in most coding languages by parameters being pass-by-value by default, making them copied implicitly.
    If Fusion needed to retain the behaviour for compatibility, I'd strongly advise adding an option akin to the one that adds alt values/strings to counters... or adding a new action for starting a fastloop without discarding scope.

  3. #23
    Clickteam Fusion 2.5 DeveloperFusion 2.5+ DLCAndroid Export ModuleHTML5 Export ModuleiOS Export ModuleUniversal Windows Platform Export ModuleInstall Creator Pro
    Fusion 2.5 (Steam)Fusion 2.5 Developer (Steam)Android Export Module (Steam)HTML5 Export Module (Steam)iOS Export Module (Steam)Universal Windows Platform Export Module (Steam)
    BartekB's Avatar
    Join Date
    Aug 2013
    Posts
    643
    Mentioned
    14 Post(s)
    Tagged
    0 Thread(s)
    That's an issue I've touched upon briefly in this thread already:

    Quote Originally Posted by BartekB View Post
    Sure, the example you have given is rather weird, it is due to how selection and fast loops were implemented and is what limited what I could do with the extension.

    But it's not a mystery either, Fusion only has one selection list and the fast loop changes it, any actions afterwards will use the fastloop's selection/scope.
    The keywords here are "one selection list", that is why functionality that nests events is so dangerous, like fast loops, for each loops and any other custom made ones in extensions.
    How Fusion reads the selection is a bit more complicated than that, including how Create object behaves, hence why Volnaiskra is getting different results.

    This is also why for each loops are queued then called when everything in the event is done rather than called immediately because of this very problem.
    The best approach to avoiding this issue is by splitting the event in to two or three, so that the loop action is by itself and cannot modify scope for other actions around it. With CF2.5+ and child events it shouldn't be a problem.


    My extension solves 50% of the problem, the loops within it save and restore selection of the object that was looped through. But, the problem still occurs if you scope an outside object.
    That could be solved by saving and restoring every single object type, but that would be very inefficient (imagine having to restore 100s of object types).
    Another more realistic solution would be to hand users a "Save selection of object" action, which would pack additional types to restore after a loop.
    - BartekB, a.k.a Uppernate
    Join the Click Converse Discord! - https://discord.gg/7RNXFrC
    Dungeon Raiders! - Link soon™

  4. #24
    Clicker Fusion 2.5 DeveloperAndroid Export Module
    Vilhjalmr's Avatar
    Join Date
    Mar 2014
    Location
    Sweden
    Posts
    70
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I have come across a related issue dealing with scope in loops. When I'm creating player objects such as "army units" I want them to have a base object, a skin object and various stats. I can create all of these using a single on each loop to sort of "layer" every unit and give them their respective values. BUT, when I want to set conditions for changing the appearance of each individual object according to their stats they are all affected in the same way, not individually.

    This code manages to place the health bar object and scale it according to each objects position and values, but not to change the color of them (I use the same value for scaling and coloring). I have tried looping for this also with the same or worse result (please disregard the sloppily name value "percent").coloring.png

  5. #25
    Clicker Fusion 2.5 DeveloperAndroid Export Module
    Vilhjalmr's Avatar
    Join Date
    Mar 2014
    Location
    Sweden
    Posts
    70
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Here I use a loop and set "percent" to object width instead, same result.
    coloring2.png

  6. #26
    Clicker Fusion 2.5 DeveloperAndroid Export Module
    Vilhjalmr's Avatar
    Join Date
    Mar 2014
    Location
    Sweden
    Posts
    70
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I solved it by switching from replacing color to changing animation, might be an issue there.

  7. #27
    Clickteam Fusion 2.5 DeveloperFusion 2.5+ DLCAndroid Export ModuleHTML5 Export ModuleiOS Export ModuleUniversal Windows Platform Export ModuleInstall Creator Pro
    Fusion 2.5 (Steam)Fusion 2.5 Developer (Steam)Android Export Module (Steam)HTML5 Export Module (Steam)iOS Export Module (Steam)Universal Windows Platform Export Module (Steam)
    BartekB's Avatar
    Join Date
    Aug 2013
    Posts
    643
    Mentioned
    14 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by Vilhjalmr View Post
    I solved it by switching from replacing color to changing animation, might be an issue there.
    Yes, replace colour modifies the original image which all instances of the object have reference to.
    The keyword is reference, the image is not copied for each instance/duplicate there is, everything just holds the one and only original image which you see happened there.

    You might want to use a shader if you'd want control over adjusting the visuals of an object per instance (only for Windows though).
    - BartekB, a.k.a Uppernate
    Join the Click Converse Discord! - https://discord.gg/7RNXFrC
    Dungeon Raiders! - Link soon™

  8. #28
    Clicker Fusion 2.5 (Steam)Fusion 2.5 Developer (Steam)Fusion 2.5+ DLC (Steam)Android Export Module (Steam)HTML5 Export Module (Steam)iOS Export Module (Steam)Universal Windows Platform Export Module (Steam)
    Volnaiskra's Avatar
    Join Date
    Jan 2014
    Location
    www.sprykegame.com
    Posts
    2,453
    Mentioned
    122 Post(s)
    Tagged
    0 Thread(s)
    Can someone please suggest a good way of creating a variable number of objects from within a ForEach loop, without breaking scope?

    So, at the moment, I'm creating a single object from within a forEach loop:



    But I'd like to be able to create, say, between 0-10 of those objects, depending on the smokeAmount0to10 variable

    I could do it using a fastloop, but as I understand it, this would break the scope of the forEach loop, which would break things further down in my code:



    One way I can think to do is to use 10 separate events like this, but this is a pretty undesirable method (it's clunky, probably a bit expensive, and any future modifications would need to be done 10 times):




    Can anyone suggest a better way?

  9. #29
    Clicker

    Fusion 2.5 MacFusion 2.5 DeveloperFusion 2.5+ DLCiOS Export ModuleSWF Export ModuleFirefly 3D Module
    Fusion 2.5 (Steam)Fusion 2.5 Developer (Steam)Android Export Module (Steam)HTML5 Export Module (Steam)iOS Export Module (Steam)Universal Windows Platform Export Module (Steam)
    fnkycoldmadeanr's Avatar
    Join Date
    Jul 2017
    Location
    Melbourne, Australia
    Posts
    187
    Mentioned
    14 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by Volnaiskra View Post
    Can someone please suggest a good way of creating a variable number of objects from within a ForEach loop, without breaking scope?

    Can anyone suggest a better way?
    RetainScope.png

    Try this Vol.

  10. #30
    Clicker Fusion 2.5 (Steam)Fusion 2.5 Developer (Steam)Fusion 2.5+ DLC (Steam)Android Export Module (Steam)HTML5 Export Module (Steam)iOS Export Module (Steam)Universal Windows Platform Export Module (Steam)
    Volnaiskra's Avatar
    Join Date
    Jan 2014
    Location
    www.sprykegame.com
    Posts
    2,453
    Mentioned
    122 Post(s)
    Tagged
    0 Thread(s)
    oh, wow - calling a fastloop from a forEach loop and then putting that same forEachloop inside the fastloop? How Escheresque I didn't know you could do that. I'll definitely try it.

    EDIT: seems to work a treat!

Page 3 of 4 FirstFirst 1 2 3 4 LastLast

Similar Threads

  1. Help with active object condition
    By fafikozoom in forum Fusion 2.5
    Replies: 5
    Last Post: 18th October 2016, 07:25 PM
  2. Flash object while [condition]
    By Hidronax in forum Multimedia Fusion 2 - Technical Support
    Replies: 2
    Last Post: 13th August 2016, 06:23 PM
  3. Replies: 2
    Last Post: 26th September 2015, 07:23 PM
  4. nearest object condition event
    By Lukiester in forum Fusion 2.5
    Replies: 4
    Last Post: 21st August 2015, 06:24 PM
  5. Graphics Filter, Audio Filter, and Transition SDK
    By kraminator in forum Extension Development
    Replies: 7
    Last Post: 27th March 2011, 08:40 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
  •