Graphics

 View Only
  • 1.  XP positioning script

    Posted 07-31-2017 15:46
    Anyone got any idea why this script wont work...?

    dim aggscore as xpTextObject
    self.GetObjectByName("HomeAggscoreVIS", aggscore)
    dim par as xpTextObject
    self.GetObjectByName("HomePar", par)
    dim int as Integer
    int = CInt(aggscore.Text)

    if int < 10 then
    par.PosX = 452.25
    end if

    if int > 10 then
    par.PosX = 441.25
    end if


  • 2.  RE: XP positioning script

    Posted 07-31-2017 19:56
    Code looks fine.. You'd need to upload the scene so we could figure out the answer; it may not be in your script. Maybe you have an object spelled incorrectly or something.
    #XPression


  • 3.  RE: XP positioning script

    Posted 08-01-2017 10:40
    The script is on the "Homescore" textobject in OnSetText.

    The 1.4 MB project file can be downloaded here: [URL="https://fil.email/X6eyKJdO"]https://fil.email/X6eyKJdO

    ;)[/URL]


    #XPression


  • 4.  RE: XP positioning script

    Posted 08-01-2017 13:49
    Looking at the script and project it looks like you are trying to move the Bracket over when the Agg score is over 10.. Why don't you eliminate the script entirely and just add the bracket into the Agg Score using visual logic? Use the string concatenate block to add a parenthesis to the beginning of the Aggregate Score. That way it will automatically position itself when the score goes over 10?


    #XPression


  • 5.  RE: XP positioning script

    Posted 08-01-2017 13:52
    There is nothing wrong with your script but the script is using the HomeAggScoreVIS text object which is being updated by Visual Logic, which doesnt run until after the OnSetText script has run. You should move your script from the HomeScore object to the HomeAggScorVIS object but I think you will still have some issues. Adding the brackets in visual logic will be way easier.

    #XPression


  • 6.  RE: XP positioning script

    Posted 08-02-2017 07:10
    I had the same issue trying to put the script on the other text object, and I've tried running the scene without the score being updated by visual logic or widgets.
    Ended up using the string concatenate now, but the reason I wanted to script it is that the next time I might want to position something other than a text object.

    Thanks :)
    #XPression


  • 7.  RE: XP positioning script

    Posted 08-02-2017 11:04
    The positioning could be done much easier in Visual Logic as well. If you wanted to position the Parenthesis text object to the left of the aggregate score.
    (assuming the aggregate score is set to Center Justify, and Parenthesis is set to Left Justify).

    Take the AggScore position, subtract half of its scaled bounding box width, subtract the bounding box width of the parenthesis object, and feed it into the parenthesis PositionX.
    The reason for subtracting the widths is that the X Position of an object is based on where it's Pivot Point is located within the object. When set to Left Justify the pivot point will be on the left edge of the text object; and when set to Center Justify the Pivot Point is right in the middle of the object (that's why we subtract half the width).

    #XPression