Skip to content

Expression 2 Directives

Fasteroid edited this page Dec 25, 2024 · 7 revisions

Directives

Directives allow you to control important properties about E2 chips, such as their name, inputs, outputs, and more.

@name

Define the name of the E2 chip to show when hovering over it.

Example

@name My E2 Chip

@inputs

Define inputs to use with the wire system alongside their types.

Example

@inputs X Y:string [Z W]:number

@outputs

Define outputs to use with the wire system alongside their types.

Example

@outputs X Y:string [Z W]:number

@persist

Define a variable to persist across multiple executions.
Otherwise variables will reset to their default values.

Example

@persist X Y:string [Z W]:number

@trigger

The trigger directive can selectively enable or disable inputs from triggering executions. Possible values are all/none, but also a list of inputs. You usually will not need to worry about this.

Example

@trigger all
# or
@trigger X Y

@model

Sets the model of the E2 chip. Example

@model path/to/prop/model.mdl

@autoupdate

Using the autoupdate directive will enable auto updating. What this means is that whenever you paste a duplication of an E2 with autoupdate enabled, the E2 will check your files for a new version of that E2 and upload it. Note:

  • Only works on saved E2s.
  • To disable autoupdate, simply don't write @autoupdate
  • If you for some reason need to get an old version of your E2 from a dupe, you will have to temporarily change the name of your E2 so that the autoupdate feature doesn't find the file. Then it'll silently fail and leave you with the old code.

@strict

This makes E2 throw runtime errors on edge cases, unsafe practices, and other things that might be the source of bugs.

Take this example for instance:

E = propSpawn("some/custom/model.mdl", entity():pos(), 1)
E:applyForce( vec(10000, 0, 0) )

If the server doesn't have "some/custom/model.mdl", you'll end up with an invalid entity stored in E.

Without @strict, this silently fails and tries to carry on like nothing happened.
However, WITH @strict, it will throw a hard error and shut down the E2 if not handled in a try/catch block.

This directive is especially useful for debugging, and it's recommended to leave it on for new E2s.

Expression 2 ⚙️

Getting Started 🕊

Guides (In learning order) 🎓

Tools 🛠️

Click To Expand

Advanced

Beacon 💡

Control 🎛️

Data 💿

Detection 👀

Display 💻

Render 🖌

I/O 🔌

Physics 🚀

Utilities 🛠️

RFID 💳

Wireless 🛜

Gates 🚥

Click To Expand

TBD

Extras 🔭

Clone this wiki locally