• Problems That Don't Need Their Own Thread v5
    4,111 replies, posted
[QUOTE=DarkDragonLov;52907016]Uh. So...I want to make physically simulated particles without creating a .pcf file. In other words, I want to script an effect in Lua that features falling and bouncing particles, but I have no clue how to do this without writing my own fake physics simulation... Is there an easier way to simulate particle physics in Lua effects?[/QUOTE] [img]http://wiki.garrysmod.com/favicon.ico[/img] [url=http://wiki.garrysmod.com/page/EFFECT/PhysicsCollide]EFFECT:PhysicsCollide[/url]? You can make scripted effects but it's a bit weird
[QUOTE=DarkDragonLov;52907016]Uh. So...I want to make physically simulated particles without creating a .pcf file. In other words, I want to script an effect in Lua that features falling and bouncing particles, but I have no clue how to do this without writing my own fake physics simulation... Is there an easier way to simulate particle physics in Lua effects?[/QUOTE] Create a CLuaEmitter that will spawn particles, then you can set the collision function to whatever you wish using [img]http://wiki.garrysmod.com/favicon.ico[/img] [url=http://wiki.garrysmod.com/page/CLuaParticle/SetCollideCallback]CLuaParticle:SetCollideCallback[/url]. You can alter the particle's trajectory however you want in the callback.
[QUOTE=LoweChaser;52903577]I'm trying to spawn/dispatch effect from server, but it doesnt work (it works from client):[code]local edata = EffectData() edata:SetOrigin(pos) edata:SetScale(32) edata:SetEntity(ent) util.Effect("custom_effect12", edata, true, true)[/code] Btw, can I render entity which is parented to the effect in its render hook? I don't understand how to work with render :frown:[/QUOTE]Still did not figured out. I can create an effect from client, its ok. But I'm also trying to render something on effect's parent entity in effect [B]Render[/B] hook. Right now I'm using [B]PostDrawOpaqueRenderables[/B] hook to do this How can I create an effect like env_entity_dissolver has?
[QUOTE=LoweChaser;52903577]I'm trying to spawn/dispatch effect from server, but it doesnt work (it works from client):[code]local edata = EffectData() edata:SetOrigin(pos) edata:SetScale(32) edata:SetEntity(ent) util.Effect("custom_effect12", edata, true, true)[/code] Btw, can I render entity which is parented to the effect in its render hook? I don't understand how to work with render :frown:[/QUOTE] Remove the last two "true" arguments.
Anyone know how to read the server's sv_pure value with Lua? print(GetConVar("sv_pure")) doesn't return a ConVar.
Is there any way of getting a list of ACT enums that work with a certain custom model? From what I understand ACT enums are just labels for sequence patterns internally, but I can't find which ACT enums work for a custom model that I have that use 100% custom animations.
Do you have it qc file? that's where it acts are defined
[QUOTE=gonzalolog;52910606]Do you have it qc file? that's where it acts are defined[/QUOTE] Yeah I found it, my issue now is translating those ACT_ENUM's to Gmod Enum's. [url]https://wiki.garrysmod.com/page/Player_Animations[/url] - Doesn't do such a great job. Is there anything I can do in Lua to print what Enum my player is currently using?
I think you can use this hook [img]http://wiki.garrysmod.com/favicon.ico[/img] [url=http://wiki.garrysmod.com/page/GM/TranslateActivity]GM:TranslateActivity[/url] or either not sure if works on players [img]http://wiki.garrysmod.com/favicon.ico[/img] [url=http://wiki.garrysmod.com/page/Entity/GetSequenceActivity]Entity:GetSequenceActivity[/url] Just remember, ACT_ENUMS are just constants that you can define by yourself
[QUOTE=gonzalolog;52910731]I think you can use this hook [img]http://wiki.garrysmod.com/favicon.ico[/img] [url=http://wiki.garrysmod.com/page/GM/TranslateActivity]GM:TranslateActivity[/url] or either not sure if works on players [img]http://wiki.garrysmod.com/favicon.ico[/img] [url=http://wiki.garrysmod.com/page/Entity/GetSequenceActivity]Entity:GetSequenceActivity[/url] Just remember, ACT_ENUMS are just constants that you can define by yourself[/QUOTE] GM:TranslateActivity worked, thanks!
[QUOTE=gonzalolog;52910731]I think you can use this hook [img]http://wiki.garrysmod.com/favicon.ico[/img] [url=http://wiki.garrysmod.com/page/GM/TranslateActivity]GM:TranslateActivity[/url] or either not sure if works on players [img]http://wiki.garrysmod.com/favicon.ico[/img] [url=http://wiki.garrysmod.com/page/Entity/GetSequenceActivity]Entity:GetSequenceActivity[/url] Just remember, ACT_ENUMS are just constants that you can define by yourself[/QUOTE] Looping through the sequence count with GetSequenceActivity can give you all ACT enums to a model.
[QUOTE=Moat;52910544]You have to use [img]http://wiki.garrysmod.com/favicon.ico[/img] [url=http://wiki.garrysmod.com/page/Global/GetConVarNumber]GetConVarNumber[/url] unfortunately.[/QUOTE] Not true: [url=https://github.com/Facepunch/garrysmod/blob/master/garrysmod/lua/includes/util.lua#L443]GetConVarNumber returns 0 whenever the ConVar object doesn't exist[/url]
[QUOTE=Moat;52910544]You have to use [img]http://wiki.garrysmod.com/favicon.ico[/img] [url=http://wiki.garrysmod.com/page/Global/GetConVarNumber]GetConVarNumber[/url] unfortunately.[/QUOTE] GetConVarNumber uses GetConVar. [url]https://github.com/Facepunch/garrysmod/blob/master/garrysmod/lua/includes/util.lua#L445[/url]
[QUOTE] print(GetConVar("sv_pure")[B]:GetFloat()[/B]) [/QUOTE] You have to specify a type to return
1 - > local table = {name = LocalPlayer():Nick()} 2 - > print(table[name]) When I do 'print(table[name])' does it call LocalPlayer():Nick()? Every time I print or use the table for something will LocalPlayer():Nick() be called or is 'table[name]' just a string now? It's hard for me to explain. I am curious and want to know whether the function gets called every time I do 'print(table[name])' or will it already have stored a string in the table? I'm new to LUA and couldn't find any other references so I posted here. Thank you!
It simply stores the value `LocalPlayer():Nick()` returns when you put it into the table. So for example if you changed your name after it had been stored, the value in the table will still be your old name. Whether this is efficient or not depends on your usage.
Calling Nick will return a string and put that in the table. Indexing the table will not re-call Nick, but just returns the same string object as earlier.
Thank you so much!
Keep in mind that the code you've got there would only print something if you had local name = "name" above it. local table = {name = LocalPlayer().Nick} --index is "name" (a string) print(table.["name"])--index it with "name" --or print( table.name ) --shorthand for the above
Thank you aswell, bigdogmat. Is there more a more efficent way in merging two tables that both contain large amounts of data other than table.Merge? The two tables will be merged together every couple seconds. By efficent, I mean by more smoother/optimized for what I'm doing.
Depends on what you're doing. What's the general structure of your tables? If it happens every few seconds, you could log changes to the source table and apply only those to the destination table.
For experimential purposes, I get a JSON table from a website and I store it to a table. Every time it sends a request and its successful, it will fill in the nil values in example['web']. It will also check if the backup file has the same contents of what it got from the body of the http request. If they are different, the backup.txt gets overwritten with the new data. Again, this only happens if the body is different than the one stored in backup.txt There will be large amounts of data in the body whenever the request is sent (every couple seconds). I would do table.Merge after I convert the JSON to a Lua table, but I am wondering if there is a more efficent method for my situation. I like to do my best to have it optimized. I'm sorry if I am doing stuff I shouldn't, but I'm still very new with Lua. local example = {} local example['web'] = {url = 'http://www.google.com', success = nil, info, nil} -- nil values get updated in the http request local example['backup'] ={name = 'backup.txt' path = file.Find( "backup.txt", "DATA" ), content = file.Read( "backup.txt", "DATA" )} -- if it by chance doesn't get a response
What did they do? I can't use my facepunch account in this thread anymore? This is weird... Well anyway, is there a damage type that doesn't harm Health? I want something to drain Armor without harming health.
You can migrate your old account. https://auth.facepunch.com/legacy/start
This is a completely new forum, you can migrate your old account here: https://auth.facepunch.com/legacy/start You'll have to use an EntityTakeDamage hook, no damage type does that.
Why merge though? Will some gaps be present in the new data that are filled by old data? If the new table is a complete record of all data, you can just overwrite the old with the new.
Well... I don't get how I can make the damage hurt armor without harming health then. without directly modifying the HP/AP values.
You'll have to manually set them. You can do something extremely simple like: hook.Add("EntityTakeDamage", "ArmorOnly", function(pEntity, dmg) if (pEntity:IsPlayer()) then local iArmor = pEntity:Armor() if (iArmor > 0) then local iDamage = dmg:GetDamage() iArmor = iArmor - iDamage if (iArmor < 0) then self:SetArmor(0) iDamage = -iArmor -- Left-over damage else self:SetArmor(iArmor) iDamage = 0 end dmg:SetDamage(iDamage) end end end)
Fully priority? Its the only source of damage in half-life 1 I remember not hurting both health and armor at the same time. I thought half-life 1 generally split it 2:1
I will re-test this; I'm probably remembering incorrectly.
Sorry, you need to Log In to post a reply to this thread.