When I spawn this entity I want the model bellow to be scaled by 2x its size
[CODE]AddCSLuaFile()
DEFINE_BASECLASS( "gf2_base_adv" )
ENT.Spawnable = true
ENT.AdminOnly = false
ENT.PrintName = "8Inch Mortar Tube"
ENT.Author = "Rogue Cheney"
ENT.Contact = "baldursgate3@gmail.com"
ENT.Category = "G-Works 2 - Mortars + Shells"
ENT.Model = "models/models/gf2/rogue_cheney/mortars/mortar_03.mdl"
ENT.Mass = 150
ENT.GBOWNER = nil
ent:SetModelScale( ent:GetModelScale() * 1.25, 1 )[/CODE]
This line of code doesn't work. "ent" is a nil value. Please help!!
is that all of your code? if yes, then you have to learn at all how to make an ent.
I'll quote the post I made in the thread you posted in the wrong board
[QUOTE=bitches;48311422]firstly, ent isn't ENT; the upper/lowercase status matters for it to be the same variable
but:
gmod reads entity files by creating a global empty table called ENT, and then reading the entity file, applying anything inside it to the ENT table, which is just a set of data and words (not an entity), and then saves this data under the entity's name so that when the entity is [I]actually created[/I] it can be created based on that stored data
you're trying to set the model scale when the code is just trying to learn, ahead of time immediately when the game starts, what variables and functions all instances of future mortar tubes will possess
so in this area, ENT means 'the template for entities created based on this template in the future'
what you're looking for is:
[code]
function ENT:Initialize()
self:SetModelScale(self:GetModelScale()*1.25,1)
end
[/code]
inside a function defined as "function table:functionName()", the term self will always refer to the entity that exists in the future, instead of the ENT template; Initialize is a function name that the game will call after it creates the entity based on the ENT template[/QUOTE]
[editline]28th July 2015[/editline]
[QUOTE=whitestar;48311575]is that all of your code? if yes, then you have to learn at all how to make an ent.[/QUOTE]
this isn't helpful in the slightest
[QUOTE=Mezi;48311571]When I spawn this entity I want the model bellow to be scaled by 2x its size
[CODE]AddCSLuaFile()
DEFINE_BASECLASS( "gf2_base_adv" )
ENT.Spawnable = true
ENT.AdminOnly = false
ENT.PrintName = "8Inch Mortar Tube"
ENT.Author = "Rogue Cheney"
ENT.Contact = "baldursgate3@gmail.com"
ENT.Category = "G-Works 2 - Mortars + Shells"
ENT.Model = "models/models/gf2/rogue_cheney/mortars/mortar_03.mdl"
ENT.Mass = 150
ENT.GBOWNER = nil
ent:SetModelScale( ent:GetModelScale() * 1.25, 1 )[/CODE]
This line of code doesn't work. "ent" is a nil value. Please help!![/QUOTE]
Change * 1.25 to * 2 to make sure it scales it up by 2x.
[editline]28th July 2015[/editline]
[QUOTE=baldursgate3;48316608]Change * 1.25 to * 2 to make sure it scales it up by 2x.[/QUOTE]
As pointed out by bitches, place self:SetModelScale( ent:GetModelScale() * 1.25, 1 ) in ENT:Initialize() hook.
Sorry, you need to Log In to post a reply to this thread.