Page 1 of 1
Dynamically created regions
Posted: Mon Dec 19, 2016 2:14 pm
by DarthRubik
Now here is the question: Is it possible to create a region inside of a lua script?
The reason that I want this is because I want to be able to sense if someone entered an area, but I don't know where that area is going to be at munge time.
Now I find it quite likely that it will be impossible to do this, so my next question is this:
Could I synthesize this behavior by adding an object dynamically, and then somehow sensing if it is collided with something, without that object actually being rendered or pushing things out of the way?
Or is there some other way to sense if someone enters a dynamically chosen area?
Re: Dynamically created regions
Posted: Mon Dec 19, 2016 2:53 pm
by Marth8880
What exactly is it that you're trying to do specifically? Are you wanting to have something happen when a unit enters a region only after a specific set of conditions are true? If so, you can do so with some if-statements, OnEnterRegion ,and DeactivateRegion (see the FAQ for details).
DarthRubik wrote:Now here is the question: Is it possible to create a region inside of a lua script?
The reason that I want this is because I want to be able to sense if someone entered an area, but I don't know where that area is going to be at munge time.
You *might* be able to do this by loading a lvl file that contains only a single layer with regions in it somewhere in ScriptPostLoad, but I wouldn't count on it.
DarthRubik wrote:Could I synthesize this behavior by adding an object dynamically, and then somehow sensing if it is collided with something, without that object actually being rendered or pushing things out of the way?
Sadly there aren't any functions that can detect object collision, no. Regions are the closest thing we have to this kind of functionality.
Re: Dynamically created regions
Posted: Mon Dec 19, 2016 3:52 pm
by DarthRubik
What exactly is it that you're trying to do specifically? Are you wanting to have something happen when a unit enters a region only after a specific set of conditions are true? If so, you can do so with some if-statements, OnEnterRegion ,and DeactivateRegion (see the FAQ for details).
Yes, I am actually trying to teleport someone/something when it enters an area, but I don't know where the area is when I munge it, so I am looking for a way to create an area of sensitivity at run time. Whenever, something enters (or exits) this area I want a function to be called.
But as you said, it does not look like this is possible, which is a bummer, because a lot of cool thing could be done with things like that.
Re: Dynamically created regions
Posted: Mon Dec 19, 2016 5:33 pm
by Marth8880
DarthRubik wrote:but I don't know where the area is when I munge it
What do you mean by this?
Re: Dynamically created regions
Posted: Mon Dec 19, 2016 5:53 pm
by DarthRubik
Basically I have a capital star ship. I want to clone all of the objects inside of the star ship (like the hanger, the doors, the engine room, etc.) and move it to some random location. Then any person that spawns in the original star ship will be teleported to the cloned hanger. Exiting the the cloned hanger, teleports you just outside of the original star ship and entering the original star ship teleports you to the cloned hanger. This gives the illusion (kind of) that you are actually in the other ship when you are not. This allows the ship to be sideways, upside down, etc.
This is the part were the problem comes in. I want to write a lua function. Basically what you would do is give the function a list of all of the objects in the capital ship that you wanted cloned over (like the hanger, the doors, the engine room, etc.), a location to clone them to, and then it sets up all the magic teleporting stuff. The problem with this is that you cannot generate a region in the cloned location with a lua script (as far as I am aware), which means that you can not sense when someone exits the cloned hanger.
So basically what this means is that I need some way of sensing that someone leaves the cloned hanger without using regions (or as a last resort just give the lua function a pre-built region to clone all of this stuff to).