• What do you need help with? V3
    6,419 replies, posted
I found out how to hide the world model. However, [ERROR] lua/entities/mariofire/init.lua:27: invalid escape sequence near '"models' 1. unknown - lua/entities/mariofire/init.lua:0 ... I dunno the problem... [code] --AddCSLuaFile( "cl_init.lua" ) AddCSLuaFile( "shared.lua" ) include( 'shared.lua' ) function ENT:SpawnFunction( ply, tr ) if ( !tr.Hit ) then return end local SpawnPos = tr.HitPos + tr.HitNormal * 64 local ent = ents.Create( "mariofire" ) ent:SetPos( SpawnPos ) ent:Spawn() ent:Activate() return ent end /*--------------------------------------------------------- Name: Initialize ---------------------------------------------------------*/ function ENT:Initialize() self.Entity:SetModel( "models\marioragdoll\Super Mario Galaxy\fire flower\fire.mdl" ) self.Entity:PhysicsInit( SOLID_VPHYSICS ) self.Entity:SetMoveType( MOVETYPE_VPHYSICS ) self.Entity:SetCollisionGroup( COLLISION_GROUP_PROJECTILE ) -- self.SpinOff = 0 -- self.VelLoss = 1 -- self.VecDir = self.VecDir or Vector( 0, 0, 1 ) -- self.ThrowVelocity = self.ThrowVelocity or 1500 self.LastBounce = CurTime() self.GravityRate = 0 self.CrTime = curtime() self.LifeTime = 3 self.HasBounced = 0 self.LifeLeft = 1.00 local phys = self.Entity:GetPhysicsObject() if (phys:IsValid()) then print( "DebugFireball: PhysObject()IsValid()") phys:Wake() -- phys:SetVelocityInstantaneous(self.ThrowVelocity*self.VecDir) -- phys:AddAngleVelocity(Vector( 0, 1000, 0 )) end end function ENT:PhysicsUpdate( phys ) local __UnitMeter = 39.3700787 if !self.HasBounced == 3 then self.GravityRate = (9.81*__UnitMeter) -- phys:SetVelocity( Vector(0,0,0) ) -- phys:AddVelocity( self.VelLoss*self.ThrowVelocity*self.VecDir -Vector(0,0,self.GravityRate) ) --self.Entity:GetPhysicsObject():SetVelocity( Vector(0,0,0) ) -- self.Entity:GetPhysicsObject():SetVelocityInstantaneous( self.VelLoss*self.ThrowVelocity*self.VecDir -Vector(0,0,self.GravityRate) ) -- Enable for fire slowing else self:Remove() end end function ENT:Think() self.LifeLeft = 1/1+((curtime()-self.CrTime)-2) if self.LifeLeft <= 0 then self:Remove() end print( 1/1+((curtime()-self.CrTime)-2) ) end /*--------------------------------------------------------- Name: PhysicsCollide ---------------------------------------------------------*/ function ENT:PhysicsCollide( data, physobj ) self.HasBounced = self.HasBounced + 1 local hEnt = data.HitEntity if hEnt:IsNPC() or hEnt:IsPlayer() or hEnt:Health() > 0 then hEnt:TakeDamage(25 * self.LifeLeft, self.Owner, self ) hEnt:Ignite(3, 0) end self.BounceClk = self.BounceClk + 1 local LastSpeed = math.max( data.OurOldVelocity:Length(), data.Speed ) local NewVelocity = physobj:GetVelocity() NewVelocity:Normalize() LastSpeed = math.max( NewVelocity:Length(), LastSpeed ) local TargetVelocity = NewVelocity * LastSpeed physobj:SetVelocity( TargetVelocity ) --[[ self.LastBounce = CurTime() if (data.Speed > 80 && data.DeltaTime > 0.2 ) then self.Entity:EmitSound( "Rubber.BulletImpact" ) end -- self.VelLoss = self.VelLoss*0.5 - 0.2 -- local LastSpeed = math.max( data.OurOldVelocity:Length(), data.Speed ) local LastFwd = data.OurOldVelocity:Normalize() local NewVelocity = physobj:GetVelocity():Normalize() local LastVel = self.VecDir * self.VelLoss * self.ThrowVelocity -- print( LastVel.x.." "..LastVel.y.." "..LastVel.z.." LastVel" ) local LostVel = data.HitNormal * LastVel -- print( LostVel.x.." "..LostVel.y.." "..LostVel.z.." LostVel" ) local FinalVel = LastVel-(LostVel*1.2) FinalVel = Vector( LastVel.x-LostVel.x, LastVel.y-LostVel.y, LastVel.z-LostVel.z ) print( LastVel.x-LostVel.y.." "..LastVel.y-LostVel.y.." "..LastVel.z-LostVel.z.." Sub" ) print( FinalVel:Length().." Length" ) -- LastSpeed = math.max( NewVelocity:Length(), LastSpeed ) -- LastFwd = LastFwd + data.HitNormal -- print( self.VelLoss.."VelLoss Pre" ) -- print( FinalVel:Length().." Final Vel" ) self.VecDir = FinalVel:Normalize() self.VelLoss = FinalVel:Length()/self.ThrowVelocity -- print( self.VelLoss.."VelLoss Post" ) self.Entity:SetLocalVelocity( Vector(0,0,0) ) self.Entity:SetVelocity( self.VecDir*self.VelLoss*self.ThrowVelocity ) ]] end /*--------------------------------------------------------- Name: OnTakeDamage ---------------------------------------------------------*/ function ENT:OnTakeDamage( dmginfo ) return false end /*--------------------------------------------------------- Name: Use ---------------------------------------------------------*/ function ENT:Use( activator, caller ) end[/code] [SUB][U][I]Edited [/I][/U][/SUB] I have no CL_INIT yet. [U][I]Edited[/I][/U] Or... I need an error-free projectile sent. Link or search term, por favor.
Did Garry take out SWEP.AdminSpawnable ?
[QUOTE=Dayto11;38764855]Could some one please help me with this code. function AddDir(dir) // Recursively adds everything in a directory to be downloaded by client local list = file.FindDir("../"..dir.."/*") for _, fdir in pairs(list) do if fdir != ".svn" then // Don't spam people with useless .svn folders AddDir(dir.."/"..fdir) end end for k,v in pairs(file.Find(dir.."/*", true)) do resource.AddFile(dir.."/"..v) end end I'm trying to make it so it downloads files from an addon any help would b appropriated thanks.[/QUOTE] [lua]function resource.AddDir(dir, path) path = path or "GAME" local list = file.Find(dir.."/*", path) for _, fdir in pairs(list) do if fdir != ".svn" then resource.AddDir(dir.."/"..fdir, path) end end for k,v in pairs(file.Find(dir.."/*", path)) do resource.AddFile(dir.."/"..v) end end[/lua]
I haven't even touched GLua since before garrysmod 13 and I am not caught up with the whole new system yet. How can I test a gamemode on my local server? Is there some sort of thign for legacy gamemodes similar to legacy addons?
[QUOTE=luavirusfree;38770731][ERROR] lua/entities/mariofire/init.lua:27: invalid escape sequence near '"models'[/QUOTE] Backslashes in your path. Either use two backslashes (like \\) or replace them with forward slashes.
-snip-
Hey! Need some help..... This code: [CODE]280:function SWEP:SetScope(b, player) if CLIENT then return end // Only play zoom sounds when chaning in/out of scope mode 285:// Just in case 286:self.Weapon:SetNetworkedFloat("ScopeZoom", self.ScopeZooms[self.CurScopeZoom]) if (b) then if (PlaySound) then 290: self.Weapon:EmitSound(sndZoomIn) end else if PlaySound then self.Weapon:EmitSound(sndZoomOut) 295: end end // Send the scope state to the client, so it can adjust the player's fov/HUD accordingly self.Weapon:SetDTBool(2, b) end[/CODE] Returns this: [CODE][ERROR] lua/weapons/weapon_mad_base_sniper/shared.lua:286: attempt to index field 'Weapon' (a nil value)[/CODE] \\It was also returning 'self' as a nil value before Help??
[QUOTE=Lolman123;38774084]Hey! Need some help..... This code: [CODE]280:function SWEP:SetScope(b, player) if CLIENT then return end // Only play zoom sounds when chaning in/out of scope mode 285:// Just in case 286:self.Weapon:SetNetworkedFloat("ScopeZoom", self.ScopeZooms[self.CurScopeZoom]) if (b) then if (PlaySound) then 290: self.Weapon:EmitSound(sndZoomIn) end else if PlaySound then self.Weapon:EmitSound(sndZoomOut) 295: end end // Send the scope state to the client, so it can adjust the player's fov/HUD accordingly self.Weapon:SetDTBool(2, b) end[/CODE] Returns this: [CODE][ERROR] lua/weapons/weapon_mad_base_sniper/shared.lua:286: attempt to index field 'Weapon' (a nil value)[/CODE] \\It was also returning 'self' as a nil value before Help??[/QUOTE] Use lua tags, and don't use self.Weapon, just use self.
I have a dhtml panel working as a little youtube player for fun, but I have hit a brick wall when it comes to actually knowing how to communicate between the html/js and lua... e.g. I want to store these vars in lua for displaying in a dlabel: <span class="duration-time html5-duration-time">[highlight]5:11[/highlight]</span> <meta name="title" content="[highlight]Initial D- GAS GAS GAS[/highlight]"> if somebody knows how it would be great [img]http://sae.tweek.us/static/images/emoticons/emot-unsmith.gif[/img]
[QUOTE=Drakehawke;38763264][url]http://glua.me/bin/?path=/lua/vgui/dhtml.lua[/url] Have a look over that[/QUOTE]
if i was to add a limit of presses on something what lines could i use?....
-snip-
IDK what this does: self.Touch = function( ... ) return end; self.Think = function( ... ) return end; . "quote"unquote
[QUOTE=luavirusfree;38779504]IDK what this does: self.Touch = function( ... ) return end; self.Think = function( ... ) return end; . "quote"unquote[/QUOTE] They both return false.
So, it means that those functions don't run?
Im trying to make a scoreboard to a gamemode. So i started to relate to other gamemodes and see how they did it, i tried to include cl_scoreboard.lua to init.lua and cl.init.lua but i really dont know how to add a scoreboard to a gamemode that has normal sandbox scoreboard if you can help me please do. Thanks in advance. Edit: I tried to include a cl_scoreboard.lua but when i started the gamemode up it couldnt find the file.
I am trying to adjust a model to a slope. How can I get the pitch of the ground which the model should spawn on? Traces on every edge of the model?
Trace down, the hit normal contains the direction the slope is facing. Just convert it to an angle :)
[QUOTE=garry;38780204]Trace down, the hit normal contains the direction the slope is facing. Just convert it to an angle :)[/QUOTE] Ok it seems that's the right way, but my model lays on the side on a normal ground with zero pitch. [lua]cliff:SetAngles( Angle(trace.HitNormal:Angle().p, math.random(0,360), trace.HitNormal:Angle().r ))[/lua] I feel like I forget something simple.
This is what I do in Vein: [lua]local trace = { }; trace.start = ent:GetPos(); trace.endpos = trace.start - Vector( 0, 0, 4096 ); trace.filter = ent; local tr = util.TraceLine( trace ); local n = tr.HitNormal:Angle(); ent:SetAngles( Angle( n.p + 90, n.y, n.r ) );[/lua]
[QUOTE=Disseminate;38780570]This is what I do in Vein: [lua]local trace = { }; trace.start = ent:GetPos(); trace.endpos = trace.start - Vector( 0, 0, 4096 ); trace.filter = ent; local tr = util.TraceLine( trace ); local n = tr.HitNormal:Angle(); ent:SetAngles( Angle( n.p + 90, n.y, n.r ) );[/lua][/QUOTE] Thanks! The + 90 was needed.
[QUOTE=garry;38780204]Trace down, the hit normal contains the direction the slope is facing. Just convert it to an angle :)[/QUOTE] Do you know if a function exists for changing the shading on entities? I apply the engine.LightStyle(int, str) and it only applies to the map's brushes.
I have a problem with my [URL="http://facepunch.com/showthread.php?t=1231968"]Fireball[/URL] script. It's not a weapon, it's a projectile. Click the link if you want to help.
Huge n00b here, trying to make a little auto-health generator script. Doesn't work of course, what did I do wrong.. function AutoHealth( ply ) local ply = LocalPlayer() local health = ply:Health() local maxhealth = ply.GetMaxHealth() if((health) < (maxhealth)) then ply:SetHealth( maxhealth ) end end hook.Add("Think", "AutoHealth", AutoHealth) Remember pls bare with me here lol
I posted a thread before seeing this, but I get the error WARNING: Vehicle FAILURE IN CUSTOM VEHICLE! The name, model or the price is invalid/missing When trying to use my Car Dealer class for DarkRP. This is the code for the custom vehicle AddCustomVehicle("Vehicle", { ent = "Jeep", model = "models/buggy.mdl", price = 5000, max = 2, cmd = "/vehicle", allowed = {TEAM_CAR} })
Everybody keeps getting spewed with this error: [code] [ERROR] lua/matproxy/player_weapon_color.lua:19: attempt to call method 'GetWeaponColor' (a nil value) 1. bind - lua/matproxy/player_weapon_color.lua:19 2. unknown - lua/includes/modules/matproxy.lua:56 [/code]
[QUOTE=tpops123;38782506]-snip-[/QUOTE] [lua] local time = 0 local regenrate = 1 -- how many seconds to wait to regen hp local regenamt = 1 -- how much hp you gain function AutoHealth() if SERVER then local plys = player.GetAll() if CurTime() >= time then for i = #plys do local ply = plys[i] local hp = ply:Health() local maxhp = ply:GetMaxHealth() if hp < maxhp then ply:SetHealth(hp+regenamt) end end time = CurTime() + regenrate end end end hook.Add("Think", "AutoHealth", AutoHealth) [/lua] Reply back if you don't understand.
[QUOTE=brandonj4;38782762][lua] local time = 0 local regenrate = 1 -- how many seconds to wait to regen hp local regenamt = 1 -- how much hp you gain function AutoHealth() if SERVER then local plys = player.GetAll() if CurTime() >= time then for i = #plys do local ply = plys[i] local hp = ply:Health() local maxhp = ply:GetMaxHealth() if hp < maxhp then ply:SetHealth(hp+regenamt) end end time = CurTime + regenrate end end end hook.Add("Think", "AutoHealth", AutoHealth) [/lua] Reply back if you don't understand.[/QUOTE] Ah.. ty :D surprisingly i understand it and now i feel retarded as balls lol
[QUOTE=zzaacckk;38775304]Use lua tags, and don't use self.Weapon, just use self.[/QUOTE] Now 'self' is returning nil :/
[QUOTE=Lolman123;38782943]Now 'self' is returning nil :/[/QUOTE] I'm guess self is out of scope somehow. I always screw scope up with lua. You're going to want to make sure that call is in the SWEP:Whatever function declaration, and you don't have an extra end somewhere before it.
Sorry, you need to Log In to post a reply to this thread.