Jump to content


Photo

Duplicate instances in room


  • Please log in to reply
8 replies to this topic

#1 Iwitrag

Iwitrag

    GMC Member

  • New Member
  • 14 posts

Posted 03 March 2012 - 03:20 PM

Hey everyone :)

I have one little question...
Is there any way to duplicate instances in room?
Sometimes, I must create for example 50 instances with
same Instance creation room code
and it's really boring doing it mechanicaly with
right mouse button click on instance + CTRL -> creation code and CTRL+V.

Thanks for help!
  • 0

#2 thegame

thegame

    Flying Penguin

  • GMC Member
  • 1404 posts
  • Version:GM:Studio

Posted 03 March 2012 - 03:50 PM

If you want every single one in the room to have the same Creation Code, you can use the Room Creation code, and then
with(object) {
    //Put creation code here
}

If some are going to be different, you could probably do it with a more complicated version of this...
  • 1

#3 Iwitrag

Iwitrag

    GMC Member

  • New Member
  • 14 posts

Posted 03 March 2012 - 04:25 PM

No...
For example, in room there are 100 instances of object obj_gun...
obj_gun works with variable power, which it gets from room...

In room there are 50 instances of obj_gun with creation code power = 3; and 50 instances of obj_gun with creation code power = 5;

I just need to know, how can I duplicate instances in room editor (with their creation code)
  • 0

#4 thegame

thegame

    Flying Penguin

  • GMC Member
  • 1404 posts
  • Version:GM:Studio

Posted 03 March 2012 - 07:04 PM

Oh, you can't... sorry about that...
If the instances are in some way organized though, for example if the 50 obj_gun that have power 3 were on one side and the power 5 ones were on the other, you could do
with(obj_gun) {
    power = 3 + ((x > midPoint) * 2);
}
Otherwise you will have to do it manually, or make multiple objects, all with parent of obj_gun. Name them obj_gun_power_3 and obj_gun_power_5. In their creation event put power = 3; or power = 5; and all the rest of the code goes in the parent. Then place those objects in the room...
  • 1

#5 Iwitrag

Iwitrag

    GMC Member

  • New Member
  • 14 posts

Posted 03 March 2012 - 07:37 PM

It's a pity... okay, i'll try to automatize it...
Thanks anyway :thumbsup:
  • 0

#6 kupo15

kupo15

    GMC Member

  • GMC Member
  • 400 posts

Posted 03 March 2012 - 09:16 PM

Hey everyone :)

I have one little question...
Is there any way to duplicate instances in room?
Sometimes, I must create for example 50 instances with
same Instance creation room code
and it's really boring doing it mechanicaly with
right mouse button click on instance + CTRL -> creation code and CTRL+V.

Thanks for help!

Why are you using the creation code instead of the create event? It would be easier to just set your power in the create event and simply add the instances. You can also use the instance IDs to your advantage. Because the ID # goes up by 1 with every version, you can place all the power 3's first then the power 5's second. Then find the last ID # of the power 3's and use that in your create event code. For example:
If the ID of the first is 0 (which it isn't obviously) and you have 5 power 3s and 5 power 5s where ID 0-4 is power 3 and 5-9 is power 5, in the create code you can put like
if 5 > id {power = 3} else power = 5

Or like thegame said, if all the power 3's are clearly bunched and the power 5s are as well, you can use the coors of them. For example if power 3s are on the left of a 500 x 500 room then
if x < 250 {power = 3} else power = 5

Edited by kupo15, 03 March 2012 - 09:19 PM.

  • 0

#7 thegame

thegame

    Flying Penguin

  • GMC Member
  • 1404 posts
  • Version:GM:Studio

Posted 04 March 2012 - 12:13 AM

As kupo15 said, the IDs are definitely useful, but its really not that good of an idea for this kind of thing... If at any time you want to add another power 3 turret, you have to practically restart your room
  • 0

#8 kupo15

kupo15

    GMC Member

  • GMC Member
  • 400 posts

Posted 04 March 2012 - 01:39 AM

thats the only problem. But if he needs to add a couple then it wouldn't be that painful to add a creation code. I wonder if using instance number would be better than id? probably. I think GM keeps an order of when each instance was created. His only other option would be to just add another object for power 5 that is a child to power 3 and just change the create event

Edited by kupo15, 04 March 2012 - 01:40 AM.

  • 0

#9 Iwitrag

Iwitrag

    GMC Member

  • New Member
  • 14 posts

Posted 05 March 2012 - 06:07 PM

This way is really useless... it's much harder than making it "by hand"...

I have solved it - Towers are in a row, so I made loop, which checks from left to right all turrets in a row and set their attributes...
  • 0




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users