I'm looking to create an elevator that the player can use so I checked out the door prefab, but I'm left a little bit confused as to what actually triggers it. I can already tell I'm going to be asking a tonne of questions that might seem a bit simple, but I can't figure out what's making the door open in the first place when you get near.
please note that I've split your post, creating a new, standalone topic from it. That keeps discussions with different topics easier to follow.
I guess it's best if you check out some of the example lifts and doors in the maps: Simple doors are in map Kidney, a simple lift is in AEonsCube. A complex lift (and also teleporters and smaller lifts) are in BpWxBeta (the one shown in the image at http://www.cafu.de/news/client-features-revisited/).
Generally speaking, you need an entity that has a Mover component and a Script component. An entity that provides the "move destination point" can be a sub-entity of the main entity. Finally, you need something that triggers the Mover. Such triggers can be brushes that are part of the main entity (invisible in the maps unless you change the render mode in the 3D view using the TAB key) or a GUI. The trigger or GUI causes the main entity's script to be called, which in turn moves the door or lift.
Don't hesitate to ask if you've more questions!
The segment I want to use is already assigned to an entity called "tzone" and I've whacked the "trigger" meta texture on it just because I saw that in another map. But for whatever reason, this entire system doesn't feel at all intuitive to me. I know it will soon enough, but even while digging through scripts with the maps open in the game and CaWE I can't make much sense of the "which in turn"'s.
All it needs to do is toggle from upstairs, to downstairs when I walk into the triggerzone, but I've only been able to figure out how to "set the table" so to speak. Is there something incredibly glaringly obvious that I'm missing, or is it just a niche usecase so it's quite obtuse?
Let's break it into steps:
(I'm not sure what you mean by segment of an arc. Do you want the segment to initiate some action when it is touched, shot, clicked, ...?)
Let's just assume that the segment is a solid piece of wall or floor and you want an action to occur when someone walks near it.
You would create a new brush next to the segment, assign the "Trigger" material to it and move and shape it so that it encloses the volume that later should, when touched, trigger the action. That is, players are supposed to walk "into" this newly created brush (this is why it is rendered invisible in some of the CaWE render modes). It is the "Trigger" material that causes it to attain that special behavior. Such a brush is called a "trigger volume".
Next, when the player walks into such a trigger volume, what happens?
Note that trigger volume brushes are supposed to be part of a dedicated entity that has a Script component.
That is, the minimal setup is an entity that contains a trigger volume and a Script component. At this point, nothing else is needed.
Whenever something walks into the trigger volume, the script's
OnTrigger()method is called.
That is, the Script component must either point to a script file that defines this method, or you can enter the code into the ScriptCode field directly. For example:
Code: Select all
local Trigger = ... function Trigger:OnTrigger(Other) -- Add your code here. -- Here is typically a call to the door or lift -- that tells it to run it's action (open/close/move/...). end
Ohh, it just comes to mind: Make sure to check out the two trigger volumes in TestPatches.cmap! These provide really good examples of the technique described so far!
Next, the door or lift (that is for now an entirely different entity from the above) must be addressed as mentioned in the above code comment. For example:
Code: Select all
local Trigger = ... function Trigger:OnTrigger(Other) -- For more detail about this, see Games/DeathMatch/GUIs/Activate_main.cgui local DoorEnt = world:GetRootEntity():FindByName("my_door") local DoorScript = DoorEnt:GetComponent("Script") DoorScript:OnActivate(Other) end
Finally, note the trick that we use with the doors that you see in map Kidney (and elsewhere): The entity that keeps the trigger volume and the entity that keeps the Mover component are just one, which in turn simplifies the script setup, because you only need one script file, not two. It is a consequence of this two-in-one setup that the script in Scripts/MoverBinary.lua contains this code:
Code: Select all
function Script:OnTrigger(OtherEnt) self:OnActivate(OtherEnt) end
Users browsing this forum: No registered users and 0 guests