Expression 2 Directives - wiremod/wire GitHub Wiki

To declare wiremod inputs, outputs and persistent variables, you use directives.
You can also use them to say the name of the E2, change the model, tell it when to trigger and autoupdate and finally tell it to be a little more strict.

@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

@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 the E2 throw runtime errors whenever an internal error occurs.
Usually E2 would silently fail, and return the default value in a function (nothing, 0, "", etc), for example if you did

noentity():applyForce(vec(1e2, 0, 0))

This would not do anything without @strict, but with @strict, it would throw an error because you can't apply force onto an invalid entity (noentity()).

This is useful for debugging and generally to keep your E2 efficient and safe.
It is not enabled by default as to keep backwards compatibility with old E2s, but may be in the future.