abouffard
Registered:1496269110 Posts: 14
Posted 1502919821
Reply with quote
#1
Is it correct to assume that when the players destroy a target with weapons, that it ceases to exist in the game and using if_exists on that target will return "false" for that target object?
Mike Substelny
Administrator
Registered:1375273622 Posts: 2,990
Posted 1502980970
Reply with quote
#2
Yes, that is correct for the most part. There are two caveats:You need to know the name of the object to check to see if it exists. You can't do it with a randomly created name. Artemis has no problem maintaining two objects with exactly the same name. In this case all logical checks, including if_exists, will be checking the one that was created first.
__________________"The Admiralty had demanded six ships; the economists offered four; and we finally compromised on eight." - Winston Churchill
ryleyra
Registered:1399599588 Posts: 3,214
Posted 1502996991
· Edited
Reply with quote
#3
Quote:
Originally Posted by
Mike Substelny Artemis has no problem maintaining two objects with exactly the same name. In this case all logical checks, including if_exists, will be checking the one that was created first. I assume this is only if both objects exist. If the first object created is subsequently destroyed, I'm assuming the second object with the same name will be returned in all cases, including if_exists. While I wasn't aware of this feature, it does make things easier. You can create a bunch of objects with the same name and then modify and rename them one by one, even if some of them are subsequently created while the rename is taking place. I've always tried to ensure my code creates an object, renames it, and only then creates a new object with the reused name, to avoid this problem. It's nice to know I don't have to do that.
Mike Substelny
Administrator
Registered:1375273622 Posts: 2,990
Posted 1503067712
Reply with quote
#4
Quote:
Originally Posted by ryleyra I assume this is only if both objects exist. If the first object created is subsequently destroyed, I'm assuming the second object with the same name will be returned in all cases, including if_exists.
Your assumption is correct. This means it doesn't matter much for if_exists since the check returns true when even one object with that name exists. But when you are checking a position, shield state, etc. the fact that you can only check the oldest instance of the object becomes important.Quote:
Originally Posted by ryleyra While I wasn't aware of this feature, it does make things easier. You can create a bunch of objects with the same name and then modify and rename them one by one, even if some of them are subsequently created while the rename is taking place. I've always tried to ensure my code creates an object, renames it, and only then creates a new object with the reused name, to avoid this problem. It's nice to know I don't have to do that.
Actually if you want to control any properties of that object such as maximum speed, shield strength, elite abilities, brain stack, etc. then you do need to create the object with a uniform name, change its properties, then reassign it a random name.
__________________"The Admiralty had demanded six ships; the economists offered four; and we finally compromised on eight." - Winston Churchill