• Problems That Don't Need Their Own Thread v3.0
    5,003 replies, posted
This probably isn't a great place to ask for C++ help, but here goes... When compiling my module on Linux, IVEngineServer::PEntityOfEntIndex() always returns null. Using a fairly recent version of gcc and Source Sdk 2013 headers/libraries. Using eifacev21.h because the other one wasn't working at all. Any ideas?
[QUOTE=Tomelyr;47805469][img]http://wiki.garrysmod.com/favicon.ico[/img] [url=http://wiki.garrysmod.com/page/net/Broadcast]net.Broadcast[/url] exists for a reson.[/QUOTE] sorry that I don't know everything also going to quote my earlier post to try to bring attention back to a question that hasn't been answered yet [QUOTE=Mossman1223;47803497]How does one make lua effects? I tried copying the balloon_pop effect from sandbox, renaming it and putting it in myaddon/lua/entities/effects but it's not being loaded.[/QUOTE]
[QUOTE=MadParakeet;47806005]This probably isn't a great place to ask for C++ help, but here goes... When compiling my module on Linux, IVEngineServer::PEntityOfEntIndex() always returns null. Using a fairly recent version of gcc and Source Sdk 2013 headers/libraries. Using eifacev21.h because the other one wasn't working at all. Any ideas?[/QUOTE] Garry's Mod uses the old V21 Engine interface. Not sure what the eifacev21.h does but it sounds like it should cooperate. If not you can try using eiface.h again and use the INTERFACEVERSION_VENGINESERVER_VERSION_21 define as the first argument to interfacefactory. Also [url=https://github.com/FgtHouse/fgt_navstuff/blob/48a8460b87ed22332a27fb42728a2cccc93bc50d/src/plugincallbacks.cpp#L205]here's[/url] my usage of PEntityOfEntIndex if it helps any.
returning to my series of "stupid questions i need help with" i have a DColorMixer in a menu that I'm trying to set a faction/team color with, however whenever I try to GetColor() from it, it always returns the default (255,0,0), even after changing etc, is there a better/proper way to get the currently selected color from it? [lua] local factionrgb = vgui.Create("DColorMixer", factionpanel) factionrgb:SetPalette(false) factionrgb:SetAlphaBar(false) factionrgb:SetSize(230,100) factionrgb:SetPos(250,10) factionColor = factionrgb:GetColor() [/lua] printing factionColor.r/g/b etc always returns "255 0 0"
[QUOTE=mcd1992;47807507]Garry's Mod uses the old V21 Engine interface. Not sure what the eifacev21.h does but it sounds like it should cooperate. If not you can try using eiface.h again and use the INTERFACEVERSION_VENGINESERVER_VERSION_21 define as the first argument to interfacefactory. Also [URL="https://github.com/FgtHouse/fgt_navstuff/blob/48a8460b87ed22332a27fb42728a2cccc93bc50d/src/plugincallbacks.cpp#L205"]here's[/URL] my usage of PEntityOfEntIndex if it helps any.[/QUOTE] I finally figured it out. First I tried switching to the other header. Then I got it into my head that there was some issue with the linker, because fuck the linker, right? Then I got to thinking, and realized that none of the interfaces were working correctly, and the module was still somehow mostly functioning correctly. I looked at the specific libraries the server was loading, and realized most of them were postfixed with _srv. I changed the module name in my code from "engine" to "engine_srv". Seems to be working now. Regardless, the server has both "engine" and "engine_srv", but the normal one isn't used. [B]ARE YOU FUCKING KIDDING ME?[/B] Anyhow, thanks for trying to help. I see you're loading a plugin in your module. Is that just so you can use those callbacks, or is there some kind of advantage? [editline]26th May 2015[/editline] [QUOTE=Smt;47808604]is there a better/proper way to get the currently selected color from it?[/QUOTE] [URL="https://github.com/garrynewman/garrysmod/blob/4eb9bb19dcfac06007691376ecaf2dbc56efa6b2/garrysmod/lua/vgui/dcolormixer.lua#L379"]Weird, looks like GetColor is supposed to work...[/URL] I suspect fuckery. Maybe see if m_Color has the correct value? I avoid VGUI stuff like the plague, so I might not be a good person to help you.
[QUOTE=MadParakeet;47808823]Maybe see if m_Color has the correct value?[/QUOTE] this is where I gotta come clean, I have no idea what I'm really doing with lua - and how or where I would check that
-snip- Silly me.
[QUOTE=MadParakeet;47808823]I finally figured it out. First I tried switching to the other header. Then I got it into my head that there was some issue with the linker, because fuck the linker, right? Then I got to thinking, and realized that none of the interfaces were working correctly, and the module was still somehow mostly functioning correctly. I looked at the specific libraries the server was loading, and realized most of them were postfixed with _srv. I changed the module name in my code from "engine" to "engine_srv". Seems to be working now. Regardless, the server has both "engine" and "engine_srv", but the normal one isn't used. [B]ARE YOU FUCKING KIDDING ME?[/B] Anyhow, thanks for trying to help. I see you're loading a plugin in your module. Is that just so you can use those callbacks, or is there some kind of advantage? [/QUOTE] I needed access to the engine's tick/frame callback so I made it a hybrid lua/source plugin. The only other advantage really is it's (questionably) easier to get access to all the interfaces. But it's more difficult to initially setup the module to load as both a source and lua plugin. Also engine.so is the client's version, not sure why it's being shipped with the ds. [code] GarrysMod Client: 02088d8005525f6d1d32b089a7d4f662 engine.so GarrysModDS: 02088d8005525f6d1d32b089a7d4f662 bin/engine.so e2ee56232d790c9e158c89c6f0b87df6 bin/engine_srv.so [/code]
[QUOTE=Smt;47808920]this is where I gotta come clean, I have no idea what I'm really doing with lua - and how or where I would check that[/QUOTE] Wait, are you expecting the color object you get to update/change? You need to call factionrgb:GetColor() every time you want to get the color.
[QUOTE=MadParakeet;47809426]Wait, are you expecting the color object you get to update/change? You need to call factionrgb:GetColor() every time you want to get the color.[/QUOTE] Right now I'm just trying to print the output to make sure it works, eventually i wanna feed the output into the color for factions/groups in this gamemode so, I think I get what's wrong, getting the GetColor is only happening once as the colorpicker is being created, and that's why it's stuck to 255,0,0? would it be possible/better to make it get the color while it's actually in use? I see "DColorMixer/ValueChanged" is a thing but there's no wiki page for it on the new one or the old one but I guess I can somehow use that to make it actually work how I'm expecting it too? EDIT: okay yeah that really was one of those stupid things i need to remember, thanks parakeet (i have no idea if i need to make the variable like this but hey it works) [lua]factionrgb.ValueChanged = function( self, color ) factionColor = color end[/lua] [img]http://i.imgur.com/UCr6qCm.png[/img]
Anyone know how can i precompile code (Like with any other LuaJIT based app) ? With love2d, i can compile the code using [code] ./luajit.exe -b input.lua output.lua[/code] And it does works, if the LuaJIT version is the sames, it's working (Under Löve 2d or any other LuaJIT app). But with Gmod i got this error : [QUOTE] [ERROR] lua/gmd.lua: cannot load malformed bytecode 1. unknown - lua/gmd.lua:0 [/QUOTE] Is GMod using some kind of custom LuaJIT but without version change ? (That's the error when you try to compile the code under a version of LuaJIT and "read" it under another version)
[QUOTE=ExtReMLapin;47812277]Anyone know how can i precompile code (Like with any other LuaJIT based app) ? With love2d, i can compile the code using [code] ./luajit.exe -b input.lua output.lua[/code] And it does works, if the LuaJIT version is the sames, it's working (Under Löve 2d or any other LuaJIT app). But with Gmod i got this error : Is GMod using some kind of custom LuaJIT but without version change ? (That's the error when you try to compile the code under a version of LuaJIT and "read" it under another version)[/QUOTE] gmod doesn't support loading bytecode.
[QUOTE=ExtReMLapin;47812277]Anyone know how can i precompile code (Like with any other LuaJIT based app) ? With love2d, i can compile the code using [code] ./luajit.exe -b input.lua output.lua[/code] And it does works, if the LuaJIT version is the sames, it's working (Under Löve 2d or any other LuaJIT app). But with Gmod i got this error : Is GMod using some kind of custom LuaJIT but without version change ? (That's the error when you try to compile the code under a version of LuaJIT and "read" it under another version)[/QUOTE] As cake said, you can't load bytecode. You can make a module to load it, though.
Simple question. For DamageInfo, what would I SetInflictor() to if I want to give credit for Fall Damage? SetAttacker(ply) and SetInflictor(ply) is creating the kill icon for the weapon they're holding...
[QUOTE=WalkingZombie;47812497]Simple question. For DamageInfo, what would I SetInflictor() to if I want to give credit for Fall Damage? SetAttacker(ply) and SetInflictor(ply) is creating the kill icon for the weapon they're holding...[/QUOTE] The inflictor is usually the weapon. If there's no weapon in this instance, you either have it at NULL or game.GetWorld().
[QUOTE=Willox;47812509]The inflictor is usually the weapon. If there's no weapon in this instance, you either have it at NULL or game.GetWorld().[/QUOTE] I love how after I rated you, it says "don't post about this" Thanks for the help. [editline]26th May 2015[/editline] or not... [code] GDMG:SetAttacker( ply ) GDMG:SetInflictor( game.GetWorld() )[/code] Still showing the weapon icon in the kill feed.
[QUOTE=WalkingZombie;47812521]I love how after I rated you, it says "don't post about this"[/QUOTE] then why did you post about it???
for NULL: [quote=That Developer Console Thingy][ERROR] lua/autorun/dkdr_falling_plugin.lua:33: Tried to use a NULL entity! 1. SetInflictor - [C]:-1 2. v - lua/autorun/dkdr_falling_plugin.lua:33 3. unknown - lua/includes/modules/hook.lua:84[/quote] game.GetWorld() still shows the weapon icon.
[QUOTE=WalkingZombie;47812537]for NULL:[/QUOTE] It should default to NULL, I might be wrong and it might default to the world entity. Whatever the default is will be fine for fall damage.
[QUOTE=Willox;47812541]It should default to NULL, I might be wrong and it might default to the world entity. Whatever the default is will be fine for fall damage.[/QUOTE] Uhm, the default still shows the gun icon, which is why I asked :( [editline]26th May 2015[/editline] I'd still love to know how to make the game believe the "weapon" or "inflictor" of my DamageInfo is the world. It works fine in the GetFallDamage hook, but not in the OnPlayerHitGround hook. [B]But now I have a new problem[/B] [code]CreateConVar( "dkdr_cvarname", "1.0", 0, "Stuff" ) ( GetConvar("dkdr_cvarname"):GetFloat() )[/code] [quote=That Beautiful Developer's Console][ERROR] lua/autorun/dkdr_stuff.lua:15: attempt to call global 'GetConvar' (a nil value) 1. v - lua/autorun/dkdr_stuff.lua:15 2. unknown - lua/includes/modules/hook.lua:84[/quote]
[QUOTE=WalkingZombie;47812551]Uhm, the default still shows the gun icon, which is why I asked :( [editline]26th May 2015[/editline] I'd still love to know how to make the game believe the "weapon" or "inflictor" of my DamageInfo is the world. It works fine in the GetFallDamage hook, but not in the OnPlayerHitGround hook. [B]But now I have a new problem[/B] [code]CreateConVar( "dkdr_cvarname", "1.0", 0, "Stuff" ) ( GetConvar("dkdr_cvarname"):GetFloat() )[/code][/QUOTE] GetConVar. Instead of using that global, store the cvar returned by CreateConVar, then use variable:Get*(). It's cheaper to not have to find the cvar, since you already have it.
[QUOTE=vexx21322;47813254]GetConVar. Instead of using that global, store the cvar returned by CreateConVar, then use variable:Get*(). It's cheaper to not have to find the cvar, since you already have it.[/QUOTE] Is it cheaper to do that in a SetupMove hook?
GetConVar is a hilariously slow function, same with GetConVarNumber, GetConVarString or anything else that has to search for a ConVar. ConVars themselves are really fast, though.
No. I can't do that. The value changes, but it doesn't update in the script Either that, or I have no idea what I'm doing when I'm trying to scale how high a player jumps.
[QUOTE=WalkingZombie;47813386]No. I can't do that. The value changes, but it doesn't update in the script[/QUOTE] [code] local myVar = CreateConVar( "myVar" ) hook.Add( "Think", "", function() print( myVar:GetFloat() ) end ) [/code]
Looks to be the latter. [editline]27th May 2015[/editline] Yeah, I did the print debug thing. So I'm not really scaling the jump apparently... [editline]27th May 2015[/editline] Nevermind everything I said... I got it to work soon after [del]I made my last post.[/del] first made THIS post. [editline]27th May 2015[/editline] As for performance, you don't think it's bad enough that I have for k, v in pairs( player.GetAll() ) in think functions? Is there a better alternative?
[QUOTE=WalkingZombie;47813393]Looks to be the latter. [editline]27th May 2015[/editline] Yeah, I did the print debug thing. So I'm not really scaling the jump apparently... [editline]27th May 2015[/editline] Nevermind everything I said... I got it to work soon after [del]I made my last post.[/del] first made THIS post. [editline]27th May 2015[/editline] As for performance, you don't think it's bad enough that I have for k, v in pairs( player.GetAll() ) in think functions? Is there a better alternative?[/QUOTE] do you have multiple ones? Cache player.GetAll() to a variable at the start of your think function.
[QUOTE=PigeonPatrol;47813686]do you have multiple ones? Cache player.GetAll() to a variable at the start of your think function.[/QUOTE] or you could iterate once?
[QUOTE=Willox;47813366]GetConVar is a hilariously slow function, same with GetConVarNumber, GetConVarString or anything else that has to search for a ConVar. ConVars themselves are really fast, though.[/QUOTE] So what if I want to reference the ConVar in a different script?
Then you GetConVar it and store it in a variable at the top of the script.
Sorry, you need to Log In to post a reply to this thread.