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
554 stars 332 forks source link

Wiremod dupe issues. #925

Closed Dragman200 closed 9 years ago

Dragman200 commented 9 years ago

So this happenes with things like flying drones that have a wire camera or for a well known example, the drunk combine so lets use this as an example. i spawn it in and use it well the camera doesnt go or follow the combine ragdoll like its suppost to and i get errors like the ones here:

[Wiremod] lua/entities/gmod_wire_cameracontroller.lua:364: bad argument #1 to 'WriteFloat' (number expected, got function)
  1. WriteFloat - [C]:-1
   2. SendPositions - lua/entities/gmod_wire_cameracontroller.lua:364
    3. SyncPositions - lua/entities/gmod_wire_cameracontroller.lua:399
     4. unknown - lua/entities/gmod_wire_cameracontroller.lua:540

[Wiremod] lua/entities/gmod_wire_cameracontroller.lua:364: bad argument #1 to 'WriteFloat' (number expected, got function)
  1. WriteFloat - [C]:-1
   2. SendPositions - lua/entities/gmod_wire_cameracontroller.lua:364
    3. SyncPositions - lua/entities/gmod_wire_cameracontroller.lua:399
     4. unknown - lua/entities/gmod_wire_cameracontroller.lua:540
Wire error (Entity [89][gmod_wire_cameracontroller]):
lua/entities/gmod_wire_cameracontroller.lua:364: bad argument #1 to 'WriteFloat' (number expected, got function)
stack traceback:
    [C]: in function 'WriteFloat'
    lua/entities/gmod_wire_cameracontroller.lua:364: in function 'SendPositions'
    lua/entities/gmod_wire_cameracontroller.lua:385: in function 'SyncSettings'
    lua/entities/gmod_wire_cameracontroller.lua:631: in function 'EnableCam'
    lua/entities/gmod_wire_cameracontroller.lua:738: in function <lua/entities/gmod_wire_cameracontroller.lua:735>
    [C]: in function 'xpcall'
    lua/wire/server/wirelib.lua:62: in function 'TriggerInput'
    entities/gmod_wire_expression2/core/wirelink.lua:14: in function <entities/gmod_wire_expression2/core/wirelink.lua:12>
    [C]: in function 'pcall'
    lua/entities/gmod_wire_expression2/core/init.lua:118: in function <lua/entities/gmod_wire_expression2/core/init.lua:112>
    [C]: in function 'pcall'
    lua/entities/gmod_wire_expression2/init.lua:198: in function 'PCallHook'
    lua/entities/gmod_wire_expression2/init.lua:139: in function 'Execute'
    entities/gmod_wire_expression2/core/gametick.lua:42: in function 'v'
    lua/includes/modules/hook.lua:84: in function 'old_hook_call'
    lua/includes/modules/momo/compat.lua:30: in function <lua/includes/modules/momo/compat.lua:22>
sv: Wire error (Entity [89][gmod_wire_cameracontroller]):
lua/entities/gmod_wire_cameracontroller.lua:364: bad argument #1 to 'WriteFloat' (number expected, got function)
stack traceback:
    [C]: in function 'WriteFloat'
    lua/entities/gmod_wire_cameracontroller.lua:364: in function 'SendPositions'
    lua/entities/gmod_wire_cameracontroller.lua:385: in function 'SyncSettings'
    lua/entities/gmod_wire_cameracontroller.lua:631: in function 'EnableCam'
    lua/entities/gmod_wire_cameracontroller.lua:738: in function <lua/entities/gmod_wire_cameracontroller.lua:735>
    [C]: in function 'xpcall'
    lua/wire/server/wirelib.lua:62: in function 'TriggerInput'
    entities/gmod_wire_expression2/core/wirelink.lua:14: in function <entities/gmod_wire_expression2/core/wirelink.lua:12>
    [C]: in function 'pcall'
    lua/entities/gmod_wire_expression2/core/init.lua:118: in function <lua/entities/gmod_wire_expression2/core/init.lua:112>
    [C]: in function 'pcall'
    lua/entities/gmod_wire_expression2/init.lua:198: in function 'PCallHook'
    lua/entities/gmod_wire_expression2/init.lua:139: in function 'Execute'
    entities/gmod_wire_expression2/core/gametick.lua:42: in function 'v'
    lua/includes/modules/hook.lua:84: in function 'old_hook_call'
    lua/includes/modules/momo/compat.lua:30: in function <lua/includes/modules/momo/compat.lua:22>

Any help?

Divran commented 9 years ago

Try to format your errors a bit better next time. Nobody wants to scroll for 3 years to get down here.

The first error is caused by conflicts with another mod. This other mod is made by someone really stupid who tries to create a variable named Distance on every single entity. This breaks any entity that tries to use Distance for itself Of course, since Distance is a really common variable name, creating a variable with that name on every entity is really stupid. What they should be doing if they want to create variables on entities is to create a table with a unique name and store their variables in that.

EDIT: The second error appears to be the same error again, but formatted differently. So yep your error is caused by another addon.

Divran commented 9 years ago

Here's the solution: https://github.com/wiremod/wire/issues/783

TomyLobo commented 9 years ago

To be clear about why this is their fault and not ours when we're both using the very common name "Distance": We introduced the entity and they're messing with it

oldmud0 commented 9 years ago

Why are we using the very common name Distance? Shouldn't we be having some convention like a Wire_ prefix for everything?

Divran commented 9 years ago

the fuck kind of question is that

EDIT: the entity is using "Distance" internally, to remember its own distance to things. If other addons externally break it, that's their fault and their fault alone. EDIT 2: entities can use whatever they want internally. It's up to other mods who also want to store variables on entities they don't own to make sure they don't break everything. EDIT 3: hell if wiremod itself wanted to write values to any wire entity, including this one, it should use a unique identifier (and it does, for example in E2 right here: https://github.com/wiremod/wire/blob/master/lua/entities/gmod_wire_expression2/core/entity.lua#L800-L833 )

TomyLobo commented 9 years ago

@oldmud0 I thought I pre-empted that question. We made the entity thus we get to dictate which fields others can use without breaking our entity.