• UtilX -- Extending GLua -- Need community input
    371 replies, posted
:( That's depressing.
Wanna give the real creator of that, credits kahn?
No clue if this'll work, but it's generally what I'm looking for. [b]utilx.PlayerCanSee(object,player) -- Is it within their LOS?[/b] On the client: [lua]local function PlayerCanSee(obj) if type(obj) == "vector" then return tobool(obj:GetPos():ToScreen().visible) else local posmin, posmax = obj:GetPos()+obj:OBBMaxs(), obj;GetPos()+obj:OBBMins() if tobool(posmin:ToScreen().visible) == true or tobool(posmax:ToScreen().visible) == true then return true else return false end end end datastream.Hook("sv_playerCanSee",function(hand,id,enc,dec) datastraam.StreamToServer("cl_playerCanSee",PlayerCanSee(dec)) end)[/lua] Shared, I guess? [lua]function utilx.PlayerCanSee(obj,ply) if CLIENT then return PlayerCanSee(obj) else local bool = false datastream.Hook("cl_playerCanSee",function(pl,hand,id,enc,dec) bool = dec) datastream.StreamToClients(ply,"sv_playerCanSee",obj) return bool end end[/lua] Once again, not sure if this'll work at all.
return (tobool(posmin:ToScreen().visible) or tobool(posmax:ToScreen().visible)) shorter
[lua] function utilx.PlayerCanSee(ply, obj) if(!ply || !ply:IsValid() || !ply:IsPlayer()) then return false end if(!obj) then return false end local posmin, posmax = 0, 0 if(type(obj) == "vector") then posmin, posmax = obj, obj else if(!obj:IsValid()) then return false end posmin, posmax = obj:GetPos() + obj:OBBMaxs(), obj;GetPos() + obj:OBBMins() end if CLIENT then return (posmin:ToScreen().visible + posmax:ToScreen().visible) > 0 else local eye = ply:GetPos() + ply:GetViewOffset() local tMin = util.TraceLine({start=eye, endpos=posmin}) -- If it didnt hit, it must be visible! And if it did hit, and it hit our Entity then we can see it. if(!tMin.Hit || (tMin.Hit && tMin.Entity == obj)) then return true end local tMax = util.TraceLine({start=eye, endpos=posmax}) if(!tMax.Hit || (tMax.Hit && tMax.Entity == obj)) then return true end return false end return false end [/lua] That should work better. And it is also shared, server has more of an estimation, but same principle.
[QUOTE=Entoros;16727876]No clue if this'll work, but it's generally what I'm looking for. [b]utilx.PlayerCanSee(object,player) -- Is it within their LOS?[/b] On the client: [lua]local function PlayerCanSee(obj) if type(obj) == "vector" then return tobool(obj:GetPos():ToScreen().visible) else local posmin, posmax = obj:GetPos()+obj:OBBMaxs(), obj;GetPos()+obj:OBBMins() if tobool(posmin:ToScreen().visible) == true or tobool(posmax:ToScreen().visible) == true then return true else return false end end end datastream.Hook("sv_playerCanSee",function(hand,id,enc,dec) datastraam.StreamToServer("cl_playerCanSee",PlayerCanSee(dec)) end)[/lua] Shared, I guess? [lua]function utilx.PlayerCanSee(obj,ply) if CLIENT then return PlayerCanSee(obj) else local bool = false datastream.Hook("cl_playerCanSee",function(pl,hand,id,enc,dec) bool = dec) datastream.StreamToClients(ply,"sv_playerCanSee",obj) return bool end end[/lua] Once again, not sure if this'll work at all.[/QUOTE] Why on earth do you use DATASTREAM for shared functions? In the last few weeks I've seen more and more of this shit datastream usage, people should really learn for what datastream was made...
[QUOTE=The-Stone;16731451]Why on earth do you use DATASTREAM for shared functions? In the last few weeks I've seen more and more of this shit datastream usage, people should really learn for what datastream was made...[/QUOTE] Agreed, They are using datastream for the strangest reasons. I suppose they find it easier to work with. Where do people pick up all these strange programming conventions and styles?
@OP - I wonder how you came up with this idea /sarcasm
[lua]function utilx.PlayerCanSee( obj, ply ) return obj:Visible( ply ) end[/lua]
Does that use the player's eyes? Or the players origin.
Eyes. Isn't that obvious?
No, but yes, it does use eyes.
[cpp]int UTIL_EntitiesAlongRay( const Ray_t &ray, CFlaggedEntitiesEnum *pEnum ) { partition->EnumerateElementsAlongRay( PARTITION_ENGINE_NON_STATIC_EDICTS, ray, false, pEnum ); return pEnum->GetCount(); }[/cpp] I'd like to see a lua version of this.
Any ETA on a release?
I've started work on the UtilX dll. The goal is to have all the useful dlls come out of the binaries forum. So in the end we have a single dll that works on both clientside and serverside and encompasses all the functions wanted badly by developers. So far I have implemented: gmcl_renderx gmcl_chrome gm_luaprof gmcl_steamid gmsv_datadesc gm_sockets(Or possibly a custom stream system, so we can perhaps have a better stream/umsg/netvar system) DLLs that should not be inside this include: gm_rawio gm_cvar2 And anything else that can do bad naughty stuff. Currently I have a cool modular design so you only load what you need. [lua] require("utilx") utilx.require("renderx") utilx.require("profile") [/lua]
I guess you have to get garry to add it by default in gmod if you gonna inlcude chrome..
You didn't even bother asking the module authors. I don't mean to sound cold or anything, but I don't want my module bundled with something whose creator won't even take the time to ask the author if they would like it bundled or not. Had you asked, my reaction would most likely have been different. [quote]functions wanted badly by developers[/quote] All these functions that you claim are badly wanted by developers, are in fact, available to developers.
[QUOTE=Jinto;16754239]You didn't even bother asking the module authors. I don't mean to sound cold or anything, but I don't want my module bundled with something whose creator won't even take the time to ask the author if they would like it bundled or not. Had you asked, my reaction would most likely have been different. All these functions that you claim are badly wanted by developers, are in fact, available to developers.[/QUOTE] Well he has not actually released anything yet. Really he only has to ask permission if and when he wants to release it. He was just saying what he intends to do and what he is working on.
[QUOTE=Carnag3;16754767]Well he has not actually released anything yet. Really he only has to ask permission if and when he wants to release it. He was just saying what he intends to do and what he is working on.[/QUOTE] What he intends to do, uses not just my module but modules from numerous other authors. For this type of project, it makes sense to ask before you go through all the work, only in the end, before release, to have 50% of those authors say no.
Atm this is just a proof of concept to see if they can coexist in a single dll. At this point in time it won't be released. After this I will talk with the original developers of course. I respect your work.
I thought the purpose of this was to extend onto the util library and add useful functions, not copy-paste a bunch of dlls together.
Exactly. And preferrably not inside of a dll at all, unless it HAS to be.
Honestly it'd be really useful to me personally if I only had to include a single DLL with a gamemode download. It's a pain in the ass to have people have to worry about a bunch of DLLs.
Exactly. And they have to worry about the origin. If its a unified dll, that can be trusted by the community, and not exploited then we will see some interesting game modes come out for sure.
I guess someone could trawl through the thread and gather up all the snippets into 1 lua file. What, don't look at me -_-
Apologies for the bump, but I'd like to know that all of the effort in this thread isn't going to waste. Is anyone still trying to create the UtilX library?
Yup. Release is tomorrow (hopefully).
[QUOTE=haza55;16753247] Currently I have a cool modular design so you only load what you need. [lua] require("utilx") utilx.require("renderx") utilx.require("profile") [/lua][/QUOTE] -snip- Last time I don't read the entire thread...
lol
[quote=Kogitsune]They're two different things, honestly. GM+ is a more or less lite enhancement pack while this would be aimed more towards coders directly.[/quote] Deprecated download. The only reason for downloading the framework (if finished) would be because another addon which required it would be broken (or half available) without it. Useless. The GMod Plus project was designed for both ends, player and programmer; to be a majorly popular addon upon release, which would then be motivation for programmers to use the internal frameworks included. Or is it just me who notices the loads of wiremod, and phx downloads on garrysmod.org?
Sorry, you need to Log In to post a reply to this thread.