so im making a computer building addon but i thik i stuffed up somewhere in the init.lua it has verabbiles r like u can have 2 gpus or 1 for only 1 motherboard and so on just please help
include("shared.lua")
AddCSLuaFile("shared.lua")
AddCSLuaFile("cl_init.lua")
function ENT:Initialize()
self:SetModel("models/oldpcs/nzxth440.mdl")
self:PhysicsInit(SOLID_VPHYSICS)
self:SetMoveType(MOVETYPE_VPHYSICS)
self:SetSolid(SOLID_VPHYSICS)
end
self.hasMotherboard = 0
self.has4gbram = 0
self.has8gbram = 0
self.has16gbram = 0
self.has1080ti = 0
self.hasgt1030 = 0
self.hastitanv = 0
self.hasryzencpu = 0
self.hasredstarpower = 0
self.hasrxvega = 0
self.totalCash = 0
function ENT:StartTouch(ent)
if ent:GetClass() == "motherboard" and self.hasMotherboard == 0 then
ent:Remove()
self.hasMotherboard = 1
end
end
function ENT:StartTouch(ent)
if ent:GetClass() == "amd_ryzen_cpu" and self.hasryzencpu == 0 and self.hasMotherboard == 1 then
ent:Remove()
self.hasryzencpu = 1
end
end
You are overriding your first function with second one. You have to use nested If statement
ok thanks my code it now
include("shared.lua")
AddCSLuaFile("shared.lua")
AddCSLuaFile("cl_init.lua")
function ENT:Initialize()
self:SetModel("models/oldpcs/nzxth440.mdl")
self:PhysicsInit(SOLID_VPHYSICS)
self:SetMoveType(MOVETYPE_VPHYSICS)
self:SetSolid(SOLID_VPHYSICS)
end
function
self.hasMotherboard = 0
self.has4gbram = 0
self.has8gbram = 0
self.has16gbram = 0
self.has1080ti = 0
self.hasgt1030 = 0
self.hastitanv = 0
self.hasryzencpu = 0
self.hasredstarpower = 0
Self.hasrxvega = 0
end
function ENT:StartTouch(ent)
if ent:GetClass() == "motherboard" and self.hasMotherboard == 0 then
ent:Remove()
self.hasMotherboard = 1
end
if ent:GetClass() == "amd_ryzen_cpu" and self.hasryzencpu == 0 and self.hasMotherboard == 1 then
ent:Remove()
self.hasryzencpu = 1
end
end
but i get this error in my console its from the self. i dont see anything wrong
[ERROR] addons/computer_building_addon/lua/entities/nzxt_h440/init.lua:16: '(' expected near '='
1. unknown - addons/computer_building_addon/lua/entities/nzxt_h440/init.lua:0
you just start a function with no name, no parameters, you just have the word "function"
Sorry, you need to Log In to post a reply to this thread.