[QUOTE=bilbasio;52093750]I tried using dmodelpanel but I had some issues related to it. Is there really no other way than using dmodelpanel?
EDIT:Just fixed my issues with dmodelpanel.
Does anyone have an idea on how to remove the zone before the dnumslider where you click to be precise?
[url]http://imgur.com/a/aWQFH[/url][/QUOTE]
I'd look into the source code behind it
[url]https://github.com/garrynewman/garrysmod/blob/4965849af3f70331f050536a11583899dca4227f/garrysmod/lua/vgui/dnumslider.lua[/url]
How can I create a material from only part of a texture? Say, for example, I only want a square from coordinates 0,0 to 10,10 of a vtf to be my material.
I think with some math you could try [URL="https://developer.valvesoftware.com/wiki/$basetexturetransform"]https://developer.valvesoftware.com/wiki/$basetexturetransform[/URL].
If that does not work and it's for 2d things then use [URL="http://wiki.garrysmod.com/page/render/SetScissorRect"]http://wiki.garrysmod.com/page/render/SetScissorRect[/URL].
[QUOTE=code_gs;52097435]How can I create a material from only part of a texture? Say, for example, I only want a square from coordinates 0,0 to 10,10 of a vtf to be my material.[/QUOTE]
This is probably not what you want as you seem to want it for an actual material, but [img]http://wiki.garrysmod.com/favicon.ico[/img] [url=http://wiki.garrysmod.com/page/surface/DrawTexturedRectUV]surface.DrawTexturedRectUV[/url] lets you draw part of a texture
[QUOTE=code_gs;52097435]How can I create a material from only part of a texture? Say, for example, I only want a square from coordinates 0,0 to 10,10 of a vtf to be my material.[/QUOTE]
I never thought I'd see code_gs ask a GLua related question... :freakout:
[QUOTE=Wavie;52097850]I never thought I'd see code_gs ask a GLua related question... :freakout:[/QUOTE]
It's a well known fact that good programmers know everything
[QUOTE=SFArial;52097546]I think with some math you could try [URL="https://developer.valvesoftware.com/wiki/$basetexturetransform"]https://developer.valvesoftware.com/wiki/$basetexturetransform[/URL].
If that does not work and it's for 2d things then use [URL="http://wiki.garrysmod.com/page/render/SetScissorRect"]http://wiki.garrysmod.com/page/render/SetScissorRect[/URL].[/QUOTE]
$BaseTextureTransform is definitely the correct answer. The matrix format is a bit weird (I still haven't figured it out) but you can just create it with [img]http://wiki.garrysmod.com/favicon.ico[/img] [url=http://wiki.garrysmod.com/page/Global/Matrix]Matrix[/url] + [img]http://wiki.garrysmod.com/favicon.ico[/img] [url=http://wiki.garrysmod.com/page/VMatrix/Scale]VMatrix:Scale[/url] + [img]http://wiki.garrysmod.com/favicon.ico[/img] [url=http://wiki.garrysmod.com/page/VMatrix/SetTranslation]VMatrix:SetTranslation[/url]. Or you can just use the string format described on the valve wiki, I think if you do that you need to use [img]http://wiki.garrysmod.com/favicon.ico[/img] [url=http://wiki.garrysmod.com/page/IMaterial/SetString]IMaterial:SetString[/url] instead of [img]http://wiki.garrysmod.com/favicon.ico[/img] [url=http://wiki.garrysmod.com/page/IMaterial/SetMatrix]IMaterial:SetMatrix[/url].
[QUOTE=code_gs;52097435]How can I create a material from only part of a texture? Say, for example, I only want a square from coordinates 0,0 to 10,10 of a vtf to be my material.[/QUOTE]
Create a 10x10 rendertarget and draw the bigger texture in that :eng101s:
Does anybody know why render.RenderView hides the crosshair? I'm calling it under HUDPaint.
[QUOTE=Ryanrc;52098627]Does anybody know why render.RenderView hides the crosshair? I'm calling it under HUDPaint.[/QUOTE]
Probably because the crosshair is drawn after HUDPaint.
Really simple question, how can I get the second argument from a return value with multiple arguments? For example [img]http://wiki.garrysmod.com/favicon.ico[/img] [url=http://wiki.garrysmod.com/page/Panel/GetPos]Panel:GetPos[/url]
I tried
[code]local x, y = self:GetPos()[/code]
but it didn't seem to work and I can't find an answer online.
if you need it in one go use [img]http://wiki.garrysmod.com/favicon.ico[/img] [url=http://wiki.garrysmod.com/page/Global/select]select[/url]
[CODE]
local yPos = select( -1, self:GetPos() )
[/CODE]
[QUOTE=bilbasio;52100644]Really simple question, how can I get the second argument from a return value with multiple arguments? For example [img]http://wiki.garrysmod.com/favicon.ico[/img] [url=http://wiki.garrysmod.com/page/Panel/GetPos]Panel:GetPos[/url]
I tried
[code]local x, y = self:GetPos()[/code]
but it didn't seem to work and I can't find an answer online.[/QUOTE]
[QUOTE=Bull29;52100671]if you need it in one go use [img]http://wiki.garrysmod.com/favicon.ico[/img] [url=http://wiki.garrysmod.com/page/Global/select]select[/url]
[CODE]
local yPos = select( -1, self:GetPos() )
[/CODE][/QUOTE]
Can you explain why this is needed? Seems to work on my machine(tm):
[code]
> function ret2()
>> return 1,2
>> end
> a,b = ret2()
> print(a)
1
> print(b)
2
>
[/code]
i might've misunderstood his problem; it's not required [CODE] local a, b = somefunc()[/CODE] works and always has
i thought he wanted a way to directly assign the second vararg value to a var
[QUOTE=Bull29;52101535]i might've misunderstood his problem; it's not required [CODE] local a, b = somefunc()[/CODE] works and always has
i thought he wanted a way to directly assign the second vararg value to a var[/QUOTE]
Must've done something wrong in my code for it not to work, honestly I don't even remember why I wanted to do this. Still great to learn about select though.
Is [img]http://wiki.garrysmod.com/favicon.ico[/img] [url=http://wiki.garrysmod.com/page/Panel/Receiver]Panel:Receiver[/url] and [img]http://wiki.garrysmod.com/favicon.ico[/img] [url=http://wiki.garrysmod.com/page/Panel/Droppable]Panel:Droppable[/url] actually worth it to use? I just can't figure out how to make it work maybe someone can give me an insight :
[code]function PANEL:Init()
self:Droppable("ItemButton")
self:Receiver("ItemButton", function(receiver, pnls, dropped, index, x, y) print("Working") end)
end[/code]
Droppable is for the panel you want to drag, and Receiver is for the panel you want to drop it onto.
[lua]function ITEMICON:Init()
self:Droppable("SItemIcon")
end
function ITEMGRID:Init()
self:Receiver("SItemIcon", function(this, panels, dropped, idx)
if not dropped then return end
-- ...
end)
end[/lua]
[QUOTE=Luni;52101970]Droppable is for the panel you want to drag, and Receiver is for the panel you want to drop it onto.
[lua]function ITEMICON:Init()
self:Droppable("SItemIcon")
end
function ITEMGRID:Init()
self:Receiver("SItemIcon", function(this, panels, dropped, idx)
if not dropped then return end
-- ...
end)
end[/lua][/QUOTE]
Is it possible to have a panel that is at the same time the 'Droppable' and the 'Receiver' at the same time like in my example?
[code]local GodMode = {
Settings = {
Length = 3
}
}
function GodMode:PlayerSpawn(ply)
if !IsValid(ply) then return end
ply:GodEnable()
ply.GodEnabled = true
ply:SetMaterial("models/alyx/emptool_glow")
local effectdata = EffectData()
effectdata:SetOrigin(ply:GetPos())
effectdata:SetScale(6)
effectdata:SetRadius(4)
effectdata:SetMagnitude(4)
util.Effect("Sparks", effectdata)
ply:EmitSound("npc/roller/mine/rmine_shockvehicle"..math.random(1,2)..".wav")
timer.Simple(self.Settings.Length, function()
if !IsValid(ply) then return end
ply:GodDisable()
ply.GodEnabled = false
ply:SetMaterial("")
end)
end
hook.Add("PlayerSpawn", "GE.PlayerSpawn", function(...) GodMode:PlayerSpawn(...) end)[/code]
I am trying to make the spark effect happen everytime the player spawns but it only happens the first time they spawn for some reason.
[QUOTE=Yushe;52105122][code]local GodMode = {
Settings = {
Length = 3
}
}
function GodMode:PlayerSpawn(ply)
if !IsValid(ply) then return end
ply:GodEnable()
ply.GodEnabled = true
ply:SetMaterial("models/alyx/emptool_glow")
local effectdata = EffectData()
effectdata:SetOrigin(ply:GetPos())
effectdata:SetScale(6)
effectdata:SetRadius(4)
effectdata:SetMagnitude(4)
util.Effect("Sparks", effectdata)
ply:EmitSound("npc/roller/mine/rmine_shockvehicle"..math.random(1,2)..".wav")
timer.Simple(self.Settings.Length, function()
if !IsValid(ply) then return end
ply:GodDisable()
ply.GodEnabled = false
ply:SetMaterial("")
end)
end
hook.Add("PlayerSpawn", "GE.PlayerSpawn", function(...) GodMode:PlayerSpawn(...) end)[/code]
I am trying to make the spark effect happen everytime the player spawns but it only happens the first time they spawn for some reason.[/QUOTE]
I have never seen a function called that way honestly... You should try naming your function "GodMode.EffectSpawn" and then do
[code]hook.Add("PlayerSpawn", "lily to the rescue!", GodMode.EffectSpawn)[/code]
edit: Tell me if it works!
[QUOTE=Lilyxfce;52105180]I have never seen a function called that way honestly... You should try naming your function "GodMode.EffectSpawn" and then do
[code]hook.Add("PlayerSpawn", "lily to the rescue!", GodMode.EffectSpawn)[/code]
edit: Tell me if it works![/QUOTE]
It needs to be PlayerSpawn.
[QUOTE=Yushe;52105396]It needs to be PlayerSpawn.[/QUOTE]
And it will be run at PlayerSpawn.
[QUOTE=Ryanrc;52098627]Does anybody know why render.RenderView hides the crosshair? I'm calling it under HUDPaint.[/QUOTE]
I assume you are not enabling the HUD in render.RenderView. I think that is required to draw the crosshair. I'd just draw my own afterwards personally.
Ok it is making the particle effects but I can only see it on other players/bots, I want players to be able to see the particle effects on themselves when they spawn anyone know how to fix?
In what instance would the GetOwner method be missing on a SWEP? Somehow one of my users is getting that specific lua error, and I have no idea how it's even possible.
[QUOTE=TFA;52106916]In what instance would the GetOwner method be missing on a SWEP? Somehow one of my users is getting that specific lua error, and I have no idea how it's even possible.[/QUOTE]
GetOwner is an entity method, which means it would only be non-existant if the object that it was being used on wasn't an entity.
[QUOTE=code_gs;52107104]GetOwner is an entity method, which means it would only be non-existant if the object that it was being used on wasn't an entity.[/QUOTE]
How else could it even be used? It's being called from another SWEP function, OwnerIsValid, and the earliest that's called is in Initialize.
[QUOTE=TFA;52107108]How else could it even be used? It's being called from another SWEP function, OwnerIsValid, and the earliest that's called is in Initialize.[/QUOTE]
Can you post a code excerpt and what call is causing the error?
[code]
[TFA Base] lua/weapons/tfa_gun_base/sh_utils.lua:231: attempt to call method 'GetOwner' (a nil value)
1. OwnerIsValid - lua/weapons/tfa_gun_base/sh_utils.lua:231
2. GetStat - lua/weapons/tfa_gun_base/sh_attachments.lua:150
3. GetPrimaryAmmoType - lua/weapons/tfa_gun_base/shared.lua:1472
4. unknown - addons/nzombies-master-workshop/gamemodes/nzombies/entities/entities/wall_buys/shared.lua:216
[/code]
Apparently the issue is specific to NZombies, happens upon wall buy, and goes away if you have a TFA Weapon somewhere in your inventory first. I can't reproduce it myself.
e:
Apparently he's calling
[code]local ammo_type = wep.GetPrimaryAmmoType and wep:GetPrimaryAmmoType() or wep.Primary.Ammo[/code], but wep is the SWEP metatable? This explains it then, but not why it only happens before another TFA weapon has init.
There wouldn't be an owner if the weapon was dropped.
[QUOTE=LegoGuy;52107879]There wouldn't be an owner if the weapon was dropped.[/QUOTE]
I got it. The method itself is nil because its being called on a table, not an ent.
Sorry, you need to Log In to post a reply to this thread.