[QUOTE=AnonTakesOver;46179585]Don't you need to use commas? or is this some type of thing that I am unware of and you can use semicolons[/QUOTE]semicolons are valid seperators
I have this friend and he (for whatever reason) thinks that Lua isn't object oriented. Can somebody from here please back me up, I've given him a wealth of resources that prove it and he just keeps forcing it down my throat.
[IMG]http://i.imgur.com/DxYNeIw.png[/IMG] :v:
[IMG]http://i.imgur.com/rLSvdrH.png[/IMG]
[IMG]http://i.imgur.com/OmQl7Qw.png [/IMG]
[IMG]http://i.imgur.com/LTRseZy.png[/IMG]
I don't know if he doesn't actually know very much about programming or what, but Facepunch, tell him why Lua is object oriented, apart from the fact that it is
i wouldn't say it's completely object oriented, it just looks like it from a distance
Am I the only one having problems getting rid of the CHudHistoryResource part of the HUD? I'm returning it as false yet it doesn't remove the ammo and weapon pickup notification on the right of the screen.
Same thing with CHudWeapon.
(Talking about this)
[img]https://maurits.tv/data/garrysmod/wiki/wiki.garrysmod.com/images/e/e7/Gmod_wiki_chudweapon.png[/img]
[QUOTE=buu342;46181983]Am I the only one having problems getting rid of the CHudHistoryResource part of the HUD? I'm returning it as false yet it doesn't remove the ammo and weapon pickup notification on the right of the screen.
Same thing with CHudWeapon.
(Talking about this)
[IMG]https://maurits.tv/data/garrysmod/wiki/wiki.garrysmod.com/images/e/e7/Gmod_wiki_chudweapon.png[/IMG][/QUOTE]
[url]https://github.com/garrynewman/garrysmod/blob/master/garrysmod/gamemodes/base/gamemode/cl_hudpickup.lua[/url]
My Melon gun isn't shooting with the right velocity anymore.
It seems like its only shooting with a Power of <3000.
It worked fine about 2 months ago and I didn't change anything that would interfere with the velocity of the melon.
[lua] ent:SetPos( self.Owner:GetShootPos() + Forward * 32 )
ent:SetModel("models/props_junk/watermelon01.mdl")
ent:SetAngles( self.Owner:EyeAngles() )
ent:Spawn()
local phys = ent:GetPhysicsObject()
phys:SetVelocity( self.Owner:GetAimVector() * Power ) --Power is only going up to ~3000. (even when it's 10000, it's only shooting as far as 3000)
[/lua]
[QUOTE=RonanZer0;46179326]You need to put the full model paths, not just their name. Go into sandbox, find the models in the menu, right click and click copy or something, then you can paste it into the code.[/QUOTE]
Thank you.
@ Acecool,
Yes I am trying to get rotation. I got the pitch clamped nicely but Yaw is being an issue. I also want this to work no matter where I look. So like my y axis is 90 and it would clamp between -90 and 180...
I'm having trouble explaining my problem because I dont entirely understand it. I want the players view to be limited to only 90 degrees left or right of their current Eye Angle when I run the function on them.
Is there an easy way to get the position of an entity to automatically spawn around 50 ft. above the character when it is launched? I already tried messing around with ent:GetAngles and SetAngles and I was just wondering if there was an easier way to manage this stuff.
[QUOTE=bluebull107;46183189]Is there an easy way to get the position of an entity to automatically spawn around 50 ft. above the character when it is launched? I already tried messing around with ent:GetAngles and SetAngles and I was just wondering if there was an easier way to manage this stuff.[/QUOTE]
[lua]
local ent = ent.Create("your_entity")
ent:SetPos(player:GetPos() + Vector(0,0,500))
ent:Spawn()
[/lua]
Or whatever 50 ft. would be. I assume you have the player entity when you're doing the spawn.
How would I get props of a player?
Thank you so much Atebite!
That saves me so much time :)
[QUOTE=Exho;46182601]@ Acecool,
Yes I am trying to get rotation. I got the pitch clamped nicely but Yaw is being an issue. I also want this to work no matter where I look. So like my y axis is 90 and it would clamp between -90 and 180...
I'm having trouble explaining my problem because I dont entirely understand it. I want the players view to be limited to only 90 degrees left or right of their current Eye Angle when I run the function on them.[/QUOTE]
I think the easiest way to explain it is this.... And this is me assuming this is what you want which may be completely wrong too...
You have a player facing one direction, you want their head ( or camera in 3rdperson ) to rotate freely ( or with a button )... That should be locked -90 to +90 of current view so behind them will not be visible...
I'm about to head out but when I'm back I should be able to help you out with it if others don't get to it first ( few hours to new place )...
[QUOTE=bluebull107;46183189]Is there an easy way to get the position of an entity to automatically spawn around 50 ft. above the character when it is launched? I already tried messing around with ent:GetAngles and SetAngles and I was just wondering if there was an easier way to manage this stuff.[/QUOTE]1 foot = 16 units
50 * 16 = 800
Use 800 for SetPos.
Anyone trig-minded here know how to rotate something around a point?
I've kind of confused myself here and over thank too much, I'm using this function to allow a user to create a button simply using: [B]AddNavButton( id , x , y , w , h , text, page)[/B]
But how can I change the text color when the mouse hovers over the button (Im using the draw library for the text)
Heres the code;
[code]
function AddNavButton( id , x , y , w , h , text, page)
local NavButtonColor = Color( 46,54,65, 255 )
local NavButtonOne = vgui.Create( "DButton", MotdNav )
NavButtonOne:SetPos( x, y )
NavButtonOne:SetText( "" )
NavButtonOne:SetSize( w, h )
NavButtonOne.Paint = function()
draw.RoundedBox( 0, 0, 0, NavButtonOne:GetWide(), NavButtonOne:GetTall(), NavButtonColor )
draw.SimpleText(text,"SMOTD_Body",NavButtonOne:GetWide()/2,NavButtonOne:GetTall()/2,Color(255,255,255,200),TEXT_ALIGN_CENTER)
end
NavButtonOne.OnCursorEntered = function()
surface.PlaySound("garrysmod/ui_return.wav")
NavButtonColor = Color( 255, 255, 255, 255 )
end
NavButtonOne.OnCursorExited = function()
NavButtonColor = Color( 46,54,65, 255 )
end
NavButtonOne.DoClick = function()
print("clicked Button "..id)
end
end
[/code]
So my aimed out put would be:
*User hovers over button* *Buttons text color changes to ie. Red*
( I have tried using SetText and SetTextColor rather than drawing the text)
[QUOTE=LUModder;46183301]How would I get props of a player?[/QUOTE]
If you're using a prop protection look into the [url=http://ulyssesmod.net/archive/CPPI_v1-1.pdf]CPPI interface[/url]. Otherwise I think GetOwner or GetCreator will return the owner? I'm not 100% sure on that but CPPIGetOwner always worked for me and FPP.
[QUOTE=_Entity;46184242]I've kind of confused myself here and over thank too much, I'm using this function to allow a user to create a button simply using: [B]AddNavButton( id , x , y , w , h , text, page)[/B]
But how can I change the text color when the mouse hovers over the button (Im using the draw library for the text)
Heres the code;
-snip-
So my aimed out put would be:
*User hovers over button* *Buttons text color changes to ie. Red*
( I have tried using SetText and SetTextColor rather than drawing the text)[/QUOTE]
First off all, you didn't create the function. Maybe you should ask the Creator (me ;)) first?
the same way i handle the RoundedBox color. Also you should try to understand the code or ask me to help you understanding my code
[lua]local NavButtonTextColor = Color(255,255,255,200) -- setting it to the first White.
NavButtonOne.OnCursorEntered = function()
surface.PlaySound("garrysmod/ui_return.wav")
NavButtonColor = Color( 255, 255, 255, 255 )
NavButtonTextColor = Color(255,0,0,255) -- Changing it to red.
end
NavButtonOne.OnCursorExited = function()
NavButtonColor = Color( 46,54,65, 255 )
NavButtonTextColor = Color(255,255,255,200) -- Back to the original Color.
end
[/lua]
Edit:// forgott something
[lua] NavButtonOne.Paint = function()
draw.RoundedBox( 0, 0, 0, NavButtonOne:GetWide(), NavButtonOne:GetTall(), NavButtonColor )
draw.SimpleText(text,"SMOTD_Body",NavButtonOne:GetWide()/2,NavButtonOne:GetTall()/2,NavButtonTextColor,TEXT_ALIGN_CENTER)
end[/lua]
the Variable must be inside the draw.SimpleText.
[QUOTE=Tomelyr;46184400]First off all, you didn't create the function. Maybe you should ask the Creator (me ;)) first?
the same way i handle the RoundedBox color. Also you should try to understand the code or ask me to help you understanding my code
[lua]local NavButtonTextColor = Color(255,255,255,200) -- setting it to the first White.
NavButtonOne.OnCursorEntered = function()
surface.PlaySound("garrysmod/ui_return.wav")
NavButtonColor = Color( 255, 255, 255, 255 )
NavButtonTextColor = Color(255,0,0,255) -- Changing it to red.
end
NavButtonOne.OnCursorExited = function()
NavButtonColor = Color( 46,54,65, 255 )
NavButtonTextColor = Color(255,255,255,200) -- Back to the original Color.
end
[/lua]
Edit:// forgott something
[lua] NavButtonOne.Paint = function()
draw.RoundedBox( 0, 0, 0, NavButtonOne:GetWide(), NavButtonOne:GetTall(), NavButtonColor )
draw.SimpleText(text,"SMOTD_Body",NavButtonOne:GetWide()/2,NavButtonOne:GetTall()/2,NavButtonTextColor,TEXT_ALIGN_CENTER)
end[/lua]
the Variable must be inside the draw.SimpleText.[/QUOTE]
[QUOTE]I'm using this function[/QUOTE] <---- ;p
I understand it all fine just a tard when it comes to "problem solving" thanks anyway!
[QUOTE=Acecool;46183437]I think the easiest way to explain it is this.... And this is me assuming this is what you want which may be completely wrong too...
You have a player facing one direction, you want their head ( or camera in 3rdperson ) to rotate freely ( or with a button )... That should be locked -90 to +90 of current view so behind them will not be visible...
I'm about to head out but when I'm back I should be able to help you out with it if others don't get to it first ( few hours to new place )...[/QUOTE]
Its not really their head, its a RenderView that is overlayed on their screen. And yeah, I got the pitch to be clamped between my 2 variables, its just turning left and right that are not locked.
Using NormalizeAngle requires me to first convert my Vector into an angle, using either Angle or AngleEx returns an error. Why is this so hard... Pitch was easy but everything else has to be complicated as hell
[code]
attempt to call method 'Angle' (a nil value)
[/code]
[QUOTE=BFG9000;46183640]Anyone trig-minded here know how to rotate something around a point?[/QUOTE]
Use [URL="http://wiki.garrysmod.com/page/Angle/RotateAroundAxis"]Angle:RotateAroundAxis[/URL]
As the name suggests, it rotates the angle around its axis.
I cant seem to get ent:SetModelScale( ent:GetModelScale() * 10, 1 ) to work right. I place it in SWEP:PrimaryAttack. If there anything I am doing wrong?
Okay, I think this might help... I want to find the player's current facing Angle Roll, round it to some variant of 90 (0, 90, 180, -90), and then clamping the view from that point. If someone could tell me how to do that, i would be thankful.
This is my project I am working on: [url]https://github.com/Exho1/TTT_Spy_Cable/[/url]
[QUOTE=Exho;46185410]Okay, I think this might help... I want to find the player's current facing Angle Roll, round it to some variant of 90 (0, 90, 180, -90), and then clamping the view from that point. If someone could tell me how to do that, i would be thankful.
This is my project I am working on: [url]https://github.com/Exho1/TTT_Spy_Cable/[/url][/QUOTE]
A start would be setting the player's eye angles using [URL="http://wiki.garrysmod.com/page/Player/SetEyeAngles"]player:SetEyeAngles[/URL].
I've tried using it before, though, and I ended up with a skewed vision even though I stored and reverted back to the original angles. So be wary, I guess.
[QUOTE=Atebite;46184684]Use [URL="http://wiki.garrysmod.com/page/Angle/RotateAroundAxis"]Angle:RotateAroundAxis[/URL]
As the name suggests, it rotates the angle around its axis.[/QUOTE]
No, this doesn't work because the point of rotation cannot be changed. I'm looking to rotate an object's angle and position around a determined point.
[QUOTE=BFG9000;46185784]No, this doesn't work because the point of rotation cannot be changed. I'm looking to rotate an object's angle and position around a determined point.[/QUOTE]
Oh, you want to rotate it around a different pivot. You could try to offset the entity's position before you set the angles.
Poking around the wiki I found [URL="http://wiki.garrysmod.com/page/Entity/SetLocalPos"]entity:SetLocalPos[/URL], I'd give that a go.
[QUOTE=BFG9000;46183640]Anyone trig-minded here know how to rotate something around a point?[/QUOTE]
There is Vector:Rotate(). Subtract your point from point you want to rotate around (the 'origin') so it is relative to that location, rotate it, then add it back to origin.
Something like this (untested):
[lua]--Example
--Get a point 100 units in the direction the player is aiming.
--Rotate that point asround the player by 45 degrees yaw
local FwdDistance = 100
local ply = LocalPlayer()
local EyePos = ply:EyePos()
local EyeAngle = ply:EyeAngles()
--Get the direction they are looking as a normal (unit) vector
local AimDirection = EyeAngle:Forward()
--Get a point in front of the player in the direction they are looking
local PointInFront = EyePos + AimDirection*FwdDistance
--Make that point local to where you are rotating from
local LocalPoint = PointInFront-EyePos
--Rotate it
LocalPoint:Rotate(0,45,0) --:Rotate() modifies the actual vector, it doesn't return a new value
local NewPoint = EyePos+LocalPoint[/lua]
Edit: Wtf happened to the syntax highlighting?
Does anyone know how to prevent the game from giving 24 pistol ammo every time unused ammo types (CombineCannon, AirboatGun) are given to the player?
[QUOTE=ROFLBURGER;46188575]Does anyone know how to prevent the game from giving 24 pistol ammo every time unused ammo types (CombineCannon, AirboatGun) are given to the player?[/QUOTE]
You could detour Player:GiveAmmo and apply your own logic. Of course it'd be better to just not give unused ammo types.
[QUOTE=StonedPenguin;46188984]You could detour Player:GiveAmmo and apply your own logic. Of course it'd be better to just not give unused ammo types.[/QUOTE]
What are the possible detours?
I want it so that an absolutely custom ammo system is the last resort.
[editline]8th October 2014[/editline]
also for fonts, I can't seem to load up of a custom font. I put each ttf file in garrysmod/resource and garrysmod/resource/fonts and it isn't loading. I restarted gmod twice and the engine didn't seem to load the font.
Sorry, you need to Log In to post a reply to this thread.