User Tag List

Results 1 to 10 of 10

Thread: if value of an item exists in a list file, destroy item

  1. #1
    Clicker Fusion 2.5Fusion 2.5+ DLCAndroid Export ModuleiOS 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)
    blurymind's Avatar
    Join Date
    Feb 2014
    Location
    Huddersfield, United Kingdom
    Posts
    493
    Mentioned
    6 Post(s)
    Tagged
    0 Thread(s)

    if value of an item exists in a list file, destroy item

    I am using a list item to store all active object IDs that should not be spawned again when you restart the game (load/save system).

    How do I tell an item to destroy itself at the start of frame, if its ID value exists in the list file?

    Using the findStringExact command kills all the items, because the condition is not pointing which item to destroy. Instead it is pointing to the list file.

    Is it possible to use a list file in order to stop objects from respawning after game reset?

  2. #2
    Clicker Fusion 2.5Fusion 2.5+ DLCAndroid Export ModuleiOS 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)
    blurymind's Avatar
    Join Date
    Feb 2014
    Location
    Huddersfield, United Kingdom
    Posts
    493
    Mentioned
    6 Post(s)
    Tagged
    0 Thread(s)
    If nobody knows how to do this with a list file, any ideas how to do it with an array?

    I want to store in one place all the ID values of game items that have been used/killed/shouldnt respawn.
    If that value is in that place= kill the item on start of frame!

  3. #3
    Clicker Fusion 2.5 DeveloperAndroid Export Module
    Chrille's Avatar
    Join Date
    Jul 2006
    Posts
    389
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    You can do it with a List, but when you compare the ID of an Active Object to a List Item you need to use Val(), since the List Items are Strings.

    Code:
    1: Start a Loop (-1 times)
    
    2: On Loop
        & if Active Object ID is equal to Val(Get Line(Loop Index))
        = Destroy Active Object
    
    3: If Loop Index is equal to List Count
        = Stop Loop

  4. #4
    Clicker Fusion 2.5Fusion 2.5+ DLCAndroid Export ModuleiOS 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)
    blurymind's Avatar
    Join Date
    Feb 2014
    Location
    Huddersfield, United Kingdom
    Posts
    493
    Mentioned
    6 Post(s)
    Tagged
    0 Thread(s)
    interesting. I didnt know you can run a loop -1 times. What does it do when its a negative value?

    In my case I am also appending the number of the frame to the ID. Would that cause any serious issues?
    I am also running a loop at start of frame to spread the ID (and append the number of the frame at the start of it- so I dont have objects from one frame destroy objects from another)

  5. #5
    Clicker Fusion 2.5 DeveloperAndroid Export Module
    Chrille's Avatar
    Join Date
    Jul 2006
    Posts
    389
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    -1 means the Loop will run until it's stopped by code. If an infinite Loop is never stopped, the game will crash. Loops always start at Index 0, so if you choose to run a Loop times the number of Items in a List, and the List uses a 1-based Index, it won't check all the Items. So the code-example here would work with either type of list.

    For example, say a List has 10 Items, Index 1 to 10, and you choose to run the Loop 10 times. Then the Loop will start at Index 0 and stop at Index 9. So when you use 'Get Line (LoopIndex)', it means the loop is already finished before it checks Item 10. You can, however, use 'Get Line (LoopIndex +1)' and it will work.


    As for any issues with IDs, well, it's hard to say since I'm not sure exactly how your code looks. So all objects in frame 1 will get an ID of 11, 12, 13 etc?
    If that were the case, the only issue would be, if for example an ID is 112. That could just as well be frame 1, object 12 as frame 11, object 2.

  6. #6
    Clicker Fusion 2.5
    Fusion 2.5 (Steam)Fusion 2.5 Developer (Steam)Android Export Module (Steam)HTML5 Export Module (Steam)iOS Export Module (Steam)
    kirkmet's Avatar
    Join Date
    May 2014
    Posts
    125
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Have you considered "Find string in string"?

  7. #7
    Clicker Fusion 2.5Fusion 2.5+ DLCAndroid Export ModuleiOS 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)
    blurymind's Avatar
    Join Date
    Feb 2014
    Location
    Huddersfield, United Kingdom
    Posts
    493
    Mentioned
    6 Post(s)
    Tagged
    0 Thread(s)
    if that would be more efficient than running a loop.

    I am actually considering doing it with an array, but I am not sure how much it would add complexity to the code and if it would be worth it.
    I cant believe that nobody made an example of this using arrays. At least I couldnt find one

  8. #8
    Clicker Fusion 2.5Fusion 2.5+ DLCAndroid Export ModuleiOS 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)
    blurymind's Avatar
    Join Date
    Feb 2014
    Location
    Huddersfield, United Kingdom
    Posts
    493
    Mentioned
    6 Post(s)
    Tagged
    0 Thread(s)
    As for any issues with IDs, well, it's hard to say since I'm not sure exactly how your code looks. So all objects in frame 1 will get an ID of 11, 12, 13 etc?
    If that were the case, the only issue would be, if for example an ID is 112. That could just as well be frame 1, object 12 as frame 11, object 2.
    yeah that is exactly how it generates the Ids at the moment. You are right it will cause problems!
    I am wondering how to get around this. Maybe create a list for each individual frame instead? It will end up having lots of list files.

    Maybe I really should try another approach to this. Any idea how to do it with arrays?
    x=id
    y=frame number
    x coordinate+y coordinate= finds z value

    z=state(0=dead, 1=alive, 2,3,4 and so on could be its health)

    These could be dynamically fed into the right values of game objects on start of frame

  9. #9
    Clicker Fusion 2.5Fusion 2.5+ DLC
    casleziro's Avatar
    Join Date
    Mar 2013
    Location
    United States
    Posts
    654
    Mentioned
    14 Post(s)
    Tagged
    0 Thread(s)
    Since I can't ever seem to give simple solutions to things, be prepared to dive headfirst into something a bit complicated :P

    I would recommend a string array for this. Basically you need to think about this from a level editor perspective: Every time you place an enemy with your editor, you write all of their data to a string in the cell. All you need to do to test whether or not the enemy will spawn is add a 0 or a 1 boolean (for simplicity) somewhere in the string and check it upon creation. Then when you need the enemy to de-spawn you would just directly modify their string at runtime by snipping the flag off and adding a different value.

    Using a string array is all well and good in theory, but if you want to save positions and retrieve them properly it can get hard to actually figure out how to handle retrieving the proper values from a string that will have varying length (due to position changes, larger values, etc). A way I use to overcome this is to force mmf2 to write my values with additional number places in the string, so it is always the same length no matter what (i.e instead of writing 15 as the X position it would be written as 0015, and if the 15 increases to 3 #places it would be written as 0115). This can be a tedious process but definitely makes things easier on you in the long run since all you have to do is set these rules up once and then forget about them.

    The formula for forcing strings to have more spaces is Left$("000000000", #TOTAL PLACES - Len(STRING ) ) +STRING . The many 0's there at the beginning flood the string so there are just tons of 0's before your number, and the #Total Spaces will clip the excess off. For example: Left$("000000000", 3 - Len("15" ) ) +"15" will = "015". Now that you have the formula you can use an alterable value to dynamically alter the number of places, and you will want a string on hand to add the little snippets into one big master string that is written to the array. You would later retrieve substrings of a specified length from the master string's cell using the Mid$ function.

    Since this is all pretty confusing to talk about, I made a very basic example about writing stuff like this to the array and loading it, since I can't be bothered to actually make an entire level editor for you: https://www.dropbox.com/s/7fv2g49ub8...tring.mfa?dl=0

  10. #10
    Clicker Fusion 2.5Fusion 2.5+ DLCAndroid Export ModuleiOS 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)
    blurymind's Avatar
    Join Date
    Feb 2014
    Location
    Huddersfield, United Kingdom
    Posts
    493
    Mentioned
    6 Post(s)
    Tagged
    0 Thread(s)
    Hi casleziro,
    Glad to hear from you

    I decided to redo it as array, but a bit simpler than your example.
    x=object ID coordinate
    y=value ID coordinate
    z=frame number

    Alterable value A (value ID=0) is reserved to store the object ID of each object, which will be needed for the X coordinate.

    at the start of frame- spread value ID to the 0-id (alterable value A) of all objects with the DATA qualifier.. 1 based ID (starts from 1- since the array is 1-based number array)
    ------------------------------------------------
    -start loop "write to array-valueID" (10 times - for the ten values each object has)
    -on loop "write to array-valueID" --> start "onEachObjectLoop-objectID" on objects with the DATA qualifier
    - on "onEachObjectLoop-objectID" --> write to array - get ValueByID (loopindex of "write to array-valueID"), x=loopIndex of "eachObjectLoop-objectID"+1, y=loopIndex("write to array-valueID"), z=frame number

    this successfully writes to the array file all of the values of all objects that have the DATA qualifier.
    ---------------

    I am however completely stuck on reversing the process - reading the values from the Array and writing them back to the object values.
    For some strange reason it deletes the ID value and reads (writes array to value) only on the first value

    This is where I need help, as I cant seem to get my array to properly write all the values to multiple objects with the data qualifier.

    Can someone help me with an example where an array X=object ID, y= value ID, z=frame ID, writes to all values of all objects in a frame.
    In this case I know I have to run a forEachLoop(loopindex=objectID) within a fastLoop (loopindex=valueID) to do it, but my syntax/conditions are obviously messed up. Fusion is not writing my array to the values properly. But it has no problem feeding them to the array object flawlessly by using the same logic.
    -------------
    on length of array - as Snail points out in one of his videos- the Array object extends its length automatically depending on what is fed to them ,if you set all of its values to 1.So I dont seem to have to deal with that aspect here.

Similar Threads

  1. Item list - find a line by string and delete it
    By blurymind in forum Fusion 2.5
    Replies: 8
    Last Post: 12th January 2015, 01:42 AM
  2. how do you check is specific item exists in list
    By blurymind in forum Fusion 2.5
    Replies: 11
    Last Post: 21st December 2014, 03:30 PM
  3. list item - specific input controls
    By blurymind in forum Fusion 2.5
    Replies: 8
    Last Post: 7th December 2014, 01:12 AM
  4. Random Item List
    By jotek in forum Multimedia Fusion 2 - Technical Support
    Replies: 4
    Last Post: 13th January 2009, 06:00 PM
  5. Next item on the check list.....
    By ZayLong in forum Multimedia Fusion 2 - Technical Support
    Replies: 4
    Last Post: 31st August 2008, 06:29 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
  •