Author Topic: Console code that changes all brick ownership to certain ID  (Read 1892 times)

I'd like to type something in console to switch brick ownership of all bricks from ID 47704 to ID 48284. How to do this?

Copy this: for(%i=Brickgroup_47704.getCount()-1;%i>=0;%i--)Brickgroup_48284.add(Brickgroup_47704.getObject(%i));

Type this: eval(getClipboard());


If it's on another computer, then you'll have to type the first codelet directly.
« Last Edit: October 12, 2014, 04:41:15 AM by Xalos »

Copy this: for(%i=Brickgroup_47704.getCount();%i>=0;%i--)Brickgroup_48284.add(Brickgroup_47704.getObject(%i));

Type this: eval(getClipboard());


If it's on another computer, then you'll have to type the first codelet directly.
Shouldn't you also change the brick's client and stack BL ID?

for(%i=Brickgroup_47704.getCount();%i>=0;%i--){%b=Brickgroup_47704.getObject(%i);%c=findClientByBL_ID(48284);Brickgroup_48284.add(%b);%b.client=%c;%b.stackBL_ID=%c.BL_ID;}


Why?
Because it's easier to type than for(%i=Brickgroup_47704.getCount();%i>=0;%i--)Brickgroup_48284.add(Brickgroup_47704.getObject(%i));

Shouldn't you also change the brick's client and stack BL ID?

for(%i=Brickgroup_47704.getCount();%i>=0;%i--){%b=Brickgroup_47704.getObject(%i);%c=findClientByBL_ID(48284);Brickgroup_48284.add(%b);%b.client=%c;%b.stackBL_ID=%c.BL_ID;}

There's really no reason to call findClientByBL_ID every iteration of that loop.

%c=findClientByBL_ID(48284);while(BrickGroup_47704.getCount()>0){BrickGroup_48284.add(%b=BrickGroup_47704.getObject(0));%b.client=%c;%b.stackBL_ID=%c.BL_ID;}



Also, with Xalos' and Jes' code, you're actually going to want to make the for statement for(%i=BrickGroup_47704.getCount()-1;%i>=0;%i--) because setting %i to the size of the group will cause the first iteration to error.
« Last Edit: October 12, 2014, 12:14:25 AM by $trinick »

%c=findClientByBL_ID(48284);while(BrickGroup_47704.getCount()>0){BrickGroup_48284.add(%b=BrickGroup_47704.getObject(0));%b.client=%c;%b.stackBL_ID=%c.BL_ID;}
There is about a 50% chance that the game will crash with the error "Local variable used in global scope" if you do this.

Mm I believe that bug only exists when you use the external console. Use the one you get by pressing ~ or copy it and use eval(getClipboard()); as Xalos suggested and you should be good.

Shouldn't you also change the brick's client and stack BL ID?
Once you get into changing the stack BL_ID you have to do it for every brick in every brickgroup.  It's essentially who owns the brick this brick rests upon, so it can be different from the person who can actually owns it.

Also, with Xalos' and Jes' code, you're actually going to want to make the for statement for(%i=BrickGroup_47704.getCount()-1;%i>=0;%i--) because setting %i to the size of the group will cause the first iteration to error.
Oh, nice catch.

Because it's easier to type than for(%i=Brickgroup_47704.getCount();%i>=0;%i--)Brickgroup_48284.add(Brickgroup_47704.getObject(%i));
Ok sure
But pasting the for loop would be even easier
« Last Edit: October 12, 2014, 10:19:08 AM by Headcrab Zombie »

Ok sure
But pasting the for loop would be even easier

Can't paste directly into console.  You also can't eval it directly because I'm an idiot and used local variables.

So the right way to do it would be to copy for($i=Brickgroup_47704.getCount()-1;$i>=0;$i--)Brickgroup_48284.add(Brickgroup_47704.getObject($i)); and then enter eval(getClipboard());

Can't paste directly into console.
I can paste directly into the console just fine
Never had a problem
« Last Edit: October 12, 2014, 10:47:06 AM by Headcrab Zombie »

I can paste directly into the console just fine
Never had a problem

This.. lol..

I can paste directly into the console just fine
Never had a problem

With the dedicated console, you can either right click on the window status bar and navigate to the Edit submenu, or you can type in eval(getClipboard());.  Unless you can't type with any speed, the latter method is always going to be faster.

With the dedicated console, you can either right click on the window status bar and navigate to the Edit submenu, or you can type in eval(getClipboard());.  Unless you can't type with any speed, the latter method is always going to be faster.
I can type just fine
The time difference (if any) between the two is trivial, so it's more a matter of preference.
Don't tell people you can't paste into console just because you prefer a different method