wiremod / wire

Garry's Mod add-on that allows users to wire up components in order to make more elaborate automatic and user-controlled contraptions.
http://www.wiremod.com
Apache License 2.0
550 stars 332 forks source link

E2 Functions do not add their op cost #2958

Closed Denneisk closed 8 months ago

Denneisk commented 8 months ago

E2 functions do not apply their op cost to the running chip.

Given the following code, one would expect the output to be above 5000.

@strict
soundDuration("")
print(opcounter())

However, the output will be a resounding 1.

Operators apply ops as expected.

@strict
1 + 2 + 3
print(opcounter())

Outputs 3.

I believe this is an oversight. https://github.com/wiremod/wire/blob/aab46e3a9653f2ebf812ad208eacbcfb1261d1a7/lua/entities/gmod_wire_expression2/base/compiler.lua#L1989-L1992 As shown above, Compiler.GetOperator adds to the op count as expected. Compiler.GetFunction lacks this feature.