[QUOTE=Drakehawke;36568053]That isn't the right way to use it. [url=http://maurits.tv/data/garrysmod/wiki/wiki.garrysmod.com/index0d85.html]DModelPanel[/url] does a similar thing and if you look at the source for that it uses a clientside model. I'd link you to the source but the last update broke luabin.[/QUOTE]
I've check'd the source code, but whenever I use ClientsideModel, it spawns at the very center of map and does not look like element of the screen but like an element of the map.
The point is that I want it to always be in the right upper corner of my screen.
[QUOTE=BradenFase;36514792]Alright, I've modified my code to show something like that.
[url]http://codepad.org/Kha71qle[/url]
No matter what I touch it with it will not remove. Is my code correct?[/QUOTE]
I'm a bit rusty with Glua now, but I'm pretty sure you can only use entity hooks on scripted entities.
Netheous
I have a script from over a year ago from an unfinished project that created a cube model displayed on the lower left of the screen, that rotates based on player health. If there's some awful problem with it, keep in mind how old it is. Also, there's some failed attempts at screen resolution scaling in there; anyway, this should show you how to do what you want. Just insert your own model.
[url]http://pastebin.com/UDc8M7Fj[/url]
I think Cube might be a nil entity at that point, you'd better double check on this.
[QUOTE=Bletotum;36575089]Netheous
I have a script from over a year ago from an unfinished project that created a cube model displayed on the lower left of the screen, that rotates based on player health. If there's some awful problem with it, keep in mind how old it is. Also, there's some failed attempts at screen resolution scaling in there; anyway, this should show you how to do what you want. Just insert your own model.
[url]http://pastebin.com/UDc8M7Fj[/url]
I think Cube might be a nil entity at that point, you'd better double check on this.[/QUOTE]
Thanks thats really helpful, but I thought there is another way to do it.
You see I have to make a HUD with mentioned melon and making HUD using Derma isn't a really good idea (I did once thought, somehow managed to make it not overflood).
Anyways, I've looked into source of DModelPanel and I noticed that it uses ClientsideModel, any idea why it spawns Clientside model so it looks like a part of derma panel and not a part of map ?
Look in it's Paint hook, the last few arguments of [url=http://maurits.tv/data/garrysmod/wiki/wiki.garrysmod.com/index4771.html]cam.Start3D[/url] seem to take care of that.
[QUOTE=Loures;36574737]I'm a bit rusty with Glua now, but I'm pretty sure you can only use entity hooks on scripted entities.[/QUOTE]
Yeah you are correct. I got help in another thread with this. Thanks for the reply though.
How to draw a hollow circle, or a circle with a border.
Making a HUD.
[QUOTE=zyke34;36582736]How to draw a hollow circle, or a circle with a border.
Making a HUD.[/QUOTE]
You're not going to accomplish an HUD-worthy circle with surface.DrawCircle().
Use a texture.
[QUOTE=dylanb5123;36583499]You're not going to accomplish an HUD-worthy circle with surface.DrawCircle().
Use a texture.[/QUOTE]
Yeah, I'd believe that using a texture would be waaay better and it would be less complicated to change the way it looks.
Im trying to figure out how to add and remove tabs from the "Q-Menu" for a gamemode, I can't find any info anywhere else could I have some pointers in the right direction?
I'm stuck on a table.insert() problem more info here:
[URL="http://facepunch.com/showthread.php?t=1195457"]http://facepunch.com/showthread.php?t=1195457[/URL]
[QUOTE=Grondo4;36597557]Im trying to figure out how to add and remove tabs from the "Q-Menu" for a gamemode, I can't find any info anywhere else could I have some pointers in the right direction?[/QUOTE]
Take a look at the sandbox source in gamemodes/sandbox/gamemode. You could do so at [url]http://glua.me/bin/[/url] , but that site seems to not be working at the moment.
Looking at the source in cl_spawnmenu of an old update to gmod, I see GM:AddGamemodeToolMenuTabs() for the set of tabs to the right. You add a tool to it by saying spawnmenu.AddToolTab("Tab Name","#tabname","texture path here, such as gui/silkicons/table_edit") .
Look around in your own source to find where you can add different tabs to the left set.
Alpha stopped working for me in GMod13 on SetColor(Color(r,g,b,a)), Anyone know what I'm doing wrong or if there is another way to make it work? I've tried setting the rendermode to something different but it would break the entity's interaction.
[code]
ent:SetColor(Color(255, 255, 255, 0));
[/code]
How would you guys go on about writing a scrollbar?
[QUOTE=A Lost Sandwich;36623932]Alpha stopped working for me in GMod13 on SetColor(Color(r,g,b,a)), Anyone know what I'm doing wrong or if there is another way to make it work? I've tried setting the rendermode to something different but it would break the entity's interaction.
[code]
ent:SetColor(Color(255, 255, 255, 0));
[/code][/QUOTE]
I think you use this along with SetColor:
ent:SetRenderMode(RENDERMODE_TRANSALPHA)
[lua]
function FQuery(name)
if name == nil then return end
local query = database:query("SELECT * FROM test WHERE name = '"..name.."' ")
query.onSuccess = function()
if query:getData()[1] == nil then
return false
else
return true
end
end
query.onError = function(Q,E) Org.Error(E) end
query:start()
end
[/lua]
Having problem with returning a value. That won't return anything, because it returns the values inside query.onSuccess function, not the FQuery().
You have to use a callback function, for example
[lua]
function FQuery(name, callback)
if name == nil then return end
local query = database:query("SELECT * FROM test WHERE name = '"..name.."' ")
query.onSuccess = function()
callback(query:getData()[1])
end
query.onError = function(Q,E) Org.Error(E) end
query:start()
end
[/lua]
Then you pass a function as the second argument, which is what you want to do with the data when it's retrieved.
[QUOTE=Chessnut;36624894]I think you use this along with SetColor:
ent:SetRenderMode(RENDERMODE_TRANSALPHA)[/QUOTE]
Still broke the interaction with the entity,
I found that this worked perfectly for me. This way I don't have to use SetColor to make an ent invisible.
[code]
ent:AddEffects( EF_NOSHADOW | EF_NODRAW )
[/code]
I'm using a DNumSlider in a menu, is there any way I can make it so when I set a value, close out of the menu, and then reopen it the numslider isn't set back at 0 and kept at the value I set it too?
Code:
[LUA]
local NumSliderTest = vgui.Create( "DNumSlider", SheetItemFive )
NumSliderTest:SetPos( 10,50 )
NumSliderTest:SetWide( 150 )
NumSliderTest:SetText( "Testing" )
NumSliderTest:SetMin( 0 ) -- Minimum number of the slider
NumSliderTest:SetMax( .10 ) -- Maximum number of the slider
NumSliderTest:SetDecimals( 2 ) -- Sets a decimal. Zero means it's a whole number
NumSliderTest:SetConVar( "TestConvar" )
NumSliderTest.OnValueChanged = function( panel, value )
if NumSliderTest:GetValue() > .10 then
LocalPlayer():ChatPrint("You can't make it larger than .10")
elseif NumSliderTest:GetValue() < 0 then
LocalPlayer():ChatPrint("You cannot make it a negative value!")
end
end
[/LUA]
Use ConVars?
[QUOTE=I Fail At Lua;36627780]I'm using a DNumSlider in a menu, is there any way I can make it so when I set a value, close out of the menu, and then reopen it the numslider isn't set back at 0 and kept at the value I set it too?
Code:
[LUA]
local NumSliderTest = vgui.Create( "DNumSlider", SheetItemFive )
NumSliderTest:SetPos( 10,50 )
NumSliderTest:SetWide( 150 )
NumSliderTest:SetText( "Testing" )
NumSliderTest:SetMin( 0 ) -- Minimum number of the slider
NumSliderTest:SetMax( .10 ) -- Maximum number of the slider
NumSliderTest:SetDecimals( 2 ) -- Sets a decimal. Zero means it's a whole number
NumSliderTest:SetConVar( "TestConvar" )
NumSliderTest.OnValueChanged = function( panel, value )
if NumSliderTest:GetValue() > .10 then
LocalPlayer():ChatPrint("You can't make it larger than .10")
elseif NumSliderTest:GetValue() < 0 then
LocalPlayer():ChatPrint("You cannot make it a negative value!")
end
end
[/LUA][/QUOTE]
You have to use this: [b][url=http://wiki.garrysmod.com/?title=DNumSlider.SetValue]DNumSlider.SetValue [img]http://wiki.garrysmod.com/favicon.ico[/img][/url][/b]. You should do it so it sets the value of your slider to value of TestConvar
[QUOTE=Drakehawke;36626510]You have to use a callback function, for example
[lua]
function FQuery(name, callback)
if name == nil then return end
local query = database:query("SELECT * FROM test WHERE name = '"..name.."' ")
query.onSuccess = function()
callback(query:getData()[1])
end
query.onError = function(Q,E) Org.Error(E) end
query:start()
end
[/lua]
Then you pass a function as the second argument, which is what you want to do with the data when it's retrieved.[/QUOTE]
Hmm, it wasn't what i exactly looked for but i guess it'll do.
[QUOTE=ollie;36631010]Hmm, it wasn't what i exactly looked for but i guess it'll do.[/QUOTE]
I don't like it either, when you have the database module itself, your own database handler calling stuff from the module, and then you calling the functions in that handler, it just ends up a massive chain of callbacks. Not really another way to do it unfortunately.
@Edit: Deleted lol
[QUOTE=Netheous;36637605]You can always put it in init of the slider :P So it gets called only on initialization of the slider[/QUOTE]
What? Slider?
@Edit: Deleted lol
Oh right, I was replying to ollie, completely unrelated to the slider thing. Or did you quote the wrong post or something?
[QUOTE=Drakehawke;36638688]Oh right, I was replying to ollie, completely unrelated to the slider thing. Or did you quote the wrong post or something?[/QUOTE]
Oh lol, sorry.
I didn't read the thing he has quoted, lol
Is there any way to draw tilted text on the screen? Say, a health bar that is angled like /.
Sorry, you need to Log In to post a reply to this thread.