ENT:Touch()

So I want it check if any of the entities inside a table.Class is touching the ent when remove that ent and run further though the table and set other variables.

I got some errors though :smiley:



icemod_printer
table: 0x33888288

[ERROR] lua/includes/extensions/table.lua:99: bad argument #1 to 'pairs' (table expected, got string)
  1. pairs - [C]:-1
   2. HasValue - lua/includes/extensions/table.lua:99
    3. unknown - addons/darkrpmodification/lua/entities/btc_miner/init.lua:49


GPU = {}
GPU[1] = { 
Class = "icemod_printer",
Name = "Geforce GTX 760",
MaxSLI = 2,
MHz = 980,
GMHz = 1000,
Heat = 97, 
Watt = 170
}


function ENT:Touch(ent)

	if ent:IsPlayer() then return end
	for index,v in pairs (GPU) do
		print(GPU[index].Class)
		print(GPU[index])
		if table.HasValue(GPU[index].Class, ent:GetClass()) then
			if self.MaxSLI != v.MaxSLI then
				return end
				self.MaxSLI = self.MaxSLI + 1 
				self.MHz = self.MHz + v.MHz
				self.GMHz = self.GMHz + v.GMHz
				self.Heat = v.Heat
				self.Watt = self.Watt + v.Watt
				self:SetNWString("GPU", v.Name)
				ent:Remove()
			else
			print("GPU doesnt match any table")
			end
		end
			for index,v in pairs (FAN) do
				if table.HasValue(FAN[index].Class, ent:GetClass()) then
					self.FWatt = self.FWatt + v.Watt
					self.FRPM = self.FRPM + v.RPM 
					self:SetNWString("fan", v.Name)
					ent:Remove()
					else
				print("Fan doesnt match any table")
				end
			end
		end

You misuse table.HasValue. Just use arg1 == arg2

Thanks.

Can i ask why a money printer needs to have a graphic cards?

Its not really a printer. I post it on WAYWO then its working without major bugs

Maybe it mines bitcoins :0