Jump to content

change groundcover via script


subabrain
 Share

Recommended Posts

  • Replies 75
  • Created
  • Last Reply

Top Posters In This Topic

okay here a explanation for what i need this function ;)


i want to mow a meadow with a ride-on mower i have all but i dont know exactly what can i do in this case. i have a few ideas - do something with the footstep or with triggers or - what i think is the best way - the terrain-painter (call from script).


So thanks a lot for the answer - but im new to torque maybe you could explain a bit more - so i can understand ...


okay now you know why i need this :)


greetings

Robert

Link to comment
Share on other sites

No idea, learn to search for it.

I would make it as a weapon and while wearing the weapon or using it, put the function that paints the terrain there instead of damaging something.


Get Torsion if you do not have already and make a breakpoint to see what functions the engine calls when you do something.

Link to comment
Share on other sites

Hello again :P


as i wrote:

 

hey guys,


i find out something good...


thats how you an set the brush (for painting etc.):

 

ETerrainEditor.setBrushPos(getWord(%curPos, 0) + %x, getWord(%curPos, 1) + %y);

 

and get the brush:

 

%curPos = ETerrainEditor.getBrushPos();

 

now i just need to "paint" on the brush position... - maybe you can help me?


Thank you very much!


Greetz

Robert

 


Sorry that im disturbing you :/


but i know how to set the position of the brush... i tried to paint through the command Azaezel shows ... but maybe someone could tell me how i get this right?


i tried to make the player position to the brush one - thats working ...


i hope you could help me a last time ... would be nice - THANKS!


Greetings

Robert

Link to comment
Share on other sites

So now you need to know what happens when you press the mouse button on the terrain painter?

I don't know where this is done, maybe try setting a breakpoint and see what happens, I think it is in terrainEditor.ed.cs

 

yes thats the point - theres nothing shown in the console or somewhere else in torsion when i do the paint in the terrainpainter :/


okay but i hope we will get it ;)


thanks alot - i try to search the "terrainEditor.ed.cs" again :)


greetings

Robert

Link to comment
Share on other sites

hi there,


okay i made an output from the method and when i press the mouse button while painting.

So its the right thing :)


but i have troubles to be able to execute this function by torquescript ... i read some things but i dont know if im right ..


would be nice i you could help me (maybe i will find it out faster) :P :)


Thanks a lot for your help!


Regards -

Robert

Link to comment
Share on other sites

hey there,


i stuck a little bit :P


i want to call the method "PaintMaterialAction::process" from torquescript.

so now i took the following in the c++ code:


DefineEngineFunction(tesla, void, (), , "")

{

PaintMaterialAction::process;

}


and the following to the torquescript:


DefineEngineFunction( tesla, void, (),, "" )

{

echo("test");

}


so this is not working.

what do i made wrong?


Thanks a lot and gn8 ;)

Robert

Link to comment
Share on other sites

  • 1 month later...

Hello Guys,


sorry for the long delay but i dont get it :/


i tried all things - to manipulate the c++ methods and try to search for solutions but i dont get it!


i now get it to execute c++ functions with torque 3d but they dont get it to run -> for example:


---------------------------------------------------------------------------------------------------------------------------


grass.cpp

 

#include "grass.h"
#include "console/simBase.h" 
#include "console/console.h" 
#include "gui/worldEditor/terrainEditor.h"  
#include "gui/worldEditor/terrainActions.h"  
 
IMPLEMENT_CONOBJECT(grass);
 
void grass::set_grass()
{
 
	TerrainEditor *edit = new TerrainEditor();
 
	edit->autoMaterialLayer(-10000, 10000, 0, 90, 100);
 
}

 

---------------------------------------------------------------------------------------------------------------------------



grass.h

 

#ifndef _SIMBASE_H_  
#include "console/simBase.h" 
#include "gui/worldEditor/terrainEditor.h"  
#endif  
 
class grass : public SimObject
 
private:
	typedef SimObject Parent;
 
public:
	grass() { grass::set_grass(); }
	virtual ~grass() {}
	virtual void set_grass();
 
	DECLARE_CONOBJECT(grass);
};

---------------------------------------------------------------------------------------------------------------------------


And the TorqueScript:

grass.cs

 

function grasses() {
 
   %obj = new grass();  
   %obj.set_grass();
 
}

 

---------------------------------------------------------------------------------------------------------------------------


okay - but i just need to now how i can paint the material on a certain position :roll:


please help me - thx a lot!



Greetings - Robert!

Link to comment
Share on other sites

Then it will probably be in the C++ source code.

I looked it up for you and it may be this one:

https://github.com/GarageGames/Torque3D/blob/development/Engine/source/gui/worldEditor/terrainActions.cpp#L197-L247

 

i think this is the key - but how to execute this method?


i tried to make an instance and all the method ... but whats with the arguments?


please help me -.-



Greetz

Robert

Link to comment
Share on other sites

The arguments are named, you pass them along when you use the function.

If you miss arguments you usually get an error message like "invalid number of arguments got 2 expected 3" etc.

If you use debug mode in Visual Studio you can even see the data that is passed along with the function.

Link to comment
Share on other sites

If that's the whole code for your object, you still need a consoleMethod definition so the script system knows what the function is


Similar to [ur=]https://github.com/GarageGames/Torque3D/blob/development/Engine/source/T3D/shapeBase.cpp#L4936-L4947lthis,[/url] you would do something like:

 

DefineEngineMethod( grass, set_grass, void, (),,
   "@Paints some grass.\n\n" )
{
   object->set_grass();
}

 

What this does, is informs the script engine that objects of the 'grass' class have a function called set_grass() that can be called. When it's called, the above is executed by the script engine. So it'll take object(which is automatically the class of the first argument in the DefineEngineMethod function - in this case, "grass" - and then we call set_grass for it.


2 minor nitpicks from your examples I spotted(just to encourage good habits ;) ) you wouldn't want to have the grass::set_grass() call in the constructor. The method isn't static for one thing. Secondly, set_grass doesn't need to be virtual unless you plan to have classes inherit from grass and also have their own set_grass() function. You can leave that as a regular old function, since we'll be calling it through the DefineEngineMethod stuff :)

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

 Share


×
×
  • Create New...