Graphics

 View Only
  • 1.  Scripting Position Change Based on Text Object Driven by Widget

    Posted 06-12-2024 10:29
    Alright, so as the title says I have a text object "BatOrd" within my scene that is being changed by a Text List Widget. Based on the number within the text list I want the Y position of my quad object "Highlight" to change. I have done this previously in a different project with Visual Logic but for some reason it is causing Xpression to crash in this one so I wanted to try approaching differently and scripting it to see if that would work. Here is my code of an If...Then...Else statement that I thought would work. It is compiling but not executing. I have tried putting it on "OnOnline" "OnPrepare" and "OnSetText" of the Text Object "BatOrd". I have also tried spot.AsString and spot.Text. What am I missing? 



    ------------------------------
    Avery Cook
    Freelancer
    Omaha United States
    ------------------------------


  • 2.  RE: Scripting Position Change Based on Text Object Driven by Widget

    Posted 06-12-2024 12:33

    spot.Text = whatever

    also, using an Array would be more succinct



  • 3.  RE: Scripting Position Change Based on Text Object Driven by Widget

    Posted 06-12-2024 16:04

    What Azathoth said!

    Also I would avoid using OnRender if you can.

    Anytime you find yourself using a script in OnRender you should stop and I think "Could I do this with visual logic instead?" 




  • 4.  RE: Scripting Position Change Based on Text Object Driven by Widget

    Posted 06-13-2024 11:29

    Hi Garner, do you mind explaining why re OnRender vs VL? 



    ------------------------------
    Carlito Chippy
    ------------------------------



  • 5.  RE: Scripting Position Change Based on Text Object Driven by Widget

    Posted 06-19-2024 10:05

    OnRender and visual logic both execute on every frame render. So every 16ms-32ms. 

    Visual Logic has been developed specifically to operate this way. Visual logic is integrated into XPression so that it can't stall the render pipeline. 

    OnRender lets you do anything that the XPression script engine can do. Which means you can end up doing things that could cause the render pipeline to stall. Sometimes OnRender scripts can also negatively affect the performance of a scene, because the script in OnRender takes the engine a long time to run (long time being 16ms+), for whatever reason. 

    Its hard to give specific rules or guidelines about OnRender, because it will work, until it doesn't. 

    Generally I would try to avoid making and Engine.Whatever calls in OnRender. 




  • 6.  RE: Scripting Position Change Based on Text Object Driven by Widget

    Posted 06-19-2024 10:50

    Hi Avery,
    the answers to your issue are already given. Anyhow there might be circumstances where there is no way to avoid to use the OnRender event.
    As Garner said whenever you can avoid it you should do it.

    Situations where you cann not avoid to use On_Render might appear, if you need information from other scenes.

    What you should do is programming your code with an archtitecure of "Early Exit". This means that you exit your sub as early as possible so that not the complete code needs to be proceeded.
    For your case you should alos use "Select case" rather than "if then else" because this is much faster in execution.



    ------------------------------
    Tom Lehmann
    CEO
    IT Services
    Frankfurt/Main Germany
    ------------------------------