[QUOTE=Orgy;39273439]Indeed. Didn't realize I couldn't use 0 as the second argument in hook.Add. I've seen it used in examples, why wouldn't it work for me?
Oh well, I changed it to a string and it worked.
Thanks![/QUOTE]
Yeah it recently changed to only accept strings
[QUOTE=Hyper Iguana;39273567][url]http://maurits.tv/data/garrysmod/wiki/wiki.garrysmod.com/index5b3b.html[/url]
?[/QUOTE]
Yes but how would I paint it without affecting anything but the background color?
[editline]18th January 2013[/editline]
[QUOTE=fairy;39273471][url]http://wiki.garrysmod.com/page/gui[/url]
What happened to [url=http://maurits.tv/data/garrysmod/wiki/wiki.garrysmod.com/index2c41.html]OpenURL[/url]?
[HR][/HR]
[/QUOTE]
and this too
[URL="http://www.facepunch.com/showthread.php?t=1240237"]http://www.facepunch.com/showthread.php?t=1240237[/URL]
Bump again :V
[QUOTE=thefreemann;39273890][URL="http://www.facepunch.com/showthread.php?t=1240237"]http://www.facepunch.com/showthread.php?t=1240237[/URL]
Bump again :V[/QUOTE]
Try using CRYSIS Bold as the font name instead.
gui.OpenURL is still there just not documented because it was removed for a little.
[QUOTE=Chessnut;39273977]gui.OpenURL is still there just not documented because it was removed for a little.[/QUOTE]
[lua] local URLButton = vgui.Create('DButton', self)
URLButton:SetPos(self:GetWide() / 2 + 21, self:GetTall() - 20)
URLButton:SetText("Visit Site")
URLButton:SetSize(100,15)
URLButton:SetVisible(true)
URLButton.DoClick = function()
gui.OpenURL("noegaming.net")
end[/lua]
Nothing happens upon clicking the button.
[editline]18th January 2013[/editline]
[QUOTE=pilot;39273586]That was a mistake I put on Facepunch.
FIX:
[CODE]
concommand.Add( "This", Function )
for k,v in pairs(player.GetAll()) do
if v:KeyReleased( KEY_G ) then
v:ConCommand("This")
end
end[/CODE]
Although it is still broken.[/QUOTE]
For one, KeyReleased only accepts IN_ keys, not the KEY_ keys.
Also if you want that to happen every time someone releases something it needs to be in a hook.
How about this?
[CODE]
concommand.Add( "This", Function )
local players = player.GetAll()
for _, player in ipairs( players ) do
if( player:KeyReleased( IN_ALT1 ) ) then
ConCommand( "This" )
end
end[/CODE]
[QUOTE=pilot;39274264]How about this?
[CODE]
concommand.Add( "This", Function )
local players = player.GetAll()
for _, player in ipairs( players ) do
if( player:KeyReleased( IN_ALT1 ) ) then
ConCommand( "This" )
end
end[/CODE][/QUOTE]
[lua]hook.Add("Tick", "getatmekidurgay", function()
for k,v in pairs(player.GetAll()) do
if v:KeyReleased(IN_FORWARD) then
v:ConCommand("This")
end
end
end)[/lua]
If you press and release W, the command will be ran.
[QUOTE=fairy;39274299][lua]hook.Add("Tick", "getatmekidurgay", function()
for k,v in pairs(player.GetAll()) do
if v:KeyReleased(IN_FORWARD) then
v:ConCommand("This")
end
end
end)[/lua]
If you press and release W, the command will be ran.[/QUOTE]
Thanks so much! But would it be possible to get the same results with KEY_ *enums?
[QUOTE=pilot;39274345]Thanks so much! But would it be possible to get the same results with KEY_ *enums?[/QUOTE]
You'd have to make a clientside portion to check if the key is down. Add this in a clientside file:
[lua]hook.Add("Think", "imgay", function()
if input.IsKeyDown(KEY_G) then
RunConsoleCommand("This")
end
end)[/lua]
I don't know the clientside way to get when a KEY_ is released, you'd have to check the wiki.
[QUOTE=zzaacckk;39273941]Try using CRYSIS Bold as the font name instead.[/QUOTE]
This is what I have changed it to
[PHP]function GM:Initalize()
surface.CreateFont( "Crysis",
{
font = "CRYSIS Bold",
size = 24,
weight = 400,
antialias = true,
shadow = true
})
end
function GM:HUDPaint()
self.BaseClass:HUDPaint()
local ply = LocalPlayer()
local wep = LocalPlayer():GetActiveWeapon()
local HP = LocalPlayer():Health()
local ARM = LocalPlayer():Armor()
surface.SetTextColor( 20, 180, 50, 255)
surface.SetTextPos( 20, 20 )
surface.SetFont( "Crysis" )
surface.DrawText( "Health: "..HP)
end[/PHP]
it tells me this:
[PHP][ERROR] gamemodes/tutorialgamemode/gamemode/cl_init.lua:40: 'Crysis' isn't a valid font
1. SetFont - [C]:-1
2. unknown - gamemodes/tutorialgamemode/gamemode/cl_init.lua:40
[/PHP]
Also, does the font have to be placed somewhere in the gamemode folders?
try moving the surface.CreateFont outside of GM:Initialize
How would I get a player's steam ID in LUA? I passed in ply from PlayerSay and used ply:SteamID(), but it just returns STEAM_0:0:0
Certainly that's not my Steam ID
EDIT: Could it be because I'm playing locally rather than on a server?
[QUOTE=Orgy;39275056]How would I get a player's steam ID in LUA? I passed in ply from PlayerSay and used ply:SteamID(), but it just returns STEAM_0:0:0
Certainly that's not my Steam ID
EDIT: Could it be because I'm playing locally rather than on a server?[/QUOTE]
You can't get SteamID's on a local server. Only works multiplayer. You're doing it right though.
[editline]19th January 2013[/editline]
[QUOTE=fairy;39273471]I've asked this 3 times in the past 5 days with [b]no response what-so-ever[/b].
Does anyone know how I can change the color of the background in a [url=http://wiki.garrysmod.com/page/Lua/Tutorials/VGUI/DCollapsibleCategory]DCollapsibleCategory[/url]?
It's some weird color of blue by default. Is there a way to change it without making a skin?[/QUOTE]
[QUOTE=fairy;39275165]You can't get SteamID's on a local server. Only works multiplayer. You're doing it right though.
[editline]19th January 2013[/editline][/QUOTE]
Alright, thanks. I wish I could help you with your problem but I really have no idea.
I'm starting to think what i'm trying to do is impossible. I'm trying to replace a texture on one playermodel/item/entity.
The only problem is[B] I don't[/B] want to replace the entire texture for everybody's model like this would:
[lua]
local mat = Material("models/kleiner/players_sheet")
local mat2 = Material("models/humans/male/group01/players_sheet")
mat:SetTexture( "$basetexture", mat2:GetTexture( "$basetexture" ) )
[/lua]
Is it possible to do this with lua, or would I have to learn modelling and use bodygroups?
[QUOTE=fairy;39275165]I've asked this 3 times in the past 5 days with no response what-so-ever.
Does anyone know how I can change the color of the background in a DCollapsibleCategory?
It's some weird color of blue by default. Is there a way to change it without making a skin?[/QUOTE]
override the Paint function?
I have a question:
How can I detect an AI node with lua? I want to give NPCs a randomized path (on a noded map) towards a certain location, and the way I'm thinking of going about it would be to start at the nearest node, get the direction of the target, add some randomness to the directional vector, then go a random distance from that and find the nearest node to set the move order to.
Thanks in advance, guys.
I need to talk to someone whos good with Derma stuff, so if anyone is interested in helping me then add me on steam.
[QUOTE=Netheous;39277031]I need to talk to someone whos good with Derma stuff, so if anyone is interested in helping me then add me on steam.[/QUOTE]
Or you could just post your questions on here.
anyone in here know how to disable bouncy ball so u cant spawn it on gmod 13 server?
[QUOTE=Paco Capone;39277375]anyone in here know how to disable bouncy ball so u cant spawn it on gmod 13 server?[/QUOTE]
[lua]
local function DisableBouncyBall( pl, class )
return ( class != "sent_ball" ) or pl:IsAdmin()
end
hook.Add( "PlayerSpawnSENT", "disable_bouncyball", DisableBouncyBall )
[/lua]
[QUOTE=fairy;39274396]You'd have to make a clientside portion to check if the key is down. Add this in a clientside file:
[lua]hook.Add("Think", "imgay", function()
if input.IsKeyDown(KEY_G) then
RunConsoleCommand("This")
end
end)[/lua]
I don't know the clientside way to get when a KEY_ is released, you'd have to check the wiki.[/QUOTE]
It worked! But issue is...if you hold it down it starts showing up like 100 times. I think this is because I'm holding it down. I wonder if there is a release option for that.
[QUOTE=Thermadyle;39277467][lua]
local function DisableBouncyBall( pl, class )
return ( class != "sent_ball" ) or pl:IsAdmin()
end
hook.Add( "PlayerSpawnSENT", "disable_bouncyball", DisableBouncyBall )
[/lua][/QUOTE]
Thanks but where to put this i know i dotn have so much brain :I
[QUOTE=pilot;39277514]It worked! But issue is...if you hold it down it starts showing up like 100 times. I think this is because I'm holding it down. I wonder if there is a release option for that.[/QUOTE]
You could always do something like this
[lua]
local haspushed = false
hook.Add("Think", "imgay", function()
if input.IsKeyDown(KEY_G) and !haspushed then
haspushed = true
RunConsoleCommand("This")
else
haspushed = false
end
end)
[/lua]
I would like to get some help with the fretta map voting for TTT, thanks in advance.
[QUOTE=Hyper Iguana;39277974]You could always do something like this
[lua]
local haspushed = false
hook.Add("Think", "imgay", function()
if input.IsKeyDown(KEY_G) and !haspushed then
haspushed = true
RunConsoleCommand("This")
else
haspushed = false
end
end)
[/lua][/QUOTE]
That essentially worked, but what happens is that it turns on 100000 times when pressing G. I was given this by a friend:
[CODE]local Delay=5
local CurTimeB=0
hook.Add("Think", "Filler", function()
if input.IsKeyDown(KEY_F) and not CurTime() < CurTimeB then
RunConsoleCommand("This") CurTimeB=CurTime()+Delay
end
end)[/CODE]
But I get the error:
[CODE][ERROR] RunString:61: attempt to compare boolean with number
1. v - RunString:61
2. unknown - lua/includes/modules/hook.lua:82
[/CODE]
I'm currently trying to create a binary module and would like to get a bit deeper into lua itself. I remember that somewhere, Garry said that he wanted to give people the opportunity to use the lua API directly instead of his OOP approach.
Is that still true? Whenever I try to use lua functions, I'm required to add the header - which in turn will require the symbols. I don't know which version of luaJIT GMod exactly uses (and even then, compiling that or getting it to compile is a pain).
Edit: Figured it out. By taking normal luajit headers and creating an own .lib for garrysmod/bin/lua_shared.dll (using dumpbin, creating a .def file and lib that, all done in the VS toolset) and then linking to that, it works smoothly. All the lua functions \o/
[QUOTE=pilot;39280833]That essentially worked, but what happens is that it turns on 100000 times when pressing G. I was given this by a friend:
[CODE]local Delay=5
local CurTimeB=0
hook.Add("Think", "Filler", function()
if input.IsKeyDown(KEY_F) and not CurTime() < CurTimeB then
RunConsoleCommand("This") CurTimeB=CurTime()+Delay
end
end)[/CODE]
But I get the error:
[CODE][ERROR] RunString:61: attempt to compare boolean with number
1. v - RunString:61
2. unknown - lua/includes/modules/hook.lua:82
[/CODE][/QUOTE]
I wasn't paying attention, try this.
[lua]
local haspushed = false
hook.Add("Think", "imgay", function()
if input.IsKeyDown(KEY_G) then
if !haspushed then
haspushed = true
RunConsoleCommand("This")
end
else
haspushed = false
end
end)[/lua]
Sorry, you need to Log In to post a reply to this thread.