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

Lua error when trying to wire an entity with many inputs #1071

Closed suunr closed 8 years ago

suunr commented 8 years ago

When looking with Wire on an entity with many wire inputs you get the error:

[ERROR] addons/wire/lua/weapons/gmod_tool/stools/wire_adv.lua:970: bad argument #2 to 'max' (number expected, got nil)
  1. max - [C]:-1
   2. DrawHUD - addons/wire/lua/weapons/gmod_tool/stools/wire_adv.lua:970
    3. unknown - gamemodes/sandbox/entities/weapons/gmod_tool/cl_init.lua:57

Example entity made in e2:

@inputs  A B C D E F G H I J K L M N O P Q R S T U V W X Y Z
@inputs  A1 B1 C1 D1 E1 F1 G1 H1 I1 J1 K1 L1 M1 N1 O1 P1 Q1 R1 S1 T1 U1 V1 W1 X1 Y1 Z1
@inputs  A2 B2 C2 D2 E2 F2 G2 H2 I2 J2 K2 L2 M2 N2 O2 P2 Q2 R2 S2 T2 U2 V2 W2 X2 Y2 Z2
Divran commented 8 years ago

This happens when the inputs don't fit on your screen. The function that is supposed to calculate the font size of the inputs can't find a font that is small enough, so it returns nil. To fix it, we would need to either make this function check smaller fonts, or just make it give up and return a small number if it fails.

https://github.com/wiremod/wire/blob/master/lua/weapons/gmod_tool/stools/wire_adv.lua#L895-L910