Author Topic: Creating working bricks in script  (Read 1206 times)

So I've been out of BL for a while and I can't make bricks.
I've got a brick, set to isPlanted, I setTrusted, I plant() it, and it's got no collision and no "dot plus a number" in the mission editor.

I've tried the stuff referenced in this thread where red_guy talks about making sure it has a client and a brickgroup and I even give it a stack BLID but none of that makes any difference whatsoever.

Also while we're on the subject of getting stuff to work these days, when I'm prototyping I find it to be IMMENSELY helpful to reload the map, ideally without shutting down the server. Can that still be done? Because I would always change the map from the admin menu, and pick the map that was already loaded.

Also while we're on the subject of getting stuff to work these days, when I'm prototyping I find it to be IMMENSELY helpful to reload the map, ideally without shutting down the server. Can that still be done? Because I would always change the map from the admin menu, and pick the map that was already loaded.
How to restart the mission?

What is the exact code you're using?

It would be way, way, easier for someone to just give me an example of something working. I'm not some whippersnapper that needs handholding; if anyone knows how to plant bricks that work, just post something that works and I'll take it from there.

Code: [Select]
%brick = new fxDTSBrick() { datablock=brick1x1fdata; isPlanted=1; };
brickgroup_x.add(%brick);
%brick.setTrusted(1);
%brick.plant();

Just tried it, worked absolutely fine for me.


Also: if you're hosting a local server you can change the gamemode to renew the map. Otherwise you'll get disconnected, which is a annoying but it's faster than literally restarting.
« Last Edit: December 28, 2012, 11:44:30 PM by Trinick! »

OK great thanks

I still need to know how to reload the map, that would be really helpful.

One issue I have is that when closing the server all the brick datablocks get deleted, and defining new datablocks doesn't work without changing the map. If anyone knows how to reload the map without closing the server, that would be a HUGE time-saver so I don't need to mess with .zip files every time I want to do anything with brick datablocks. Or some other workaround that involves making the datablocks work (yes, I've tried transmitting them) or keeping the datablocks from being deleted. BL or RTB likes to crash if you set up a server with trace on so I'm hoping someone can save me a huge headache and knows already how to do spmething for this.
« Last Edit: December 29, 2012, 12:03:56 AM by Mr. Wallet »


That got me started, so thanks... but looks like changing the game mode technically closes the server and returns you to the main menu, instantly starting up a server with the new game mode before it has a chance to draw the menu on the screen.

I think it's curious how there has NEVER ONCE been a patch for BL that made life easier for modders, and usually quite the opposite. Badspot's a better troll than I'll ever be.

Anyway, when you change the game mode, it does this:
  • delete datablocks
  • deactivate packages
  • delete datablocks
  • deactivate packages

So I can't even package a thing to re-add the datablocks because that package gets turned off and then the datablocks get deleted again.

So here's the final workaround I came up with, in case anyone ever wonders how to get around this:
Code: [Select]
function DeactivateServerPackages()
{
//do nothing
}

package doNotDeleteMyDBs {
function onDatablocksDeleted()
{
Parent::onDatablocksDeleted();
exec("this selfsame file that the datablocks are also in");
}
};
activatepackage(doNotDeleteMyDBs);

I figured re-running packages was safer than re-running datablocks because I didn't know if it would have a stufffit at me for occupied namespaces or something. Obviously you can't switch between two complex gamemodes but if you're debugging and coding you're not doing that anyway. copy/pasting the above once is still faster than dealing with .zip files.

Also I found another "feature" of the new BL: bricks don't collide or work properly in general if their bottom is below height zero. This was the main problem with my brick creation code. This is a particularly soft spot for me because my #1 favorite thing to do in beta was to make a hole in the terrain and build underground; I was super-annoyed when BL retail was released and those bricks were disallowed for being "buried". Now I can't even have bricks script-planted to be even partially underground. I would post a picture of a reaction face if a human face could possibly convey the myriad emotions I am going through right now.

So, everything is solved. Well, as far as they can possibly be. Thanks.  :cookie:
« Last Edit: December 29, 2012, 01:20:23 AM by Mr. Wallet »

Overwriting the server cleanup seems like a very bad idea...

Wallet, for the same of indexing and searching, could you post the code that didn't work?

Also I found another "feature" of the new BL: bricks don't collide or work properly in general if their bottom is below height zero. This was the main problem with my brick creation code. This is a particularly soft spot for me because my #1 favorite thing to do in beta was to make a hole in the terrain and build underground; I was super-annoyed when BL retail was released and those bricks were disallowed for being "buried". Now I can't even have bricks script-planted to be even partially underground. I would post a picture of a reaction face if a human face could possibly convey the myriad emotions I am going through right now.
On a totally non-coding related note, that was, hands down, the coolest part of v0002. One of the things I remember the most about v0002 was going through some massive space base (might have been different, the memory is hazy) that was built inside RTB Island with the hill on RTB Island being the entrance.

Instead of restarting the entire server, just clear all the bricks and then load them again.

The main problem is defining or changing a brick datablock after the mission finishes loading. There's no way I've found to make that work without doing a new mission load. It's necessary for a lot of other stuff that you get up to when rapidly prototyping.