GetConVar works on Windows, but not Linux?

PewPew appears to be giving me an error when run on Linux (tried with centos 6.5 & debian wheezy 7)


[ERROR] addons/pewpew/lua/weapons/gmod_tool/stools/pewpew_weapon_designer.lua:73: attempt to call method 'GetConVar' (a nil value)
  1. LeftClick - addons/pewpew/lua/weapons/gmod_tool/stools/pewpew_weapon_designer.lua:73
   2. unknown - gamemodes/sandbox/entities/weapons/gmod_tool/shared.lua:254


What’s so different between the windows version & linux version?

Can you show us the line the error happens? By the error it seems you are running it as method of some object, while it is a stand-alone function.


		if (!pewpew:GetConVar( "WeaponDesigner" )) then 
			ply:ChatPrint("[PewPew] The Weapon Designer is currently disabled.")
			return 
		end

Even if that is the case, it still doesn’t make sense that it runs perfectly fine on windows

Odd that it would even work on windows because GetConvar is a stand-alone function: http://wiki.garrysmod.com/page/Global/GetConVar

So I should change


if (!pewpew:GetConVar( "WeaponDesigner" )) then 

to


if (!GetConVar( "WeaponDesigner" )) then 

?

yes

that didn’t work. also, I found this:


	net.Receive( "PewPew_WeaponDesigner", function(l)
		if tobool(pewpew:GetConVar( "WeaponDesigner" ))==true then
			Weapon = net.ReadTable()
			Weapon.Name = "Weapon Designer Bullet"
		end
	end)

which is executed before


		if (!pewpew:GetConVar( "WeaponDesigner" )) then 
			ply:ChatPrint("[PewPew] The Weapon Designer is currently disabled.")
			return 
		end

so why does the other piece of code work?

GetConVar returns the ConVar object, to get a value from an object, you could do any of these:



// Number
local int = GetConVar("something"):GetInt()
// String
local str = GetConVar("something"):GetString()
// Boolean
local bool = GetConVar("something"):GetBool()


Replace pewpew:GetConVar(“convar_name”) with GetConVar(“convar_name”), and the first piece of code would work because GetConVar returned the ConVar object, which is then turned into true or false by tobool (which returned true because the ConVar isn’t nil/0/“false”/false).

Well WeaponDesigner is also a bool, so I could just use tobool there aswell?

I think what your trying to do is disable the weapon designer if a ConVar isn’t 1 or whatever.

You’d do this:



net.Receive( "PewPew_WeaponDesigner", function()
       if GetConVar("convar_name"):GetBool() then
              Weapon = net.ReadTable()
              Weapon.Name = "Weapon Designer Bullet"
       end
end)




if not GetConVar("convar_name"):GetBool() then 
       ply:ChatPrint("[PewPew] The Weapon Designer is currently disabled.")
       return 
end


now that I’ve applied your example, I get this error


[ERROR] addons/pewpew/lua/weapons/gmod_tool/stools/pewpew_weapon_designer.lua:73: attempt to index a nil value
  1. LeftClick - addons/pewpew/lua/weapons/gmod_tool/stools/pewpew_weapon_designer.lua:73
   2. unknown - gamemodes/sandbox/entities/weapons/gmod_tool/shared.lua:254


this is how the code looks:



              if not GetConVar("pewpew_options_wpn_designer"):GetBool() then
                        ply:ChatPrint("[PewPew] The Weapon Designer is currently disabled.")
                        return
                end


The problems you are having are most likely because the file paths contain uppercase letters. Try lowercasing it all in linux and it should start working again.

[editline]15th July 2015[/editline]

Use something like


convmv --lower -r lua --qfrom --qto --notest

I’m sorry? I’m having a problem with getting ConVar’s, not files :stuck_out_tongue:

You haven’t created a ConVar yet. Use CreateClientConVar/CreateConVar.

I have created it.


	local weapondesigner = CreateClientConVar("pewpew_options_wpn_designer","0",false,false)

Use 0 instead of “0”. Try replacing GetConVar(“pewpew_options_wpn_designer”) with weapondesigner.

Something tells me that there’s a global table called “pewpew” that has a function “GetConVar” and that’s what disappears on Linux for some reason? That’s the first thing I’d look into.

just run that on vanilla pewpew lua folder and see if everything got fixed.

Sorry if I missed this, but did you actually run the weapondesigner var considering it’s a command?