Login / Registrieren
DE EN FR ES IT CZ
Zurück Nach oben

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

  • #1, by AkcayKaraazmak 12 years ago Zitieren
    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
  • #2, by afrlme 12 years ago Zitieren
    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.
  • #3, by AkcayKaraazmak 12 years ago Zitieren
    A very big thank you Lee!!! smile
  • #4, by nenad-asanovic 8 years ago Zitieren
    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
  • #5, by sebastian 8 years ago Zitieren
    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 

  • #6, by nenad-asanovic 8 years ago Zitieren
    That was quick. Thank you. Works perfectly smile
  • #7, by constantin 8 years ago Zitieren
    how can i change the opacity of animations?
  • #8, by sebastian 8 years ago Zitieren
    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. 
  • #9, by afrlme 8 years ago Zitieren
    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.
  • #10, by constantin 8 years ago Zitieren
    thank you - i just found out the same thing. great support here! thank you.