User Tag List

Page 1 of 2 1 2 LastLast
Results 1 to 10 of 13

Thread: [Beta] Func Object : Call Functions via Expression or Action

  1. #1
    Clicker Install Creator Pro
    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)
    defisym's Avatar
    Join Date
    Jun 2017
    Location
    Asia
    Posts
    506
    Mentioned
    12 Post(s)
    Tagged
    0 Thread(s)

    [Beta] Func Object : Call Functions via Expression or Action

    Func Object



    Description

    This object allows you to call functions via expression or action, make it much easier to do some quick calculations.
    This extension couldn't be done without the help of Yves.

    Release page
    Source code

    Doc

    Make calculation easier

    Tired about add many temp alterable values that only use once to calculate something by fastloop? Func object is born for this : pass values directly, create any temp params you like(will be erased after func return), and get return value directly.



    Note : Func object is much slower than fast loop. In test case (run example in picture 1000 times), fastloop costs about 1ms, func object costs about 170ms.

    Free and open source

    If you find some issues or have a new idea, you can modify the source code directly, and don't need to wait for author to make an update.

    A/C/E List

    Code:
    - Action
      - Call Func
      - Call Func (Ternary)
    
      - Loop
        - Set Func's LoopIndex
        - Stop Func Loop
    
      - Temp Param
        - Set Func's Temp Param
        - Set Current Func's Temp Param
    
      - Return Value
        - Set Current Func's Return
        - Set Current Func's Return Value
        - Push Current Func's Return Value
        - Pass Prevous Func's Return
    
    - Condition
      - On Func
    
      - Validity
        - Return
          - Previous Func Has Return At
        - Param
          - Curernt Func Has Param At
        - Temp Param
          - Func Has Temp Param
          - Curernt Func Has Temp Param
    
    - Expression
      - Call Func
        - Call Func (return value)
        - Call Func (return string)
    
      - Ternary
        - Ternary (return value)
        - Ternary (return string)
    
      - Get Param
        - Get Current Func's Param (return value)
        - Get Current Func's Param (return string)
    
        - Get Current Func's Number of Params
    
      - Get Temp Param
        - Get Func's Temp Param (return value)
        - Get Func's Temp Param (return string)
    
        - Get Current Func's Temp Param (return value)
        - Get Current Func's Temp Param (return string)
    
      - Get Return
        - Get Previous Func's Return Value (return value)
        - Get Previous Func's Return Value (return string)
    
        - Get Previous Func's Number of Return Values
    
      - Get Index
        - Get Func's LoopIndex
        - Get Func's Recursive Index
    
      - Get Current FuncName
    ============

    This object is beta so it must be buggy, if you find any issue, feel free to post it here, or open an issue on Github, I will try to fix it if it's not beyond my ability as a rookie.

    Enjoy!


  2. #2
    Clicker Install Creator Pro
    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)
    defisym's Avatar
    Join Date
    Jun 2017
    Location
    Asia
    Posts
    506
    Mentioned
    12 Post(s)
    Tagged
    0 Thread(s)
    Known Issue

    Return a blank string when retrieving return value from a nested expression in func's action (while you can get it's return value properly if store it with an alterable value)




  3. #3
    Clicker Install Creator Pro
    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)
    defisym's Avatar
    Join Date
    Jun 2017
    Location
    Asia
    Posts
    506
    Mentioned
    12 Post(s)
    Tagged
    0 Thread(s)
    Did some optimization, now Func is just 7X~8X slower than fastloop (run 100,000 times).

  4. #4
    Forum Moderator Fusion 2.5 MacFusion 2.5 DeveloperFusion 2.5+ DLCAndroid Export ModuleHTML5 Export ModuleiOS Export ModuleFirefly 3D Module
    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)Mac Export Module (Steam)Universal Windows Platform Export Module (Steam)Firefly 3D Module (Steam)
    NaitorStudios's Avatar
    Join Date
    May 2010
    Location
    Brazil
    Posts
    1,341
    Mentioned
    9 Post(s)
    Tagged
    0 Thread(s)
    Amazing work! I hope you can use DarkEdif's multitarget to export for Android/iOS as well!

  5. #5
    Clicker Install Creator Pro
    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)
    defisym's Avatar
    Join Date
    Jun 2017
    Location
    Asia
    Posts
    506
    Mentioned
    12 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by NaitorStudios View Post
    Amazing work! I hope you can use DarkEdif's multitarget to export for Android/iOS as well!
    Thanks.
    I will try to port it next year when I have plenty time to do so...

  6. #6
    Clicker

    Fusion 2.5 MacFusion 2.5 DeveloperFusion 2.5+ DLCAndroid Export ModuleHTML5 Export ModuleiOS 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
    298
    Mentioned
    14 Post(s)
    Tagged
    0 Thread(s)
    Awesome extension Defisym

    Are you comparing writing to a value (FL) with writing to a string (Func)?

    If so maybe try comparing FL val vs Func val, FL string vs Func string

  7. #7
    Clicker Install Creator Pro
    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)
    defisym's Avatar
    Join Date
    Jun 2017
    Location
    Asia
    Posts
    506
    Mentioned
    12 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by fnkycoldmadeanr View Post
    Are you comparing writing to a value (FL) with writing to a string (Func)?
    If so maybe try comparing FL val vs Func val, FL string vs Func string
    That's beacuse currently all data in func is stored by string, and ext will do the conversion every time when you trying to retrieve a value.
    I will try to do some optimizations later this week, to let user set value directly, and only do the conversion once when needed.

  8. #8
    Clicker Install Creator Pro
    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)
    defisym's Avatar
    Join Date
    Jun 2017
    Location
    Asia
    Posts
    506
    Mentioned
    12 Post(s)
    Tagged
    0 Thread(s)

    Lightbulb Update: Func B211106

    Release
    - Release Page

    Summary
    - Func is 40X faster than last release!
    - Now it's just 5X slower than fastloop: which means you could use it anywhere you like and don't need to worry about profermance impact in most cases.





    - Test case runs 100000 loops, measured by fusion's built in profiler, fastloop takes 86.249ms, func(same data type) takes 403.549ms, func(do str->number conversion) takes 662.872ms

    Optimise
    - Use substr instead of regex to parse params
    - Use per-char loop to convert string to number instead of `std::stof`
    - Use per-char loop instead of regex to check if a string can be converted to number
    - Reserve space for vector/map
    - Only do data type conversion once when needed and save the result for future use
    - Only check String is number once and save the result for future use

    DataType
    - Now func will save params as both float/string instead of string only
    - Use correct data type to get rid of conversions to squeeze more profermance (1.5X faster in test case below)





    - Func params are always saved as string due to the limitation of Fusion expression (don't support variable argument)

    New Condition
    is Number
    - check if a param can be converted to a number, using the same convert algorithm
    - note : please check validity before using this condition

    Return
    - Previous Func's Return At...is Number

    Param
    - Curernt Func's Param At...is Number

    Temp Param
    - Func's Temp Param is Number
    - Curernt Func's Temp Param is Number

  9. #9
    Clicker Fusion 2.5 Mac
    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)

    Join Date
    Jan 2015
    Location
    Australia
    Posts
    290
    Mentioned
    14 Post(s)
    Tagged
    0 Thread(s)
    damn, from 170x to to 5x, those are some incredible improvements. very much looking forward to checking this out!

  10. #10
    Clicker Install Creator Pro
    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)
    defisym's Avatar
    Join Date
    Jun 2017
    Location
    Asia
    Posts
    506
    Mentioned
    12 Post(s)
    Tagged
    0 Thread(s)
    Hi, @Yves
    Sorry to bother. As 294 is finally released, maybe you could spare some time to check this?

    If call events in an expression, and nest them, return value from child ones will be messed. For strings, the return become blank, and for float, return will be a random value. As the value type return is random, maybe it’s due to incorrect pointer offset?



    There is an example that shows the issue:

    FuncNestIssue.mfa

    By the way, is there a way to save the scope state before immediate event call then restore it later? Although it will cost a lot, but it’s useful sometimes. Besides to iterate oil and save the selected object offset chain, there is also values need to be saved, e.g., the one that indicates the iterate process to perform events to all selected objects. But IDK which one is involved and which one is necessary.

    Besides, I know it’s off topic, is there any tutorials or documents about the usage of HWA surface? I tried to implement “addBackdrop” with scale & shader, by blitex hwa source to a render target to do it with hardware acceleration, then blit that target back to a bitmap surface, and add bitmap to backdrop. The issue is sometimes fusion may freeze, or behaves differently in DX9 and DX11:

    https://community.clickteam.com/threads/109573-Tutorials-for-HWA-cSurface-usage

    The final question accumulated these months is, how to change one object’s shader params by extension? Just like event does.

    Many thanks in advance…

Page 1 of 2 1 2 LastLast

Similar Threads

  1. How to call JavaScript functions ?
    By janpier in forum HTML5 Export Module 2.5
    Replies: 7
    Last Post: 4th December 2019, 11:54 AM
  2. Is there a way to call a sound from an expression?
    By mobichan in forum Fusion 2.5
    Replies: 4
    Last Post: 28th December 2016, 01:34 PM
  3. Flash Func Loop
    By Mephistus in forum SWF/Flash Export Module Version 2.0
    Replies: 2
    Last Post: 26th April 2012, 08:33 PM
  4. Windows Functions Object Beta Release
    By Tim in forum File Archive
    Replies: 9
    Last Post: 5th November 2010, 01:01 PM
  5. List of functions in the expression editor?
    By Vetebullen in forum Multimedia Fusion 2 - Technical Support
    Replies: 5
    Last Post: 12th July 2008, 05:05 AM

Posting Permissions

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