How to "Plant Crops"?
by Drethon · in Torque Game Engine · 09/24/2008 (1:42 pm) · 4 replies
I'm trying to figure out what pieces in TGE I would want to use to plant a crop. What I'm looking for is being able to draw a field on the terrain (to start with I'd create it in the world editor and learn how to create it in game later) which would change the terrain texture to barren land. On selecting the field (I'm looking to expand the basic FPS to select any object you can act on, similar to Mass effect) the player would press a certain key and would begin following a path within the field to start planting (increasing percentage planted value).
Is a PhysicalZone the best option for this or are there other options?
Is a PhysicalZone the best option for this or are there other options?
#2
What I'm looking for would be something like a way to link a trigger to an object so on entering the trigger a table gets updated to indicate the players location includes a farm and calling the act on location command would do update this farm and the farm knows its coordinates in the world to update the terrain.
I would create the farm as a trigger as I see how a callback is called on entry but I'm not sure how to act on the current trigger by sending a command while inside it...
[edit]
I had some further thoughts on making the farm a trigger. I think if I create a Zone object that inherits from Trigger I can use onEnterTrigger to set a player attribute to indicate what Zone the player is contained in. Then when the player sends the zone action command the Zone attribute of the player will be used to find the specifics of the current zone.
My question now (from my current minimal understanding of how the scripts work) is what is DefaultTrigger and how could I cause a different onEnterTrigger to be called when the Zone::potentialEnterObject function is called?
12/09/2008 (10:56 am)
Been working on college so I just got back to this. Decals are fine but once planted, how do I find the crop again? I could use a table that lists all the coordinates with objects of interest (including farms) to compare to the current location but this seems inefficient.What I'm looking for would be something like a way to link a trigger to an object so on entering the trigger a table gets updated to indicate the players location includes a farm and calling the act on location command would do update this farm and the farm knows its coordinates in the world to update the terrain.
I would create the farm as a trigger as I see how a callback is called on entry but I'm not sure how to act on the current trigger by sending a command while inside it...
[edit]
I had some further thoughts on making the farm a trigger. I think if I create a Zone object that inherits from Trigger I can use onEnterTrigger to set a player attribute to indicate what Zone the player is contained in. Then when the player sends the zone action command the Zone attribute of the player will be used to find the specifics of the current zone.
My question now (from my current minimal understanding of how the scripts work) is what is DefaultTrigger and how could I cause a different onEnterTrigger to be called when the Zone::potentialEnterObject function is called?
#3
You can also associate an object (like a decal) with the trigger area. (If you are unfamiliar with scripting, it's as simple as "%triggerIJustCreated.plowedField = %decalObjectIMadeEarlier;".) In this manner, you can then modify the decal or the area just by knowing the trigger the player entered.
12/09/2008 (12:51 pm)
The last question is probably the easiest: If you make another TriggerData datablock with a different name (like FieldTrigger), you can assign it to a Trigger object that you create in the mission (or later during the game). Then, when the player enters this area, FieldTrigger::onEnterTrigger will be called instead.You can also associate an object (like a decal) with the trigger area. (If you are unfamiliar with scripting, it's as simple as "%triggerIJustCreated.plowedField = %decalObjectIMadeEarlier;".) In this manner, you can then modify the decal or the area just by knowing the trigger the player entered.
#4
12/12/2008 (3:18 pm)
I think I can see how to make a new type of datablock but I'm missing where to set the location and dimensions of the new trigger object, also I'm curious how you update the world editor to have the new datablock as an option when creating a trigger if I want a pregenerated one instead of making all of them on the fly.
Associate William Lee Sims
Machine Code Games
Terrains are also created by an array of squares. If you force the field to fill an entire square, you could change the texture for that square. This requires an engine modification, but I've found it to not be too difficult. Also, this would force a field to be 8x8 meters (unless you changed the default square size of the terrain in the editor).