• Print

Author Topic: Lua Halo Glow Help  (Read 26917 times)

0 Members and 1 Guest are viewing this topic.

Offline ChaosWolf

  • Jr. Member
  • **
  • Posts: 94
  • Karma: 2
  • "The Exiled One's" Server Owner
Re: Lua Halo Glow Help
« Reply #15 on: August 30, 2014, 03:25:00 pm »
[Macfan9000|7|STEAM_0:1:32363770] Lua Error:

[ERROR] lua/includes/extensions/util.lua:38: attempt to index local 'ply' (a nil
 value)
  1. GetPlayerTrace - lua/includes/extensions/util.lua:38
   2. GetTraceProp - lua/autorun/cl_halo.lua:9
    3. fn - lua/autorun/cl_halo.lua:18
     4. Run - addons/ulib/lua/ulib/shared/hook.lua:183
      5. fn - lua/includes/modules/halo.lua:163
       6. unknown - addons/ulib/lua/ulib/shared/hook.lua:183


server didn't like that either... this is where I am not understanding why its acting up.
"Someone once told me, scripting lua is like trying to build a rocket ship, once your finished with it and think your done, you start it up only to realize you had just built it upside down." ~Programmer

Offline Decicus

  • Hero Member
  • *****
  • Posts: 552
  • Karma: 81
    • Alex Thomassen
Re: Lua Halo Glow Help
« Reply #16 on: August 30, 2014, 05:24:53 pm »
As I said in my previous reply: "ply" is never defined (basically: doesn't exist) in your code. That is what "LocalPlayer()" is for, since the code is clientside, it will return the player object of the client.

Line 2 in the code should be
Code: [Select]
local trace = util.TraceLine( util.GetPlayerTrace( LocalPlayer() ) )as Neku originally had the code.
Contact information:
E-mail: alex@thomassen.xyz.
You can also send a PM.

Offline ChaosWolf

  • Jr. Member
  • **
  • Posts: 94
  • Karma: 2
  • "The Exiled One's" Server Owner
Re: Lua Halo Glow Help
« Reply #17 on: August 30, 2014, 06:29:12 pm »
Okay So the errors are gone. But the halo still isn't highlighting props. In fact as apposed to my hook on its own. It doesn't highlight anything. The hook as a standalone will highlight everything. I need a happy medium. I would appreciate a revision of at all possible.

Target/aiming at a prop should make it glow the designated color. Perhaps there is a way to make it go

Do This and do that
"Someone once told me, scripting lua is like trying to build a rocket ship, once your finished with it and think your done, you start it up only to realize you had just built it upside down." ~Programmer

Offline ChaosWolf

  • Jr. Member
  • **
  • Posts: 94
  • Karma: 2
  • "The Exiled One's" Server Owner
Re: Lua Halo Glow Help
« Reply #18 on: August 30, 2014, 11:22:19 pm »
NOPE I TAKE THAT BACK

[ERROR] stack overflow
  1. __mul - [C]:-1
   2. GetPlayerTrace - lua/includes/extensions/util.lua:43
    3. GetTraceProp - lua/autorun/cl_halo.lua:9
     4. GetTraceProp - lua/autorun/cl_halo.lua:10
      5. GetTraceProp - lua/autorun/cl_halo.lua:10
       6. GetTraceProp - lua/autorun/cl_halo.lua:10
        7. GetTraceProp - lua/autorun/cl_halo.lua:10
         8. GetTraceProp - lua/autorun/cl_halo.lua:10
          9. GetTraceProp - lua/autorun/cl_halo.lua:10
           10. GetTraceProp - lua/autorun/cl_halo.lua:10
            11. GetTraceProp - lua/autorun/cl_halo.lua:10
             12. GetTraceProp - lua/autorun/cl_halo.lua:10
              13. GetTraceProp - lua/autorun/cl_halo.lua:10
               14. GetTraceProp - lua/autorun/cl_halo.lua:10
                15. GetTraceProp - lua/autorun/cl_halo.lua:10
                 16. GetTraceProp - lua/autorun/cl_halo.lua:10


IM STILL GETTING A OVERFLOW OF ERRORS EVEN AFTER THE REVISION.
"Someone once told me, scripting lua is like trying to build a rocket ship, once your finished with it and think your done, you start it up only to realize you had just built it upside down." ~Programmer

Offline Neku

  • Hero Member
  • *****
  • Posts: 549
  • Karma: 27
Re: Lua Halo Glow Help
« Reply #19 on: August 31, 2014, 02:46:04 am »
Like I said, it's running much harder than intended.
Out of the Garry's Mod business.

Offline ChaosWolf

  • Jr. Member
  • **
  • Posts: 94
  • Karma: 2
  • "The Exiled One's" Server Owner
Re: Lua Halo Glow Help
« Reply #20 on: August 31, 2014, 08:57:52 am »
Yea I can see that, but how to fix it... That is the question. Even a revised version would be appreciated.
"Someone once told me, scripting lua is like trying to build a rocket ship, once your finished with it and think your done, you start it up only to realize you had just built it upside down." ~Programmer

Offline ChaosWolf

  • Jr. Member
  • **
  • Posts: 94
  • Karma: 2
  • "The Exiled One's" Server Owner
Re: Lua Halo Glow Help
« Reply #21 on: September 04, 2014, 11:47:07 am »
so everyone just gave up on it?
"Someone once told me, scripting lua is like trying to build a rocket ship, once your finished with it and think your done, you start it up only to realize you had just built it upside down." ~Programmer

Offline ChaosWolf

  • Jr. Member
  • **
  • Posts: 94
  • Karma: 2
  • "The Exiled One's" Server Owner
Re: Lua Halo Glow Help
« Reply #22 on: September 04, 2014, 12:52:48 pm »
so I tried something a bit different and here is what I have, but its not liking the self.Entity and calls it a nil value, so I need to use another reference but what do I call it, I removed the portion of code Neku offered simply because the hook functions on its own but it highlights all props. I want it to highlight what prop you're looking at and when you look away it doesn't highlight it. I added another line to the hook in hopes that this may get it to render distance and only what your looking at.

Code: Lua
  1. hook.Add( "PreDrawHalos", "AddHalos", function()
  2.  if ( LocalPlayer():GetEyeTrace().Entity == self.Entity && EyePos():Distance( self.Entity:GetPos() ) < 512 ) then
  3.          halo.Add( GetTraceProp(), Color( 140, 0, 255 ), 5, 5, 2 )
  4.         end
  5. end)

so what do I change self.Entity to?
 I have tried ply, Self, and for laughs and giggles GetTraceProp (I know... -_- but I tried it anyway)
"Someone once told me, scripting lua is like trying to build a rocket ship, once your finished with it and think your done, you start it up only to realize you had just built it upside down." ~Programmer

Offline JamminR

  • Ulysses Team Member
  • Hero Member
  • *****
  • Posts: 8096
  • Karma: 390
  • Sertafide Ulysses Jenius
    • Team Ulysses [ULib/ULX, other fine releases]
Re: Lua Halo Glow Help
« Reply #23 on: September 04, 2014, 01:09:09 pm »
Chaos, been too long since I looked at any indepth code, but, perhaps finding/looking at the Gmod hoverball code might help, at least to find out how it does the 'selection' when a player looks at it. There's a few other standard tools that highlight items when being looked at too.
Hoverballs highlights and does the popup bubble with strength/power levels, etc.
"Though a program be but three lines long, someday it will have to be maintained." -- The Tao of Programming

Offline ChaosWolf

  • Jr. Member
  • **
  • Posts: 94
  • Karma: 2
  • "The Exiled One's" Server Owner
Re: Lua Halo Glow Help
« Reply #24 on: September 04, 2014, 04:25:26 pm »
i see what your getting at, there is also a left 4 dead 2 script that can be ported that does the same thing. I can edit existing code, but I have a difficult time creating my own, if I know the code for it and how it works, I can use it. and that is where my problem lies, I don't know what to replace self.Entity with. its saying "if a player is looking at something and you are the player, and your eye position is fixed on an item and you see an item less than 512 then add the halo around the outline of the prop that is the color purple."

so I don't know what else to call a player other then ply if I make a port of an existing script. that will be much more complicated considering the length of them, I will use that as a last resort. if I manage to get it working then I will release the ported version. as well as a ReadMe to configure it. in fact, I will leave this code here and see what I can do with that.

thanks JamminR
"Someone once told me, scripting lua is like trying to build a rocket ship, once your finished with it and think your done, you start it up only to realize you had just built it upside down." ~Programmer

Offline Avoid

  • Full Member
  • ***
  • Posts: 142
  • Karma: 42
Re: Lua Halo Glow Help
« Reply #25 on: September 04, 2014, 08:44:44 pm »
So what im wanting is to make a code so that the client will highlight the target he/she is currently marking, say I am trying to select a small object surrounded by many other objects, it is to help with accuracy in selecting items. here's what I have so far.

Code: Lua
  1. hook.Add( "PreDrawHalos", "AddHalos", function()
  2.         halo.Add( ents.FindByClass( "prop_physics*" ), Color( 255, 0, 0 ), 5, 5, 2 )
  3. end )

but this makes all props glow, I just need something to say if ply:TEAM_PROP then do
but im not sure how to get it to work properly and in such a way that only targeted props are highlighted.

I'm still new to lua and am learning as I go. so I could use the help. anyone care to help me revise it?
Hello there,
if you want to get the entity the player is currently looking at you should look at traces in the Wiki.

EDIT: I saw Naku and Decious already helped you. :)

Then you could simply check if the trace returns a valid entity like so:
Code: [Select]
function Halos()
local tr = LocalPlayer():GetEyeTraceNoCursor()
local trace = {}
trace.start = tr.StartPos
trace.endpos = trace.start + LocalPlayer():GetAimVector() * 10000
trace.filter = self
trace.mask = MASK_SHOT

if IsValid(tr.Entity) and !tr.Entity:IsPlayer() then
if tr.HitPos:Distance(tr.StartPos) < 1000 then
local col = Color(50, 220, 200)
halo.Add({tr.Entity}, col, 2, 2, 2, true, true)
end
end
end

hook.Add( "PreDrawHalos", "DrawHalos", Halos )
« Last Edit: September 04, 2014, 08:53:36 pm by Avoid »

Offline ChaosWolf

  • Jr. Member
  • **
  • Posts: 94
  • Karma: 2
  • "The Exiled One's" Server Owner
Re: Lua Halo Glow Help
« Reply #26 on: September 05, 2014, 07:54:48 pm »
so the completed code should look like what, cause everytime I rewrite it I break it
"Someone once told me, scripting lua is like trying to build a rocket ship, once your finished with it and think your done, you start it up only to realize you had just built it upside down." ~Programmer

Offline ChaosWolf

  • Jr. Member
  • **
  • Posts: 94
  • Karma: 2
  • "The Exiled One's" Server Owner
Re: Lua Halo Glow Help
« Reply #27 on: September 10, 2014, 12:57:13 pm »
OHHHH I DIDNT SEE THE CODE, ok... that makes sense, ive made some minor changes like the color of course, changed the trace distance, etc... so I'm going to post it for download in the original OP. and am I allowed to post anything in the releases section cause I have some custom Pointshop items I made that I would like to share as well.
"Someone once told me, scripting lua is like trying to build a rocket ship, once your finished with it and think your done, you start it up only to realize you had just built it upside down." ~Programmer

Offline JamminR

  • Ulysses Team Member
  • Hero Member
  • *****
  • Posts: 8096
  • Karma: 390
  • Sertafide Ulysses Jenius
    • Team Ulysses [ULib/ULX, other fine releases]
Re: Lua Halo Glow Help
« Reply #28 on: September 10, 2014, 06:31:09 pm »
and am I allowed to post anything in the releases section cause I have some custom Pointshop items I made that I would like to share as well.
As long as the code works reasonably well, and you can support when it doesn't.
We'd strongly prefer any releases be related to ULib in some way, etc.
"Though a program be but three lines long, someday it will have to be maintained." -- The Tao of Programming

Offline ChaosWolf

  • Jr. Member
  • **
  • Posts: 94
  • Karma: 2
  • "The Exiled One's" Server Owner
Re: Lua Halo Glow Help
« Reply #29 on: September 10, 2014, 08:42:55 pm »
this is why I ask before doing things like that. perhaps a new board can be made for developers who complete scripts and have a place to share them. I mean, im not a terribad coder, I just suck at tables and vectors... all things in good time though.
"Someone once told me, scripting lua is like trying to build a rocket ship, once your finished with it and think your done, you start it up only to realize you had just built it upside down." ~Programmer

  • Print