Jump to content

creating a triggerzone in a unit position.


ESAc_matador
 Share

Recommended Posts

I am just trying to do this. I want a “vehicle A” to deploy a group called “infantry”(through “teleportinZone”) when it is close another moving vehicle called “vehicle B”

I don’t know how to write code so I neded tu use the scripting tool in the ME.

So,

“ONCE: vehicleB inside a moving trigger attached to the vechicleA.

THEN

Both cars stops and create Flag1”

 

Then I created another trigger to create a triggerzone where the Vehicle A is.

“ONCE: Time more flag1, 10s

THen

mist.teleportInZone('infantry', {Object.getPosition((vehicleA),25)}, true, 20) “

 

 

the error says

 

[string "mist.teleportInZone('infantry',{Object.getPosition((vehicleA),25)},true,20":1: Parameter#self missed stack traceback:

[C]:?

[C]:in function 'getPosition'

[string"mist.teleportInZone('infantry', {Object.getPosition((vehicleA),25)},true,20)"}1:in main chunk.

 

I dont have a clue about programming... so... I dunno what is going on!

testdeploy.miz

Link to comment
Share on other sites

  • Your call to Object.getPosition looks strange. Object.getPosition only expects one parameter, which should be an object (a unit or static object). "vehicleA" is an undefined variable here (unless you did not post your complete code)
  • mist.teleportInZone expects the name of a zone, not a position. I think you want mist.teleportToPoint instead.

 

Try something like this:

mist.teleportToPoint({groupName="infantry", point=Group.getByName("vehicleA"):getUnit(1):getPosition().p, action="respawn"})

 

Also, your logic of "I don't know Lua, so I need to use triggers" is flawed. IMO it should be "I don't know Lua, so I need to learn Lua". Scripting is much more powerful than trigger logic, more maintainable as your missions get more complex and you can test and debug a lot faster with the DCS Witchcraft Lua Console by trying out snippets of Lua code without restarting the mission.

Link to comment
Share on other sites

Ian;2355055']

 

Also, your logic of "I don't know Lua, so I need to use triggers" is flawed. IMO it should be "I don't know Lua, so I need to learn Lua". Scripting is much more powerful than trigger logic, more maintainable as your missions get more complex and you can test and debug a lot faster with the DCS Witchcraft Lua Console by trying out snippets of Lua code without restarting the mission.

 

Completely agree!! that is why I am starting from the beggining, which is studying this... http://www.lua.org/pil/contents.html. I dont know how to start, so I thought it would be good start from the beggining!.

 

And I do see that with .lua scripting, I would be able to expand my diabolic mind to make much better missions.

 

I will try what you say and I will return to you with the results.

 

Thank you!

Link to comment
Share on other sites

I tryed what you suggested, but It did not work. I have tryied few variations but it does not work. I am going to put what the message is later.

 

I dont know how tu make a function of a function... type F(G(x))

 

What I want is a simple teleportToPoint, but the point is another unit vec3. Even if I use teleportToZone is the same, I still need the vec3. ANd that is what I am not able to get.

 

Getposition? Getleadpos? i do not know

Link to comment
Share on other sites

  • 1 month later...

what is wrong with this??

 

mist.teleportToPoint({groupName="morteros", point=Group.getByName("Gato1"):getUnit(1):getPosition().p, action="respawn"})

 

no error message, but the unit does not teleport.

 

"Morteros" is a group name of Russian mortars."

"Gato1" is the group name of an Helicopter Client (Player).

 

I want to simulate a transport of two mortars initiated by a radio command. The radio command works because I put a messeage to ckeck, so...

 

is it because the helicopter vec3 position?

 

EDIT>

 

Forget about it... i got it fullfiling all parameters.

 

mist.teleportToPoint({groupName="morteros",point=Group.getByName("Gato1"):getUnit(1):getPosition().p,action="respawn",disperse = false,maxDisp = 20,radius = 30, innerRadius = 20, route = nil,})


Edited by ESAc_matador
Link to comment
Share on other sites

Hmm, I'll experiment a little bit with it to ensure that only the required parameters are needed to spawn a group since that first function should have worked. The only thing that comes to mind for why it might not have worked is that the scripting engine might not want to spawn a ground object at the exact same coordinates as either an aircraft or a client.

 

edit. See attached screenshot. In Singleplayer it gives the AI a cute little hat that shoots mortars. With me as the pilot it caused a nice little explosion and loss of tail. The function doesn't have any built in checks to verify the spawn point doesn't occupy the same space as another object. Considering how much is different from singleplayer to multiplayer I wouldn't be shocked if the scripting engine simply didn't allow for a unit to be spawned there.

 

I'd recommend changing it to either

mist.teleportToPoint({groupName="morteros", point=mist.getRandPointInCircle(Group.getByName("Gato1"):getUnit(1):getPosition().p, 20, 10), action="respawn"})

 

or

mist.teleportToPoint({groupName="morteros", point=Group.getByName("Gato1"):getUnit(1):getPosition().p, action="respawn", radius = 20, innerRadius = 10})

Screen_150508_181712.thumb.jpg.35a6063479b84ab2b521bbea7d49dcf9.jpg


Edited by Grimes

The right man in the wrong place makes all the difference in the world.

Current Projects: Scripting Wiki, Something...

Useful Links: Mission Scripting Tools MIST-(GitHub) MIST-(Thread), SLMOD, IADScript, Mission Editing Wiki!, Mission Building Forum

Link to comment
Share on other sites

 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...