• Problems That Don't Need Their Own Thread v2.0
    5,020 replies, posted
[QUOTE=Tomelyr;47070101]To get the updated Health after Damage you need to modify the local health with the new health. An Easy way would be to move the health variable into the paint hook, but so the function got called very often. Otherwise you could hook [img]http://wiki.garrysmod.com/favicon.ico[/img] [url=http://wiki.garrysmod.com/page/GM/PlayerHurt]GM/PlayerHurt[/url] with an check if victim == localplayer and then reset the health variable. an good way to start with the hook system is to use the basic [url]http://wiki.garrysmod.com/page/Hook_Library_Usage[/url] guide or summon Acecool[/QUOTE] That wiki page helped a ton, thanks! [QUOTE=bobbleheadbob;47070225]Well here's the reality of just about every program that exists which isn't just a run-one-then-done. A program is just a BIG infinite loop. This loop runs all the commands, reaches the end, and starts itself again until the user tells the loop to exit, shutting the program down. Each run of this loop is a "Frame", and these frames are VERY fast. This is where the term Frames Per Second comes in. During each frame in Garry's Mod, the game does a bunch of things, including checking a bunch of things to see if they have changed and calling "Hooks" if they have changed (or just calling hooks because they are called every frame). Every frame, the "Think" hook and the "HUDPaint" hook are called on the client (among other hooks). This means that code ran in these hooks are basically ran in real time. For instance, before "HUDPaint" is called, the HUD is cleared completely, at which point you can draw the new and refreshed hud. So if you had a bar which was very wide at full health, and the health of the player drops between two frames, the width of the bar will be thinner when the old one is cleared and a brand new one is drawn. This can be confusing, and if you don't understand that's fine. Just know that "HUDPaint" is ran basically every millisecond. Therefore, if the player's health changes, in the next millisecond the HUD will update if you do your code like this: [/QUOTE] I'm pretty sure I understand now, and I got it working as intended!(Thanks!) So by putting the local health = LocalPlayer():Health() inside the HUDPaint hook, it constantly updated since the HUDPaint is like the Think hook where it's constantly being "Refreshed"?
[QUOTE=ThrowAwayAcct;47068837]So all my script files are well under 64kb, so it's not a size issue. This is also SinglePlayer, so iunno how that affects networking, but in any case I don't think that's the problem. I cleaned up my addons (subscribed to, like, 10 addons now), wiped out my garrysmod folder (everything deleted, after of course copying out the addon i'm working on, in legacy format), then uninstalled gmod. Then I reinstalled gmod, then restarted my computer, started gmod, let it redownload my ten addons, then put my addon in and restarted gmod. After all this, it still happens. When I make changes to an autorun file, sometimes it reloads it fine and sometimes the game just crashes instantly. I took a relevant MDMP file to a website to parse it, it got me the console output right before crashing, and I see nothing of interest. I don't know why the lua auto-refresh is crashing gmod. [b]Can anyone tell me of a way to disable it, perhaps?[/b] Like a console command? In the olden days of GM12, I used lua_reloadents to reload my scripts, and I still have a key bound for that purpose. Perhaps I can fallback to that after disabling lua autorefresh? [b]EDIT:[/b] Thanks, RobotBoy, for the link. I tried to see if the console would complete any kind of command for autorefresh for me, and it didn't show me anything. That page has some very insteresting info I'll take into account.[/QUOTE] Feel free to use my autoloader; it uses loadaddon as a console command to refresh the addon... I'll be releasing a newer version which has a few more features very soon. [url]https://bitbucket.org/Acecool/acecooldev_networking/[/url] in autorun/ Also, are you auto-refreshing with bots or other players AND with vehicles spawned in? [editline]4th February 2015[/editline] [QUOTE=Kamber56;47070343]That wiki page helped a ton, thanks! I'm pretty sure I understand now, and I got it working as intended!(Thanks!) So by putting the local health = LocalPlayer():Health() inside the HUDPaint hook, it constantly updated since the HUDPaint is like the Think hook where it's constantly being "Refreshed"?[/QUOTE] Make sure you're using SRCDS to test code, it's easy: [url]https://dl.dropboxusercontent.com/u/26074909/tutoring/server_srcds_steamcmd/setting_up_a_server_with_steamcmd.lua.html[/url] Also, yes; those are getter functions that retrieve the value for use. They're meant to be called many times per frame, also to avoid errors with using LocalPlayer( ) in HUDPaint ( because LocalPlayer( ) is not valid for the first few frames the hook is called ) you'll want to add a few checks... Here's how to properly create HUDPaint elements: [url]https://dl.dropboxusercontent.com/u/26074909/tutoring/hud/proper_hud_creation.lua.html[/url] Scaling: [url]https://dl.dropboxusercontent.com/u/26074909/tutoring/hud/understanding_hardcoding_of_screensizes.lua.html[/url] General optimization and errors people make which can cause issues: [url]https://dl.dropboxusercontent.com/u/26074909/tutoring/optimization/_generalized_optimization_guide.lua.html[/url] And some other guides: [url]https://dl.dropboxusercontent.com/u/26074909/tutoring/hud/basic_healthbar.lua.html[/url] [url]https://dl.dropboxusercontent.com/u/26074909/tutoring/poly/creating_shapes_using_poly.lua.html[/url]
[QUOTE=] Also, yes; those are getter functions that retrieve the value for use. They're meant to be called many times per frame, also to avoid errors with using LocalPlayer( ) in HUDPaint ( because LocalPlayer( ) is not valid for the first few frames the hook is called ) you'll want to add a few checks... Here's how to properly create HUDPaint elements: [url]https://dl.dropboxusercontent.com/u/26074909/tutoring/hud/proper_hud_creation.lua.html[/url] Scaling: [url]https://dl.dropboxusercontent.com/u/26074909/tutoring/hud/understanding_hardcoding_of_screensizes.lua.html[/url] General optimization and errors people make which can cause issues: [url]https://dl.dropboxusercontent.com/u/26074909/tutoring/optimization/_generalized_optimization_guide.lua.html[/url] And some other guides: [url]https://dl.dropboxusercontent.com/u/26074909/tutoring/hud/basic_healthbar.lua.html[/url] [url]https://dl.dropboxusercontent.com/u/26074909/tutoring/poly/creating_shapes_using_poly.lua.html[/url][/QUOTE] A lot of the things in those links I don't understand so i'll probably save them for future reference, but there's definitely a few points in which those links clear up, and explain the HUD/Panels a lot clearer than anywhere else i've seen, Thanks One thing i've seen a lot but don't understand what it does is a ! before things. For example, what does putting the ! before certain things like IsValid() do?
[QUOTE=Kamber56;47072940]A lot of the things in those links I don't understand so i'll probably save them for future reference, but there's definitely a few points in which those links clear up, and explain the HUD/Panels a lot clearer than anywhere else i've seen, Thanks One thing i've seen a lot but don't understand what it does is a ! before things. For example, what does putting the ! before certain things like IsValid() do?[/QUOTE] ! is the "logical not" operator. You can also use the word "not" instead of it. "!true" is equal to false. "not true" is equal to false. "!false" is equal to true. "not false" is equal to true. When being 'converted' to a boolean, any value that is not false and is not nil is treated as true.
[QUOTE=Willox;47072949] "not false" is equal to false. [/QUOTE] [img]http://i.imgur.com/AvlIEiT.png[/img]
[QUOTE=Robotboy655;47072954][img]http://i.imgur.com/AvlIEiT.png[/img][/QUOTE] typo i swear i'm not dumb :downs:
[QUOTE=Willox;47072949]! is the "logical not" operator. You can also use the word "not" instead of it. "!true" is equal to false. "not true" is equal to false. "!false" is equal to true. "not false" is equal to true. When being 'converted' to a boolean, any value that is not false and is not nil is treated as true.[/QUOTE] Ohh okay, thanks for clearing that up. I also see .. used alot. Usually between a variable and a string such as HP .. " HP" or something. Does that actually do anything or is it to make it look neater?
[QUOTE=Kamber56;47072985]Ohh okay, thanks for clearing that up. I also see .. used alot. Usually between a variable and a string such as HP .. " HP" or something. Does that actually do anything or is it to make it look neater?[/QUOTE] It's the concatenation operator. It joins multiple strings (or string representations of the given values) in to a single string. This information is available in the PIL. [url]https://dl.dropboxusercontent.com/u/14265905/Programming%20in%20Lua%205.1.pdf[/url]
[QUOTE=Kamber56;47072985]Ohh okay, thanks for clearing that up. I also see .. used alot. Usually between a variable and a string such as HP .. " HP" or something. Does that actually do anything or is it to make it look neater?[/QUOTE] It is a operator for concatenating two strings ( joining two strings together ). So "my " .. "string" becomes "my string". This is useful when you want to put a value from a variable into your string for example.
You connect two strings together using it. [code] local connected = 'I am a ' .. 'connected string' .. '!' [/code]
Ah, Thanks!
Hey, I know images have to be power of two, otherwise they look like trash but can I mix them? I.e 512x128, etc
Anyone know where I can find the full list of Gmod's default sprites or materials (such as sprites/glow) that can be used on render.SetMaterial? Specifically looking for glowing light sprites.
[QUOTE=NiandraLades;47073059]Hey, I know images have to be power of two, otherwise they look like trash but can I mix them? I.e 512x128, etc[/QUOTE] Yes you can. [editline]4th February 2015[/editline] [QUOTE=VIoxtar;47073115]Anyone know where I can find the full list of Gmod's default sprites or materials (such as sprites/glow) that can be used on render.SetMaterial? Specifically looking for glowing light sprites.[/QUOTE] You can use my Extended Spawnmenu addon on Workshop, it allows you to browse through all materials/sounds just like models. ( Per game, per addon, per legacy addon )
[QUOTE=Robotboy655;47073136]Yes you can. [editline]4th February 2015[/editline] You can use my Extended Spawnmenu addon on Workshop, it allows you to browse through all materials/sounds just like models. ( Per game, per addon, per legacy addon )[/QUOTE] Thanks for the help!
[QUOTE=Kamber56;47072940]A lot of the things in those links I don't understand so i'll probably save them for future reference, but there's definitely a few points in which those links clear up, and explain the HUD/Panels a lot clearer than anywhere else i've seen, Thanks One thing i've seen a lot but don't understand what it does is a ! before things. For example, what does putting the ! before certain things like IsValid() do?[/QUOTE] If you don't mind, which parts were you having trouble with? Some of the documentation is old and I'm going over them piece by piece and combining like-tutorials and rewording some of them to be more helpful for the class I'm creating. [QUOTE=Kamber56;47072985]Ohh okay, thanks for clearing that up. I also see .. used alot. Usually between a variable and a string such as HP .. " HP" or something. Does that actually do anything or is it to make it look neater?[/QUOTE] I know this has already been answered but here's string concatenation: [url]https://dl.dropboxusercontent.com/u/26074909/tutoring/strings/string_concatenation.lua.html[/url] And, because Lua is a language of tables, here's the basics: [url]https://dl.dropboxusercontent.com/u/26074909/tutoring/tables/quick_intro_to_tables.lua.html[/url] If you work with auto-refresh and you find code only works if you auto-refresh after the initial load, this is what you should look out for: [url]https://dl.dropboxusercontent.com/u/26074909/tutoring/includes/file_only_works_on_autorefresh_possible_reasons.lua.html[/url]
[QUOTE=Robotboy655;47073136]Yes you can. [/QUOTE] Wow, Handsome Matt told me you couldn't, I could've saved some space with this
[QUOTE=Acecool;47073262]If you don't mind, which parts were you having trouble with? Some of the documentation is old and I'm going over them piece by piece and combining like-tutorials and rewording some of them to be more helpful for the class I'm creating.[/QUOTE] I think it's more to do with the fact that I don't have much basic knowledge of Lua itself rather than i'm not understanding your documents. I'm at work right now and i'm not home for the next 7 hours or so. But if what you're aiming for is tutorials for complete beginners like me i'll happily write out everything which seems a bit too complicated for me to understand at the level i'm currently at. (But I might just be stupid and not understand simple things, like the issue I have with hooks. I understand them a lot better, but now when it comes to custom hooks/arguments, where hooks are supposed to be used, If you can use one inside another and calling hooks it starts to hurt my brain again. You wouldn't happen to have one of these tutorial documents on hooks and events would ya? :L) [QUOTE=Acecool;47073262] I know this has already been answered but here's string concatenation: [url]https://dl.dropboxusercontent.com/u/26074909/tutoring/strings/string_concatenation.lua.html[/url] And, because Lua is a language of tables, here's the basics: [url]https://dl.dropboxusercontent.com/u/26074909/tutoring/tables/quick_intro_to_tables.lua.html[/url] If you work with auto-refresh and you find code only works if you auto-refresh after the initial load, this is what you should look out for: [url]https://dl.dropboxusercontent.com/u/26074909/tutoring/includes/file_only_works_on_autorefresh_possible_reasons.lua.html[/url][/QUOTE] Again more I'll save for tonight to go over properly, Thanks!
Im trying to replace the generic bullet impact effect with my custom one, but i cant find the original one's name, and also cant find it nowhere in the wiki.
[QUOTE=TheBricktop;47073892]Im trying to replace the generic bullet impact effect with my custom one, but i cant find the original one's name, and also cant find it nowhere in the wiki.[/QUOTE] Last time I checked, it's just called "Impact".
I've found an entry in particle manifest: "particles/impact_fx.pcf", searched through the entire steam folder but didnt found the actual file.
[QUOTE=Acecool;47071770]also to avoid errors with using LocalPlayer( ) in HUDPaint ( because LocalPlayer( ) is not valid for the first few frames the hook is called ) you'll want to add a few checks... Here's how to properly create HUDPaint elements: [url]https://dl.dropboxusercontent.com/u/26074909/tutoring/hud/proper_hud_creation.lua.html[/url] [/QUOTE] I have literally never run into this problem.
[QUOTE=bobbleheadbob;47074694]I have literally never run into this problem.[/QUOTE] It happens. It's also possible your client will 'remove' the local player entity at any point in the game too.
[QUOTE=Kamber56;47073348]I think it's more to do with the fact that I don't have much basic knowledge of Lua itself rather than i'm not understanding your documents. I'm at work right now and i'm not home for the next 7 hours or so. But if what you're aiming for is tutorials for complete beginners like me i'll happily write out everything which seems a bit too complicated for me to understand at the level i'm currently at. (But I might just be stupid and not understand simple things, like the issue I have with hooks. I understand them a lot better, but now when it comes to custom hooks/arguments, where hooks are supposed to be used, If you can use one inside another and calling hooks it starts to hurt my brain again. You wouldn't happen to have one of these tutorial documents on hooks and events would ya? :L) Again more I'll save for tonight to go over properly, Thanks![/QUOTE] Lua stores everything in tables and there are special tables called meta-tables which allow a lot of additional things to happen with them such as running the table itself as a function, etc... Hooks are basically just functions.. If you use hook.Call( "Blah", GAMEMODE, "testing" ); then it accesses: function GM:Blah( arg ) ... end where arg will be set to "testing" and GM and GAMEMODE are the same except GM is used when the game-mode is starting up before being renamed to GAMEMODE. I do have some tuts on hooks somewhere ( in the middle of reorganizing so I can't locate it, but feel free to add me on Steam... I've written over 500 tutorials so far ).
Wait... Garry's Mod LUA has the continue statement, right? [code]for V = X, Y do if V == 6 then continue end print( "V = "..V ) end[/code] Something like that? said continue method exists, correct?
Yes.
What is wrong with Entity:DrawModel()? I have two scripted ents. Let's call them [I]A[/I] and [I]B[/I]. [I]B[/I] is spawned as a child of [I]A[/I]. I want to draw [I]B[/I] BEFORE drawing [I]A[/I] for stencil purposes. Here is my simplified code: Entity [I]A[/I] [lua] function ENT:Draw() //Draw the kids. for k,v in pairs(self.Children)do //Children are B's. v:DrawScaled() end //Draw A. self:DrawModel() end [/lua] Entity [I]B[/I] [lua] function ENT:DrawScaled() local mat = Matrix() mat:Scale(Vector(self:GetX(),self:GetY(),self:GetZ())) self:EnableMatrix( "RenderMultiply", mat ) //Draw B. self:DrawModel() end function ENT:Draw() --do nothing. end [/lua] I've done debug and there are no errors, but no model is drawn for instances of [I]B[/I], while model [I]A[/I]is drawn fine. It's worth noting that calling self:DrawScaled() in ENT:Draw() of [I]B[/I] draws the model just fine, but then I can't use [I]B[/I] for stencils.
Is there a faster way of reloading ENT Lua files so you don't get "[ERROR] addons/nextbot/lua/entities/nextbot_ai.lua:4: attempt to index global 'ENT' (a nil value)" I'm getting tired of having to restarting to update a small mistake
If you draw a model twice in different positions in the same frame, call self:SetupBones( ) on it. [editline]5th February 2015[/editline] [QUOTE=Pandaman09;47077848]Is there a faster way of reloading ENT Lua files so you don't get "[ERROR] addons/nextbot/lua/entities/nextbot_ai.lua:4: attempt to index global 'ENT' (a nil value)" I'm getting tired of having to restarting to update a small mistake[/QUOTE] You should have no trouble editing entities in your game-mode directory ( you have to spawn a new entity each time you change the code for the changes to appear though unless you redirect all functions to global functions for dev-work and then merge them back into the ent file when you're ready to release ). You can also update the Entities list with the new data ( look into adding entities without the entities folder ).
Quick question How can I overwrite the default settings for how panels and buttons look? I want to make the buttons automatically have the designs on them I want so i can simply create them without any hassle.
Sorry, you need to Log In to post a reply to this thread.