Replacing Objects

0 favourites
  • 14 posts
From the Asset Store
Hand-painted tiles, objects, animated objects, and background to build a colorful Mayan civilization environment.
  • In almost every situation when I want to replace an object in the script, and that line contains an expression using the object being replaced, I keep having to go in and manually change the name. I think it's better to automatically rename the expression object of the same name as well by default. Thoughts?

  • Already in ... Right click on the action to remplace the object in it ... you can even replace conditions ...

  • That's not what I'm asking for. You never noticed the word "expression" I think.

  • Not necessary. Take a look at this example

    SpriteA -> set height to SpritA.Height + 10

    but You want to change it to

    SpriteB -> set height to SpritA.Height + 10

    Sometimes You want to change only an object but keep expression intact.

    For what You want You could use

    SpriteA -> set height to self.Height + 10 - that way expression will be valid for any replaced object.

  • Well, sorry, but I've never seen a reason to keep the same object name for a different object (I think your example is a little contrived from reality ;) ). Anyhow, I guess 'Self' is better practice actually, I completely forgot about that! LOL. ;)

  • (I think your example is a little contrived from reality ;)

    Actually it's not. It all depends what are You developing/prototyping.

    And btw that example, I used that few hours ago ;)

  • Try Construct 3

    Develop games in your browser. Powerful, performant & highly capable.

    Try Now Construct 3 users don't see these ads
  • You may have, but I'm sure 98% of the time it's not the case. ;) I think it's better to change the names by default and let the developer change it back, since that's the expected result in probably 98% of the cases. But, that's probably a moot point now since best practice is probably to use "Self". ;)

  • Construct 2 already does this. I just checked, and it does update the names of objects in expressions when replacing.

  • You mean when right clicking an action and selecting "replace object"? Didn't work for me.

  • Yeah, it worked for me. Can you provide a specific example of it not working? (Share a .capx and say which event to replace object on)

  • Ok, this may be a bug actually. Consider this (taken from the 3D game I just posted in the arcade):

    +Tree -> Set TransformedX to Tree.WorldX - CameraX

    This renames ok (if I copy and rename it to the "Grass" sprite object), however ...

    +Tree -> Set TransformedZ to WorldDepth - f.Call("RotateZYForZ", distFromHorizon, Tree.TransformedY, WorldTilt)

    ...does not. It would seem that parameters are ignored. ;) Seems like somewhat inconsistent behavior.

    Edit: Again, before anyone calls me out on this, yes, best practice is to use "Self". I just figure consistent behavior is also good to maintain. ;)

  • Yeah, it worked for me. Can you provide a specific example of it not working? (Share a .capx and say which event to replace object on)

    I'v noticed yesterday that it's doing it but not always... On my project it's a bit random. Sometimes it's only changing an Action object and sometimes Action object and object in expression. Unfortunately can't reproduce it in new projects.

  • OK, I think I can reproduce a problem with parameters to the Function.Call expression. As far as I can tell no other expressions are affected. Is this what you're seeing?

    You should report this type of thing to the Bugs forum; I don't always have time to check every thread so I might have missed this, but I always check everything in the bugs forum.

  • Actually this started out as a request, which turned into a bug. LOL. ;) np

Jump to:
Active Users
There are 1 visitors browsing this topic (0 users and 1 guests)