Author Topic: Sending a player to a named brick with a slash command.  (Read 1414 times)

How can I make a simple slash command to send a player to a named brick? Get ready to be impressed, I've gotten as far as:

function serverCmdShop(%client) {
   
}


So how do I fill in that blank? As you can guess, this is to send players to a shop, so you can guess that ownership and the like shouldn't be an issue.

function serverCmdShop(%this) //I just like using %this
{
   if(!isObject(%pl=%this.player)) //Does the player exist?
      return;
   %pl.setTransform(_BrickName.getTransform());
}


depending on your use, you may want to do some math to make the player not spawn inside the brick, but on top of it

it'd probably be as simple as spawning them two units higher, but idk if that's the best way to go about it
-snip dumbcode-

ofc this doesn't prevent the player from spawning inside other bricks
« Last Edit: January 05, 2014, 04:06:00 PM by otto-san »

I'm pretty sure it depends on the dimensions of the brick, as the transform is (iirc) the position of the exact centre of the brick.

I'm pretty sure it depends on the dimensions of the brick, as the transform is (iirc) the position of the exact centre of the brick.
rightrighrightright that's the part that didn't seem right

ignore what i posted

Would this snippet work to move the player atop a brick instead of inside?
%player.settransform(vectoradd(%obj.getposition(),%offset) SPC getwords(%player.gettransform(),3,6));
(Grabbed from the setPlayerTransform event, getTransform is another bit in there that would be needed too i guess)
« Last Edit: January 05, 2014, 05:28:43 PM by RagnaTheBroedge »

Assuming offset was set correctly, then it should.

You can calculate %offset using the brick's datablock's brickSizeZ variable. Note that its in studs, so a 1x1 brick would have a Z size of 3, but its 0.6 torque units high (I think, on the top of my head). Just divide the value by 5 to convert it into real units, and then of course half that again to calculate the difference from the center of the brick to the top, so overall divide by 10.

You can calculate %offset using the brick's datablock's brickSizeZ variable. Note that its in studs, so a 1x1 brick would have a Z size of 3, but its 0.6 torque units high (I think, on the top of my head). Just divide the value by 5 to convert it into real units, and then of course half that again to calculate the difference from the center of the brick to the top, so overall divide by 10.

You're overcomplicating it way too much.

vectorAdd(setWord(<brick>.getPosition(), 2, getWord(<brick>.getWorldBox(), 5)), "0 0 0.1")

If you want to include rotation, add SPC getWords(<brick>.getSpawnPoint(), 3, 6) to that.

You're overcomplicating it way too much.

vectorAdd(setWord(<brick>.getPosition(), 2, getWord(<brick>.getWorldBox(), 5)), "0 0 0.1")

As opposed to
vectorAdd(vectorAdd(<brick>.getPosition(), "0 0" SPC <brick>.getDatablock().brickSizeZ/10), "0 0 0.1")

Id personally prefer to use mine, but its a matter of preference I guess. Id be curious to know what version is more efficient, because its totally has huge performance effects.

Also, so much for avoiding spoonfeeding.. His code is 90% done now...
« Last Edit: January 06, 2014, 08:47:08 AM by boodals 2 »

I find it odd that Port added an unnecessary vectorAdd after doing the clever - and much faster - method of using setWord.

setWord(%brick.getPosition(), 2, getWord(%brick.getWorldBox(), 5) + 0.1)

I find it odd that Port added an unnecessary vectorAdd after doing the clever - and much faster - method of using setWord.

setWord(%brick.getPosition(), 2, getWord(%brick.getWorldBox(), 5) + 0.1)

Must have been pretty tired at that time, haha.

But yeah, using the world box is a lot faster and more accurate than arbitrary calculations by datablock attributes.