• LUA Errors won't stop!!!
    7 replies, posted
I have a problem... *sigh* ... I can't get this to work without lua errors. [php]AddCSLuaFile( "shared.lua" )include( 'shared.lua' ) /*--------------------------------------------------------- Name: Initialize---------------------------------------------------------*/function ENT:Initialize() -- Use the doll model self.Entity:SetModel( "models/props_c17/doll01.mdl" ) self.Entity:SetMoveType( MOVETYPE_FLYGRAVITY ); self.Entity:SetMoveCollide( MOVECOLLIDE_FLY_CUSTOM ); self.Entity:SetGravity( 0.5 ); -- Use the model's physics self.Entity:PhysicsInitSphere(7, metal); self.CrTime = curtime(); self.LifeLeft = 1; -- Wake the physics object up. It's time to have babies! local phys = self.Entity:GetPhysicsObject(); if (phys:IsValid()) then phys:Wake() end end --[[--------------------------------------------------------------------------------- Purpose:-- Input : *pOther --------------------------------------------------------------------------------function ENT:Touch( pOther ) local tr; tr = {} tr.startpos = self.Entity:NearestPoint( pOther:OBBCenter() ); tr.endpos = pOther:NearestPoint( self.Entity:OBBCenter() ); tr.filter = self.Entity; tr = util.TraceLine( tr ); local vecNormalizedVel = self.Entity:GetVelocity(); vecNormalizedVel = VectorNormalize( vecNormalizedVel ); if( self.Entity:GetOwner() && self.Entity:GetOwner():IsPlayer() ) then local dmgInfo = DamageInfo(); dmgInfo:SetInflictor( self.Entity ); dmgInfo:SetAttacker( self.Entity:GetOwner() ); dmgInfo:SetDamage( 25 ); dmgInfo:SetDamageType( DMG_BURN | DMG_PREVENT_PHYSICS_FORCE ); dmgInfo:SetDamagePosition( tr.HitPos ); pOther:DispatchTraceAttack( dmgInfo, vecNormalizedVel, tr.HitPos ); pOther:Ignite(3, 0) else local dmgInfo = DamageInfo(); dmgInfo:SetInflictor( self.Entity ); dmgInfo:SetAttacker( self.Entity:GetOwner() ); dmgInfo:SetDamage( 0 ); dmgInfo:SetDamageType( DMG_BURN | DMG_PREVENT_PHYSICS_FORCE ); dmgInfo:SetDamagePosition( tr.HitPos ); pOther:DispatchTraceAttack( dmgInfo, vecNormalizedVel, tr.HitPos ); pOther:Ignite(30, 0) timer.Simple(30, pOther.Extinguish() ) end self.Entity:Remove(); -- play body "thwack" sound-- self.Entity:EmitSound( "Weapon_Crossbow.BoltHitBody" ); -- Fireballs don't thwack. local vForward; vForward = self.Entity:GetUp(); vForward = VectorNormalize ( vForward ); self.Touch = function( ... ) return end; self.Think = function( ... ) return end; local Pos1 = tr.HitPos + tr.HitNormal local Pos2 = tr.HitPos - tr.HitNormal-- util.Decal( "Blood", Pos1, Pos2 ) -- Scorch! end]] /*--------------------------------------------------------- Name: PhysicsCollide---------------------------------------------------------*/function ENT:PhysicsCollide( data, physobj ) -- Shoot some blood-- local effectdata = EffectData();-- effectdata:SetOrigin( self.Entity:GetPos() );-- util.Effect( "BloodImpact", effectdata ); local Pos1 = data.HitPos + data.HitNormal local Pos2 = data.HitPos - data.HitNormal if( self.Entity:GetOwner() && self.Entity:GetOwner():IsPlayer() ) then local dmgInfo = DamageInfo(); dmgInfo:SetInflictor( self.Entity ); dmgInfo:SetAttacker( self.Entity:GetOwner() ); dmgInfo:SetDamage( 25 ); dmgInfo:SetDamageType(bit.bor(DMG_BURN , DMG_PREVENT_PHYSICS_FORCE )); dmgInfo:SetDamagePosition( tr.HitPos ); pOther:DispatchTraceAttack( dmgInfo, vecNormalizedVel, tr.HitPos ); pOther:Ignite(3, 0) -- Ignite for a little while, will do no noticable damage. else local dmgInfo = DamageInfo(); dmgInfo:SetInflictor( self.Entity ); dmgInfo:SetAttacker( self.Entity:GetOwner() ); dmgInfo:SetDamage( 0 ); dmgInfo:SetDamageType(bit.bor(DMG_BURN , DMG_PREVENT_PHYSICS_FORCE )); dmgInfo:SetDamagePosition( tr.HitPos ); pOther:DispatchTraceAttack( dmgInfo, vecNormalizedVel, tr.HitPos ); pOther:Ignite(30, 0) timer.Simple(30, pOther.Extinguish() ) end -- util.Decal( "Blood", Pos1, Pos2 ) -- Scorch -- Play sound on death--[[ if (data.Speed > 80 && data.DeltaTime > 0.2 ) then self.Entity:EmitSound( "Weapon_Crossbow.BoltHitBody" ); end]] SafeRemoveEntityDelayed( self.Entity, 0.1 ); end function ENT:Think() self.LifeLeft = 3-self.CrTime if self.LifeLeft <= 0 then self:Remove() endend /*--------------------------------------------------------- Name: OnTakeDamage---------------------------------------------------------*/function ENT:OnTakeDamage( dmginfo ) -- React physically when shot/getting blown self.Entity:TakePhysicsDamage( dmginfo ) end [/php] Ignore the comments. They can't be the error, unless I need to remove them.... [code][ERROR] lua/entities/mariofire/init.lua:18: unexpected symbol near '.' 1. unknown - lua/entities/mariofire/init.lua:0[/code]
[QUOTE=luavirusfree;38782285]I will post the errors I get.[/QUOTE] So post them.
[php] [ERROR] lua/entities/mariofire/init.lua:18: unexpected symbol near '.' 1. unknown - lua/entities/mariofire/init.lua:0[/php]
[code] local self.CrTime = curtime(); local self.LifeLeft = 1; [/code] to [code] self.CrTime = CurTime(); self.LifeLeft = 1; [/code] you also have a few more errors in there
Yeah, if that removes it, I'll thank you. Otherwise, I will troll you. Just curious, however... What other errors? I used the AK47 Baby Shooter to try and fix it... [code][ERROR] lua/entities/mariofire/init.lua:104: ')' expected near '|' 1. unknown - lua/entities/mariofire/init.lua:0 [/code]
[LUA]dmgInfo:SetDamageType( DMG_BURN | DMG_PREVENT_PHYSICS_FORCE );[/LUA] to [LUA]dmgInfo:SetDamageType(bit.bor(DMG_BURN , DMG_PREVENT_PHYSICS_FORCE ));[/LUA]
Thank you for that. Checking for more errors... [code][ERROR] lua/entities/mariofire/init.lua:18: attempt to call global 'curtime' (a nil value) 1. unknown - lua/entities/mariofire/init.lua:18 2. Spawn - [C]:-1 3. unknown - lua/weapons/mario_fireballs/shared.lua:77[/code] I have yet to investigate, though. I will update the code above. *Sigh* It keeps shortening it to have no enters... [code]AddCSLuaFile( "shared.lua" )include( 'shared.lua' ) /*--------------------------------------------------------- Name: Initialize ---------------------------------------------------------*/ function ENT:Initialize() -- Use the doll model self.Entity:SetModel( "models/props_c17/doll01.mdl" ) self.Entity:SetMoveType( MOVETYPE_FLYGRAVITY ); self.Entity:SetMoveCollide( MOVECOLLIDE_FLY_CUSTOM ); self.Entity:SetGravity( 0.5 ); -- Use the model's physics self.Entity:PhysicsInitSphere(7, metal); self.CrTime = curtime(); self.LifeLeft = 1; -- Wake the physics object up. It's time to have babies! local phys = self.Entity:GetPhysicsObject(); if (phys:IsValid()) then phys:Wake() end end --[[ ------------------------------------------------------------------------------- -- Purpose: -- Input : *pOther - ------------------------------------------------------------------------------- function ENT:Touch( pOther ) local tr; tr = {} tr.startpos = self.Entity:NearestPoint( pOther:OBBCenter() ); tr.endpos = pOther:NearestPoint( self.Entity:OBBCenter() ); tr.filter = self.Entity; tr = util.TraceLine( tr ); local vecNormalizedVel = self.Entity:GetVelocity(); vecNormalizedVel = VectorNormalize( vecNormalizedVel ); if( self.Entity:GetOwner() && self.Entity:GetOwner():IsPlayer() ) then local dmgInfo = DamageInfo(); dmgInfo:SetInflictor( self.Entity ); dmgInfo:SetAttacker( self.Entity:GetOwner() ); dmgInfo:SetDamage( 25 ); dmgInfo:SetDamageType( DMG_BURN | DMG_PREVENT_PHYSICS_FORCE ); dmgInfo:SetDamagePosition( tr.HitPos ); pOther:DispatchTraceAttack( dmgInfo, vecNormalizedVel, tr.HitPos ); pOther:Ignite(3, 0) else local dmgInfo = DamageInfo(); dmgInfo:SetInflictor( self.Entity ); dmgInfo:SetAttacker( self.Entity:GetOwner() ); dmgInfo:SetDamage( 0 ); dmgInfo:SetDamageType( DMG_BURN | DMG_PREVENT_PHYSICS_FORCE ); dmgInfo:SetDamagePosition( tr.HitPos ); pOther:DispatchTraceAttack( dmgInfo, vecNormalizedVel, tr.HitPos ); pOther:Ignite(30, 0) timer.Simple(30, pOther.Extinguish() ) end self.Entity:Remove(); -- play body "thwack" sound -- self.Entity:EmitSound( "Weapon_Crossbow.BoltHitBody" ); -- Fireballs don't thwack. local vForward; vForward = self.Entity:GetUp(); vForward = VectorNormalize ( vForward ); self.Touch = function( ... ) return end; self.Think = function( ... ) return end; local Pos1 = tr.HitPos + tr.HitNormal local Pos2 = tr.HitPos - tr.HitNormal -- util.Decal( "Blood", Pos1, Pos2 ) -- Scorch! end ]] /*--------------------------------------------------------- Name: PhysicsCollide ---------------------------------------------------------*/ function ENT:PhysicsCollide( data, physobj ) -- Shoot some blood -- local effectdata = EffectData(); -- effectdata:SetOrigin( self.Entity:GetPos() ); -- util.Effect( "BloodImpact", effectdata ); local Pos1 = data.HitPos + data.HitNormal local Pos2 = data.HitPos - data.HitNormal if( self.Entity:GetOwner() && self.Entity:GetOwner():IsPlayer() ) then local dmgInfo = DamageInfo(); dmgInfo:SetInflictor( self.Entity ); dmgInfo:SetAttacker( self.Entity:GetOwner() ); dmgInfo:SetDamage( 25 ); dmgInfo:SetDamageType(bit.bor(DMG_BURN , DMG_PREVENT_PHYSICS_FORCE )); dmgInfo:SetDamagePosition( tr.HitPos ); pOther:DispatchTraceAttack( dmgInfo, vecNormalizedVel, tr.HitPos ); pOther:Ignite(3, 0) -- Ignite for a little while, will do no noticable damage. else local dmgInfo = DamageInfo(); dmgInfo:SetInflictor( self.Entity ); dmgInfo:SetAttacker( self.Entity:GetOwner() ); dmgInfo:SetDamage( 0 ); dmgInfo:SetDamageType(bit.bor(DMG_BURN , DMG_PREVENT_PHYSICS_FORCE )); dmgInfo:SetDamagePosition( tr.HitPos ); pOther:DispatchTraceAttack( dmgInfo, vecNormalizedVel, tr.HitPos ); pOther:Ignite(30, 0) timer.Simple(30, pOther.Extinguish() ) end -- util.Decal( "Blood", Pos1, Pos2 ) -- Scorch -- Play sound on death --[[ if (data.Speed > 80 && data.DeltaTime > 0.2 ) then self.Entity:EmitSound( "Weapon_Crossbow.BoltHitBody" ); end]] SafeRemoveEntityDelayed( self.Entity, 0.1 ); end function ENT:Think() self.LifeLeft = 3-self.CrTime if self.LifeLeft <= 0 then self:Remove() end end /*--------------------------------------------------------- Name: OnTakeDamage ---------------------------------------------------------*/ function ENT:OnTakeDamage( dmginfo ) -- React physically when shot/getting blown self.Entity:TakePhysicsDamage( dmginfo ) end [/code] Touch has been un-commented. It wasn't doing damage, but that's likely because of the new error. [code][ERROR] lua/entities/mariofire/init.lua:50: ')' expected near '|' 1. unknown - lua/entities/mariofire/init.lua:0 [/code]
[lua]dmgInfo:SetDamageType( DMG_BURN | DMG_PREVENT_PHYSICS_FORCE );[/lua] to [lua]dmgInfo:SetDamageType( bit.bor( DMG_BURN, DMG_PREVENT_PHYSICS_FORCE ) )[/lua] In function ENT:Touch( pOther )
Sorry, you need to Log In to post a reply to this thread.