Simple Vectors

So lately for some reason I have been trying to get the specific x, y, and z values from a vector, with it, I get an error. I’m unsure why it’s doing this, but if someone could help me out here…

[LUA]
hud_ForeColor = Color(255, 0, 0, 255)

local row1 = properties:CreateRow(“HUD - General”, “Foreground - Color”)
row1:Setup(“VectorColor”)
row1:SetValue(Vector(hud_ForeColor.r / 255, hud_ForeColor.g / 255, hud_ForeColor.b / 255))
row1.DataChanged = function(_, val)
hud_ForeColor.r = val.x * 255 //Line 24
hud_ForeColor.g = val.y * 255
hud_ForeColor.b = val.z * 255
end
[/LUA]



[ERROR] gamemodes/isolation/gamemode/client/gui/hud_customization.lua:24: bad key to string index (number expected, got string)
  1. error - [C]:-1
   2. __index - lua/includes/extensions/string.lua:274
    3. DataChanged - gamemodes/isolation/gamemode/client/gui/hud_customization.lua:24
     4. ValueChanged - lua/vgui/prop_generic.lua:37
      5. ValueChanged - lua/vgui/prop_vectorcolor.lua:23
       6. OnValueChanged - lua/vgui/prop_vectorcolor.lua:67
        7. ValueChanged - lua/vgui/dcolorcombo.lua:38
         8. UpdateColor - lua/vgui/dcolormixer.lua:364
          9. SetColor - lua/vgui/dcolormixer.lua:283
           10. SetColor - lua/vgui/dcolorcombo.lua:74
            11. DoClick - lua/vgui/prop_vectorcolor.lua:72
             12. unknown - lua/vgui/dlabel.lua:206


What are val.x, y, and z defined as?

Well I was hoping you could tell me. If I can’t use those variables, is there another way I can get those values?

the problem isn’t the function itself but what you are feeding it as argument.

Can you guys stop giving me hints, and give me the damn answer? There’s little documentation for this.

Rude. We aren’t wizards. This is a two-way thing. You post details, we speculate, you post more details, we speculate some more, and eventually somebody has a lightbulb moment as a result of this discourse.

How are we supposed to give you any further help?? We don’t know what you are feeding DataChanged with. Log out the data that’s being passed as arguments in the function.

We’re not wizzards (harry), we are trying to figure out your problem.

[editline]Edit:[/editline]

trying printing one of the values.

Then you obviously haven’t read the link I gave out afterwards. I also did not define DataChanged myself, this is implemented.

[editline]19th February 2015[/editline]

Val is a Vector. Which is why I made this question.

Neither did you from the looks of your code. Print the data from the arguments being passed.

If you don’t know the answer, don’t say anything at all, if you do otherwise I would love to see the answer so I can continue with my work, and be happy.

Why should anyone help you with that attitude?

Because I have people wasting my time with hints, or incorrect answers that are completely obvious to the question. Code_gs told me what was wrong, but never answered back with an alternative way.

[editline]20th February 2015[/editline]

and then you spit on everyone trying to help gj lmao

And yet you said yourself there was little documentation. There was a 100 words on that page tops, did you think it would somehow contain more info if we saw it?

No one’s gonna serve you on a silver platter cumsock. The people asking for more information are doing it so they can help and you’ve straight up said “just figure it out already gawd”

No I was merely explaining why I have an attitude, I would appreciate the help more if I didn’t get obvious answers. Appreciating someone isn’t optimistic, and out of reach I might add.

[editline]19th February 2015[/editline]

You were correct on that statement, but this is not the answer I am looking for. Also I am not feeding an argument, I am merely assigning a variable.

No. You don’t understand. Do you expect us to do all of the work for you? To pour through the github VGUI resource to find the answer? To load gmod to find out the answer to your obscure problem by doing the basic debugging you should be doing?

No. Instead, you were asked to print the values and try to determine what is wrong beyond saying “it doesn’t work”, and to get back to us so we can guess. Hence, “no one’s gonna serve you on a silver platter”.

I know what your problem is, and I’m not going to help you because you’re being a dick.

[editline]20th February 2015[/editline]

I’ll PM scottywired the answer and you can hope that he’s so generous as to help someone being so ungrateful, since he was trying to help you in the first place.

I’ll help if you promise to stop having a pretentious attitude towards those legitimately helping you. These are not “tips” or “leads” to push you to find you a solution yourself, but rather, they’re legitimate questions we have about the situation.

Put this before line 24, but after you start the function:


PrintTable( val )
if val.x ~= nil then print( type( val.x ) .. " " .. tostring( val.x ) ) else print( "nil" ) end

Report back here on what it says before it errors.

I’m sorry for the slow assistance; I’m not actually able to see the wiki or GitHub due to me being constrained to my phone since my power supply died.

This guy is probably one of those spoiled brats who wants everything from their parents. And if they dont get it, they’ll go all ape and depressed.

Ceebs helping you now. I doubt anyone else will

Thank you for you’re time, I appreciate it, i’m not trying to be a douche, it’s just people are making it more than it has to be. Sorry for the inconvenience. I have not yet solved it, but I will report back with info.

[editline]20th February 2015[/editline]

You’re code has failed, but here is what returned. I know what you were trying to do though. Along with that I printed the vector normally, and got this… I will add that I have already printed the vector out before asking this question.

[LUA]
1.000000 0.000000 0.000000

[ERROR] lua/includes/util.lua:43: bad argument #1 to ‘pairs’ (table expected, got string)

  1. pairs - [C]:-1
  2. PrintTable - lua/includes/util.lua:43
    3. DataChanged - gamemodes/isolation/gamemode/client/gui/hud_customization.lua:24
    4. ValueChanged - lua/vgui/prop_generic.lua:37
    5. ValueChanged - lua/vgui/prop_vectorcolor.lua:23
    6. OnValueChanged - lua/vgui/prop_vectorcolor.lua:67
    7. ValueChanged - lua/vgui/dcolorcombo.lua:38
    8. UpdateColor - lua/vgui/dcolormixer.lua:364
    9. SetColor - lua/vgui/dcolormixer.lua:283
    10. SetColor - lua/vgui/dcolorcombo.lua:74
    11. DoClick - lua/vgui/prop_vectorcolor.lua:72
    12. unknown - lua/vgui/dlabel.lua:206
    [/LUA]