Using Link Filters

From FleshWorks

Jump to: navigation, search

by GlasWolf

Why Link Filters?

Sometimes you may find that you need to have several links running to and from a single object. This could perhaps be as a side effect of some complex scripting that you have implemented, where the script on one actor or volume affects several items on your map. The problem is that referencing all these links can get pretty confusing once it comes to creating your scripts.

For example, lets say we have a volume that, when breached by the player, simultaneously plays a sound and turns on a light at the other side of the room. So we'd create the volume, an AmbientSound marker to place the sound on, and a light. We'd perhaps link our volume to the light with a TriggerScript link, and the volume to the AmbientSound with an Association link. Finally, you'd create a script and add it to the volume - it would set the ambient sound across the Association link and turn the light on via the TriggerScript link.

Or was it the other way around? Ugh.

Now imagine you have ten different things happening simultaneously instead of two. You can see that the links would soon become unwieldy to say the least. Fortunately, there is a much better way - by using Link Filters.

Setting things up

You'd think after all that preamble they must be complicated, but they are incredibly simple. Go back to our example with the volume, light and ambient. This time, link the volume to both the light and marker with TriggerScript links. Now right click on the volume and choose Actor Links - you'll see the two TriggerScript links you created. Edit the one destined for the light, and in its Properties go to Link --> m_name. Call it LightSwitch. Now go to the TriggerLink --> LinkName property and call it LightSwitch there too. Click Done twice and you'll see that the link in the map is now labelled TRIGGERSCRIPTLINK: LIGHTSWITCH - this is as a result of the LinkName property. Changing the LinkName property isn't necessary, but it does make it easy to see at a glance what's what.

Image:Filters_linkprops.gif

Now to the script. To switch the light on, you'd have had an action something like Image:action_icon.png Set [bLightOn] to [TRUE] on linked objects of [TriggerScript]. Click on the [TriggerScript] entry and add LightSwitch into the Link Name Filter box at the bottom of the Link List screen. Click OK and you'll see the link shows in the script as [TriggerScript:LightSwitch]. Now only the light will get sent the message to turn the light on, not the AmbientSound marker (which would be a bit daft).

Image:Filters_script.gif

Now what?

So that's good - you can have 100 TriggerScript links on an object and access them all independently via their filter name. However, where this REALLY comes in handy is RigidAttachment links, because (as we've seen) you can write scripts to do different things to different link filters. Want an AI to pick up a piece of paper? RigidAttach it (using a link filter) and set its bOutOfWorld property to true in the editor. Then have a script that sets bOutOfWorld to false on that link filter when the AI collects the paper in game. Easy. The possibilities are endless... but that's your job.


TTLG forum discussion thread



Back to Mission Design: Scripting Tutorials Page

Back to Mission Design Tutorials Page

Back to Main Tutorials Page