Author Topic: %new  (Read 2686 times)

Can someone help me with this for some reason in game it wont spawn the plate.
I know it has to do with no datablock but when I make one it still doesnt work.

Code: [Select]

//LandPlots//

function servercmdLandclaim(%client){
%new = new StaticShape(32x32base)
position = %client.obj.position;
scale = "1 1 1"
rotation = "1 0 0 0";
};

« Last Edit: January 21, 2008, 06:53:38 PM by Kunit_Yo »

There is if you make it.

This is coding help, coding help is for asking for help on code.

Almost all of your posts in here have been requests, this is what suggestions and requests is for.

Ya CODING help. I need help getting the CODE to do it.

No. You need help making the code to do it. If you want an Add-On, you code it. We'll gladly assist you in learning TorqueScript and any problems you encounter, but don't just ask for the finished code straight off - you will learn nothing by having the finished code just given to you.

It isnt the Final code I need that to start on the rest of it -_- Im making it so that if you type /claimland a 32x32 will spawn under you and a safe zone will appear over it and you are able to turn it off and on but first I need the script that spawns the plate

Look at the duplicator or my growing plants script to see how to create bricks via script.


Ok check main post it isnt working for some reason :(

OK.  You know you don't have a datablock.  What do you do?  Make one.  How do we define datablocks?  Like this:

Code: [Select]
datablock StaticShapeData(newDatablock) //substitute your datablock name here
{
shapeFile = "Add-Ons/Shapes/newDatablock.dts"; //substitute the path to your .dts file here
}; //datablocks always end with a semicolon

Now, defining a datablock doesn't make one in-game.  What do you do?  Instantiate it.  How do we instantiate (create an instance of) our datablock?  Like this:

Code: [Select]
%newDatablockInstance = new StaticShape() // If you put a name between the (), it should be unique
{
dataBlock = newDatablock;
}; //object instances always end with a semicolon

OK.  That should get you started.  I'm only gonna say this one time:

If can prove to us that you're taking it seriously by doing the ground work yourself, we don't mind helping with the harder parts.  If you need help, it should be a "Here's what I've done so far, and here's where I'm stuck" kind of thing.

Welcome to TorqueScript.

But also just 1 last thing when I type the /landclaim it doesnt happen in consoule it says Unknown ServerCmdlandclaim.

Also thanks the datablock i made was off by some things.
« Last Edit: January 21, 2008, 07:58:07 PM by Kunit_Yo »

it says Unknown ServerCmdlandclaim

That means it can't find the function serverCmdLandClaim because it doesn't exist. You probably didn't include the code you made in your main post (but that code needs some work so make sure you fix it according to Trader).

Hmm Now it doesnt say Unkown but now nothing happens

Code: [Select]
//LandPlots//
function serverCmdlandclaim(%client){
}
datablock StaticShapeData(LandDatablock)
{
shapeFile = "base/data/shapes/bricks/baseplates/32x32F.blp";
};

%newDatablockInstance = new StaticShape()
{
dataBlock = newDatablock;
};

%new = new StaticShape(){
position = %client.obj.position;
scale = "1 1 1"
rotation = "1 0 0 0";
datablock = "LandDatablock";
};

« Last Edit: January 21, 2008, 08:24:18 PM by Kunit_Yo »

Put the "%new = ...." section inside the serverCmdLandClaim function.
Then at the end of that function, add:
Code: [Select]
%new.setPosition(%client.player.getPosition());

Code: [Select]
//LandPlots//
function serverCmdlandclaim(%client){
%new = new StaticShape()
%new.setPosition(%client.player.getPosition());

}

%newDatablockInstance = new StaticShape()
{
dataBlock = newDatablock;
}
{
datablock StaticShapeData(LandDatablock){
shapeFile = "Add-Ons/shapes/32x32F.dts";
}

position = %client.obj.position;{
scale = "1 1 1"
rotation = "1 0 0 0";
datablock = "LandDatablock";}

Right?
« Last Edit: January 21, 2008, 10:29:18 PM by Kunit_Yo »

Put the "%new = ...." section inside the serverCmdLandClaim function.
Then at the end of that function, add:
Code: [Select]
%new.setPosition(%client.player.getPosition());
not just the line.