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
556 stars 334 forks source link

wire_adv.lua:420: attempt to index a nil value #466

Closed avp216 closed 11 years ago

avp216 commented 11 years ago

I'm using a fresh install of GMod and the Workshop version of Wiremod.

I placed a button from the wire menu. I can use it and it indicates that it's being pressed. When I attempt to wire something to the button with the wire_adv tool, or I use the button while wielding the tool, this error shows in the console:

od_tool/stools/wire_namer.lua][lua/weapons/gmod_tool/stools/wire_adv.lua]

[Wiremod] lua/weapons/gmod_tool/stools/wire_adv.lua:420: attempt to index a nil value
  1. unknown - lua/weapons/gmod_tool/stools/wire_adv.lua:420
   2. func - lua/weapons/gmod_tool/stools/wire_adv.lua:195
    3. unknown - lua/includes/modules/net.lua:31

Thanks!

Jack37 commented 11 years ago

I guess It's a bug of the new wire advanced tool. Button should show "Set" input, instead of that it shows nothing. I reported this to @Divran before, but after update it stopped erroring, and it showed the input so I did not remind him of this. Hopefully now he can look into it.

avp216 commented 11 years ago

Thing is, I have no idea what you are talking about lol... all this set input and advanced wire tool stuff. I just tried both wire tools that were available (something that said legacy? and the adv one you are talking about) Both gave me that error when I try and use it on something like a button. I never saw anything called set input :/

Is there no way to remedy this? Remember, this is my first time using wiremod.. EVER.

Divran commented 11 years ago

If both tools cause this error then the problem is most likely somewhere else.

avp216 commented 11 years ago

Both the wire tools cause this problem... Apparently there is no solution to this?

AbigailBuccaneer commented 11 years ago

@avp216, please post the error you get when using the legacy tool - it may be similar, but it won't be the same. Thanks.

avp216 commented 11 years ago

Okay, i just tried the legacy first, it doesn't do anything at all. Doesn't even give an error. It can't be used. The Advanced one gives the aforementioned error.

avp216 commented 11 years ago

Okay, apparently, i don't even have to USE the tool for the error to pop up. As soon as i click the wire tool, it gives me that error.

TomyLobo commented 11 years ago

So... is the tool I made still around to try?

TomyLobo commented 11 years ago

https://github.com/wiremod/wire/blob/master/lua/weapons/gmod_tool/stools/wire_adv.lua#L420 this is an "end"... are you sure you're up to date?

EDIT: nm, the change happened between your last 2 posts. update anyway and try, though

avp216 commented 11 years ago

Update what?? I just installed wiremod via the workshop :/

TomyLobo commented 11 years ago

ah then divran might not have updated that. https://github.com/wiremod/wire/blob/workshop/lua/weapons/gmod_tool/stools/wire_adv.lua#L420

TomyLobo commented 11 years ago

ok things that might throw that particular error in that line:

@Divran, why didn't you nil-check that thing? It's not like it's surprising to have wire ents with no inputs or no outputs... my wire tool avoids that issue altogether, btw, by not relying on indexes but on names, for permanent storage.

I also just noticed I was storing the last input and output used for each ent, separately, until the tool is holstered. That's something your tool doesn't seem to do from looking at the code... That begs the question: how well did you analyze my wire tool's feature set before deciding to replace it with yours?

avp216 commented 11 years ago

I have no idea what is going on here... AT ALL....Everything you just wrote was gibberish to me lol... Apparently I am using the wrong Wiremod? I downloaded it using the workshop.... So lost...

TomyLobo commented 11 years ago

no no you didnt do anything wrong. If anyone, @Divran did :)

avp216 commented 11 years ago

Oh... okay lol. But I still can't use the wire tool :D Just saying lol. Don't want to sound like an ass or anything :)

Xandaros commented 11 years ago

@avp216 What you called gibberish earlier is an analysis of what could be wrong. They are already trying to figure out what is happening and fixing it :)

@TomyLobo If it only happens on wire ents without in-/outputs, why does the error message appear when merely selecting the tool? I didn't confirm the bug myself yet, but that doesn't make sense to me.

Divran commented 11 years ago

@TomyLobo My tool remembers indexes for each entity separately as well. I didn't analyze your tool's feature set a whole lot. I had used it a lot though. My tool should now have all the features yours did, with the most recent update.

I don't nil check what thing? I have several checks to ensure you don't click a nonexistant input or output, but only one such check for each situation. I don't like to have unecessary checks. I learned that when I made PewPew (which had tons of unecessary checks all over the place, most of which checked the same thing 3 or 4 times in a row).

TomyLobo commented 11 years ago

you need to employ preconditions then

avp216 commented 11 years ago

Oh, alrighty then! I shall let the ones in charge solve this :) I will merely watch and pretend to know what is going on lol. Looking forward for this to be solved so I can actually use the thing lol XD

Divran commented 11 years ago

uh idk whats wrong, or even if anything is wrong at all

avp216 commented 11 years ago

Don't give up! My future stupid inventions rely on this working XD

Xandaros commented 11 years ago

Tried to confirm this bug with newest master and was not getting any Lua errors. However, I was not able to wire anything with the wire advanced tool, if the gate I was wiring to had only one output. With the Legacy tool it worked fine. I think c76916a310ca47a278b3769ec36fb73870c6ee21 is at fault here.

Exactly the same with workshop. (Only one commit behind, though) Works fine with workshop^ (one commit before the one I named earlier) @Divran

Divran commented 11 years ago

I'll take another look

EDIT: Sigh, yep I'm getting the same problem now. Gotta love it when it works during testing but not afterwards... This has happened twice before. Either I'm going crazy or the lua code isn't being reloaded sometimes. Oh well I'm fixing it now. And I'll try to be more thorough next time. Several map reloads should do it. EDIT: Alright I've got it fixed. Now single output wiring should work for real. As soon as I commit it. EDIT: https://github.com/wiremod/wire/commit/e6b27e33422c1b8285b91e223def215dc260e4e6

avp216 commented 11 years ago

I am sensing progress. Too bad i don't understand any of it :) Still, thank you all for still working on this. Appreciate the effort :)

Nebual commented 11 years ago

@avp216: When creating a wire between two devices, you first select the device that will receive the signal (the input device, such as a Turret, Thruster, Hydraulic Controller, etc), then you select the device that will output a signal (the output device, such as a Button, Ranger, Pod Controller, etc).

This error you reported specifically occured when you started a wire from a device with no inputs (such as a Button). I have now fixed this error, but note that you appear to have been wiring backwards.

Though as an aside, buttons can have the input "Set" if they are "Toggle Buttons" (its a setting in the button cpanel), rangers do have some inputs (for where to point the beam), and Pod Controllers have plenty of inputs too, but they're primarily used as output devices.

avp216 commented 11 years ago

yep it worked :+1: Really happy! Thanks for the effort guys :)

TomyLobo commented 11 years ago

A duplicate for this error showed up: #473