How to change the size,position, transparency of an object with scripting

  • #1, by AkcayKaraazmakFriday, 21. November 2014, 13:50 10 years ago
    Hi guys,

    1-) how I can scale the oblect size and also the transparency of an object with code? I tried this by execute script comment but didnt work :\

    local box2 = Scenes.SceneObjects.box
    box2.ObjectScale = 3.0
    box2.ObjectVisibility = 0

    2-) How can I change the position and of an object with script. I tried this code but it doesnt work

    local box2 = getObject("Scenes[box]")
    box2:setValue(ObjectPosition, {x=400,y=200})
    box2:setValue(ObjectVisibility, 0)


    Cheers smile

    Great Poster

    440 Posts


  • #2, by afrlmeFriday, 21. November 2014, 15:03 10 years ago
    Scenes.SceneObjects will not work. It has to be...
    Objects.object_name.Scale = 3.0 -- or
    Objects["object_name"].Scale = 3.0 -- or
    getObject("Scenes[scene_name].SceneObjects[object_name]"):setValue(VObjectScale, 3.0) -- or
    getObject("Game.GameCurrentScene.SceneObjects[object_name]"):setValue(VObjectScale, 3.0)
    

    ...mind that using shorthand for accessing objects requires that each object has a unique name. & as always: names are case sensitive.

    Object positon is the position the current character will walk to when executing actions on said object. It is not scriptable. You can use the ObjectOffset but I recommend creating the objects image as an animation instead & moving the animation with...
    ActiveAnimations["animation_name"].AnimationCurrentPosition = {x = 400, y = 200}
    

    ...because animations can be set directly to coordinates whereas objects use offset which is confusing. To easily use offset the object should add the image to the object & leave the object in the initial position it was created in which would be 0, 0 & then use that to base your offset off otherwise it gets really complicated because offset always starts at 0 regardless of object position.

    Imperator

    7278 Posts

  • #3, by AkcayKaraazmakFriday, 21. November 2014, 17:02 10 years ago
    A very big thank you Lee!!! smile

    Great Poster

    440 Posts

  • #4, by nenad-asanovicTuesday, 21. November 2017, 18:51 6 years ago
    I know this is Old post but I was needing something like this and this works perfectly. Now only thing that I am interested is there a way to avoid "object_name" and replace it with saved object name? I have scene with tons of objects and would make my day easier if I don't have to type all their names each time I call this script... Thanks in advance smile

    Newbie

    59 Posts

  • #5, by sebastianTuesday, 21. November 2017, 19:54 6 years ago
    I know this is Old post but I was needing something like this and this works perfectly. Now only thing that I am interested is there a way to avoid "object_name" and replace it with saved object name? I have scene with tons of objects and would make my day easier if I don't have to type all their names each time I call this script... Thanks in advance smile
    then just use a variable inside the brackets and define it somewhere before:

    object = "table"
    Objects[object].Scale = 3.0 

    Thread Captain

    2346 Posts

  • #6, by nenad-asanovicTuesday, 21. November 2017, 20:21 6 years ago
    That was quick. Thank you. Works perfectly smile

    Newbie

    59 Posts

  • #7, by constantinWednesday, 31. January 2018, 13:31 6 years ago
    how can i change the opacity of animations?

    Forum Fan

    167 Posts

  • #8, by sebastianWednesday, 31. January 2018, 13:40 6 years ago
    would be only possible when you change the object opacity where the animation is bound to.

    i remember that there is an action part for this. 

    also possible in lua:

    Objects["name"].Visibility = 76

    0-100 are accepted. 

    Thread Captain

    2346 Posts

  • #9, by afrlmeWednesday, 31. January 2018, 16:02 6 years ago
    I think it only works if the animation is linked as the default animation of a scene object so that it automatically plays at the start of the scene / whenever the object is shown. I don't believe it's possible to change the opacity of manually started animations.

    Having said that, you could always create an animation as a character. Disable scaling in the properties for the character & insert the character into the scene as you can change the opacity of characters. Same goes with interfaces.

    Imperator

    7278 Posts

  • #10, by constantinThursday, 01. February 2018, 06:57 6 years ago
    thank you - i just found out the same thing. great support here! thank you.

    Forum Fan

    167 Posts