• Problems That Don't Need Their Own Thread v3.0
    5,003 replies, posted
Does the x co-ordinate of draw.drawtext start half way through the string, instead of on the left? For example, if I use 0 for x with draw.RoundedBox, it'll be against the screen but with text, half of it gets cut out
[QUOTE=NiandraLades;48810161]Does the x co-ordinate of draw.drawtext start half way through the string, instead of on the left? For example, if I use 0 for x with draw.RoundedBox, it'll be against the screen but with text, half of it gets cut out[/QUOTE] Read the [url=http://wiki.garrysmod.com/page/draw/DrawText]draw.DrawText[/url] wiki page. It has a method for X-axis aligning.
Oh my god, fuck I already read it a few times and the align thing went completely over my head, ty
[QUOTE=Zelpa;48808997]Yep, that was stupid of me. Here's the entire error. [code][ERROR] A runtime error has occurred in "addons/darkrpmodification/lua/entities/zelpa_basefood/init.lua" on line 196. The best help I can give you is this: bad argument #3 to 'SetFunc' (string expected, got nil) Hints: - No hints, sorry. The responsibility for this error lies with (the authors of) one (or more) of these files: 1. addons/darkrpmodification/lua/entities/zelpa_basefood/init.lua on line 196 2. gamemodes/darkrp/gamemode/libraries/fn.lua on line 80 3. gamemodes/darkrp/gamemode/modules/base/sh_createitems.lua on line 606 4. gamemodes/darkrp/gamemode/modules/chat/sv_chat.lua on line 17 5. gamemodes/darkrp/gamemode/modules/chat/sv_chat.lua on line 75 6. gamemodes/darkrp/gamemode/modules/chat/sv_chat.lua on line 139 ------- End of Simplerr error ------- [/code][/QUOTE] Looks like it's something with the spawn function you made. I'm not entirely sure without seeing the code but based on what you've posted before, it could be that "soda" in "foodEnt:SetFoodType( soda )" is nil.
[QUOTE=Z0mb1n3;48807707][img]http://wiki.garrysmod.com/favicon.ico[/img] [url=http://wiki.garrysmod.com/page/ents/FindInSphere]ents.FindInSphere[/url] [IMG]http://wiki.garrysmod.com/favicon.ico[/IMG] [URL="http://wiki.garrysmod.com/page/Global/pairs"]Global.pairs[/URL] [IMG]http://wiki.garrysmod.com/favicon.ico[/IMG] [URL="http://wiki.garrysmod.com/page/Entity/IsOnFire"]Entity:IsOnFire[/URL] [IMG]http://wiki.garrysmod.com/favicon.ico[/IMG] [URL="http://wiki.garrysmod.com/page/Entity/Extinguish"]Entity:Extinguish[/URL][/QUOTE] pairs is bad and slow don't use pairs use [IMG]http://wiki.garrysmod.com/favicon.ico[/IMG][URL="http://wiki.garrysmod.com/page/Global/next"]next[/URL]
[QUOTE=PaX_;48813607]pairs is bad and slow don't use pairs use [IMG]http://wiki.garrysmod.com/favicon.ico[/IMG][URL="http://wiki.garrysmod.com/page/Global/next"]next[/URL][/QUOTE] If I were a simple man, I would say "fuck you", but I am a complex man so I will explain that the speed you gain is simply immeasurable.
[QUOTE=zerf;48813627]If I were a simple man, I would say "fuck you", but I am a complex man so I will explain that the speed you gain is simply immeasurable.[/QUOTE] yes it's completely pointless and sometimes fucks up but dude the 1.000000000000000000000000000000000001x speed boost is amazing
[QUOTE=Bo98;48811508]Looks like it's something with the spawn function you made. I'm not entirely sure without seeing the code but based on what you've posted before, it could be that "soda" in "foodEnt:SetFoodType( soda )" is nil.[/QUOTE] Yep, forgot that it takes a string "soda", which makes it work. But I want this to work for each item in the loop. If I just set it to v, it tried to grab the entire table instead. I want to just grab the soda part in foodItems.soda as a string, I tried toString(v) but that didn't work.
If Z0mb1n3 wanted to test out my weird line bug, then this is basically the code I'm using (which has the same problem of a render.DrawLine being able to get behind the model on the panel, but a render.DrawBox not being able to. [CODE]concommand.Add( 'ModelPanelTest', function() local White = Material( 'vgui/white' ) local basepanel = vgui.Create( 'DFrame' ) basepanel:SetSize(400,400) basepanel:Center() basepanel:MakePopup() basepanel:SetSizable(true) local modelpanel = vgui.Create( 'DModelPanel', basepanel ) modelpanel:Dock(FILL) modelpanel:SetModel( 'models/props_c17/oildrum001.mdl' ) modelpanel:SetLookAt( Vector( 0, 0, 0 ) ) modelpanel.Angles = Angle( 0, 0, 0 ) --For the turning function modelpanel:DrawModel() --This is all default local curparent = self local rightx = self:GetWide() local leftx = 0 local topy = 0 local bottomy = self:GetTall() local previous = curparent while( curparent:GetParent() != nil ) do curparent = curparent:GetParent() local x, y = previous:GetPos() topy = math.Max( y, topy + y ) leftx = math.Max( x, leftx + x ) bottomy = math.Min( y + previous:GetTall(), bottomy + y ) rightx = math.Min( x + previous:GetWide(), rightx + x ) previous = curparent end render.SetScissorRect( leftx, topy, rightx, bottomy, true ) self.Entity:DrawModel() --It stops being default here local vector = self.Entity:LocalToWorld( Vector( 0, 15, 0 ) ) render.SetMaterial( White ) render.DrawLine( vector, vector+Vector(10,0,0), Color( 255, 255, 255, 255 ), true ) render.DrawBox( vector, Angle(0,0,0), Vector(-1,-1,-1), Vector(1,1,1), Color(255,255,255,255), true ) render.SetScissorRect( 0, 0, 0, 0, false ) end --All this stuff below is just so you can turn the model function modelpanel:DragMousePress() self.PressX, self.PressY = gui.MousePos() self.Pressed = true end function modelpanel:DragMouseRelease() self.Pressed = false end function modelpanel:LayoutEntity( ent ) if ( self.Pressed ) then local mx, my = gui.MousePos() self.Angles = self.Angles - Angle( 0, ( self.PressX or mx ) - mx, 0 ) self.PressX, self.PressY = gui.MousePos() end ent:SetAngles( self.Angles ) end end )[/CODE] It looks pretty long but that's only because it has big sections of default functions copied. The only bit that's actually important is the [CODE] render.DrawLine( vector, vector+Vector(10,0,0), Color( 255, 255, 255, 255 ), true ) render.DrawBox( vector, Angle(0,0,0), Vector(-1,-1,-1), Vector(1,1,1), Color(255,255,255,255), true ) [/CODE] Since the line works and the box doesn't.
[QUOTE=Zelpa;48813955]Yep, forgot that it takes a string "soda", which makes it work. But I want this to work for each item in the loop. If I just set it to v, it tried to grab the entire table instead. I want to just grab the soda part in foodItems.soda as a string, I tried toString(v) but that didn't work.[/QUOTE] If you are using for k,v in pairs(table) then you can use k to get the name of the table.
Getting some console spam when trying to spawn in a jeep with the stupidly simple code bellow [lua]local jeep = ents.Create("prop_vehicle_jeep") jeep:SetPos(Vector(1400, 1900, 360)) jeep:Spawn()[/lua] It's spamming Bad pstudiohdr in GetSequenceLinearMotion()! Most likely I'm missing something that the vehicle needs to spawn but idk what it is. I've tried also adding a SetModel to the buggy.mdl.
[QUOTE=roastchicken;48813990]If you are using for k,v in pairs(table) then you can use k to get the name of the table.[/QUOTE] Fantastic, now this all works nicely. Only problem left is that the entities don't appear in the f4 menu. Doing the function normally shows them in the f4 menu, but not when I do it in a loop? It's weird. Edit: duh, wasn't calling it clientside :v:. No errors now, it appears in the f4 menu. Thanks for all the help with this guys.
[QUOTE=YourStalker;48814079]Getting some console spam when trying to spawn in a jeep with the stupidly simple code bellow local jeep = ents.Create("prop_vehicle_jeep")jeep:SetPos(Vector(1400, 1900, 360))jeep:Spawn() It's spamming Bad pstudiohdr in GetSequenceLinearMotion()! Most likely I'm missing something that the vehicle needs to spawn but idk what it is. I've tried also adding a SetModel to the buggy.mdl.[/QUOTE] -snip i didnt read- Are you giving it a vehicle script as well? Sometimes it needs that.
[QUOTE=Z0mb1n3;48814438]Give it a model.[/QUOTE] [QUOTE=YourStalker;48814079]I've tried also adding a SetModel to the buggy.mdl.[/QUOTE] Also Z0mb1n3, any ideas why the ModelPanel thing with the render lines isn't working (check the page back from this one, I posted some code)
[QUOTE=MPan1;48814607]Also Z0mb1n3, any ideas why the ModelPanel thing with the render lines isn't working (check the page back from this one, I posted some code)[/QUOTE] Just got home, gonna test it now [editline]2nd October 2015[/editline] Set the box to a different material other than vgui/white. Use "debug/debugdrawflat" [editline]2nd October 2015[/editline] YourStalker: [code] local jeep = ents.Create("prop_vehicle_jeep_old") jeep:SetModel("models/buggy.mdl") jeep:SetKeyValue("vehiclescript", "scripts/vehicles/jeep_test.txt") jeep:SetPos(Vector(1400, 1900, 360)) jeep:Spawn() [/code] not sure if you wanted the jalopy or the regular jeep.
[QUOTE=Z0mb1n3;48814803]Set the box to a different material other than vgui/white. Use "debug/debugdrawflat"[/QUOTE] :excited: THANKS SO MUCH! [editline]3rd October 2015[/editline] Can someone explain what the hell [img]http://wiki.garrysmod.com/favicon.ico[/img] [url=http://wiki.garrysmod.com/page/GM/GrabEarAnimation]GM/GrabEarAnimation[/url] does?
My table isn't keeping it's position for each item. Table: [code] Buttons = { Home = "Home", Tasks = "Tasks", Software = "Software", Internet = "Internet", Logs = "Logs", Hardware = "Hardware", Research = "Research", Finances = "Finances", Database = "Hacked Database", Missions = "Missions", }, [/code] Result: [IMG]http://i.imgur.com/ipjpppM.png[/IMG] If you're wondering why I use names for the table variables: [code] for btn,name in pairs(GHack.Buttons) do local button = vgui.Create("ghack_menu_button",GHack.Panel.sidebar) button:SetText(name) button:SetImage(GHack.Icons[btn]) --set icon based on button name button:Dock(TOP) end [/code]
snip
[QUOTE=PortalGod;48817658]use ipairs if you want to keep the order[/QUOTE] Doesn't ipairs only work with numerical tables?
[QUOTE=PortalGod;48817658]use ipairs if you want to keep the order[/QUOTE] I'd use ipairs if I didn't have to set the icon based on the name, but since I'm using nonidentical names (ex: database icon variable != database name string) I can't
[QUOTE=LUModder;48817622]My table isn't keeping it's position for each item. Table: [code] Buttons = { Home = "Home", Tasks = "Tasks", Software = "Software", Internet = "Internet", Logs = "Logs", Hardware = "Hardware", Research = "Research", Finances = "Finances", Database = "Hacked Database", Missions = "Missions", }, [/code] Result: [IMG]http://i.imgur.com/ipjpppM.png[/IMG] If you're wondering why I use names for the table variables: [code] for btn,name in pairs(GHack.Buttons) do local button = vgui.Create("ghack_menu_button",GHack.Panel.sidebar) button:SetText(name) button:SetImage(GHack.Icons[btn]) --set icon based on button name button:Dock(TOP) end [/code][/QUOTE] [code]Buttons = { {text = "Home", icon = "whatever"} {text = "Tasks", icon = "whatever"} {text = "Software", icon = "whatever"} {text = "Internet", icon = "whatever"} {text = "Logs", icon = "whatever"} {text = "Hardware", icon = "whatever"} {text = "Research", icon = "whatever"} {text = "Finances", icon = "whatever"} {text = "Hacked Database", icon = "whatever"} {text = "Missions", icon = "whatever"} },[/code]
Where can I disable the info that draws when a player aims at another player in sandbox? EDIT: nevermind, found it
[QUOTE=Author.;48817878][code]Buttons = { {text = "Home", icon = "whatever"} {text = "Tasks", icon = "whatever"} {text = "Software", icon = "whatever"} {text = "Internet", icon = "whatever"} {text = "Logs", icon = "whatever"} {text = "Hardware", icon = "whatever"} {text = "Research", icon = "whatever"} {text = "Finances", icon = "whatever"} {text = "Hacked Database", icon = "whatever"} {text = "Missions", icon = "whatever"} },[/code][/QUOTE] Plus, you can always make the icon path optional and generate it from text like so: local icon = t.icon or "icons/" .. t.text:lower() .. ".png"
Anyone know the answer for question 1 of [URL="https://facepunch.com/showthread.php?t=1486872"]this[/URL] (something to do with DModelPanels that I never got answered :huh: )
[QUOTE=MPan1;48819629]Anyone know the answer for question 1 of [URL="https://facepunch.com/showthread.php?t=1486872"]this[/URL] (something to do with DModelPanels that I never got answered :huh: )[/QUOTE] [code] (pos1 - pos2):GetNormalized():Angle() -- pos1 is the worldspace coordinate on the model, pos2 is the camera position [/code] or did i misunderstand
[QUOTE=Z0mb1n3;48819680][code] (pos1 - pos2):GetNormalized():Angle() -- pos1 is the worldspace coordinate on the model, pos2 is the camera position [/code] or did i misunderstand[/QUOTE] I'm probably doing something wrong-this is what I'm trying ([B]NONE OF IT MATTERS UNTIL THE PART COMMENTED THAT IT ACTUALLY MATTERS[/B]) I just included the rest if you wanted to test. [CODE] concommand.Add( 'DermaPositioning', function() --NONE OF THIS IS THE PROBLEM YET local White = CreateMaterial( 'earthwhitematerial', 'UnlitGeneric', '$flat %noToolTexture' ) local panel = vgui.Create('DFrame') panel:SetSize(500,500) panel:Center() panel:MakePopup() local modelpanel = vgui.Create('DModelPanel',panel) modelpanel:Dock(FILL) modelpanel:SetLookAt(Vector(0,0,0)) modelpanel:SetFOV(50) modelpanel:SetModel('models/props_c17/canister_propane01a.mdl') function modelpanel:DrawModel() local curparent = self local rightx = self:GetWide() local leftx = 0 local topy = 0 local bottomy = self:GetTall() local previous = curparent while( curparent:GetParent() != nil ) do curparent = curparent:GetParent() local x, y = previous:GetPos() topy = math.Max( y, topy + y ) leftx = math.Max( x, leftx + x ) bottomy = math.Min( y + previous:GetTall(), bottomy + y ) rightx = math.Min( x + previous:GetWide(), rightx + x ) previous = curparent end render.SetScissorRect( leftx, topy, rightx, bottomy, true ) self.Entity:DrawModel() local vec = self.Entity:LocalToWorld(Vector( 0, 12, 0 )) render.SetMaterial( White ) render.DrawBox( vec, Angle( 0, 0, 0 ), Vector( -1, -1, -1 ), Vector( 1, 1, 1 ), Color( 255, 255, 255, 255 ), true ) render.SetScissorRect( 0, 0, 0, 0, false ) end function modelpanel:DoClick() --THIS IS WHAT ACTUALLY MATTERS self.Entity:SetAngles( ( self.Entity:LocalToWorld(Vector(0,12,0)) - self.vCamPos ):GetNormalized():Angle() ) end function modelpanel:LayoutEntity( ent ) end end ) [/CODE]
[QUOTE=MPan1;48819959]I'm probably doing something wrong-this is what I'm trying ([B]NONE OF IT MATTERS UNTIL THE PART COMMENTED THAT IT ACTUALLY MATTERS[/B]) I just included the rest if you wanted to test. [CODE] concommand.Add( 'DermaPositioning', function() --NONE OF THIS IS THE PROBLEM YET local White = CreateMaterial( 'earthwhitematerial', 'UnlitGeneric', '$flat %noToolTexture' ) local panel = vgui.Create('DFrame') panel:SetSize(500,500) panel:Center() panel:MakePopup() local modelpanel = vgui.Create('DModelPanel',panel) modelpanel:Dock(FILL) modelpanel:SetLookAt(Vector(0,0,0)) modelpanel:SetFOV(50) modelpanel:SetModel('models/props_c17/canister_propane01a.mdl') function modelpanel:DrawModel() local curparent = self local rightx = self:GetWide() local leftx = 0 local topy = 0 local bottomy = self:GetTall() local previous = curparent while( curparent:GetParent() != nil ) do curparent = curparent:GetParent() local x, y = previous:GetPos() topy = math.Max( y, topy + y ) leftx = math.Max( x, leftx + x ) bottomy = math.Min( y + previous:GetTall(), bottomy + y ) rightx = math.Min( x + previous:GetWide(), rightx + x ) previous = curparent end render.SetScissorRect( leftx, topy, rightx, bottomy, true ) self.Entity:DrawModel() local vec = self.Entity:LocalToWorld(Vector( 0, 12, 0 )) render.SetMaterial( White ) render.DrawBox( vec, Angle( 0, 0, 0 ), Vector( -1, -1, -1 ), Vector( 1, 1, 1 ), Color( 255, 255, 255, 255 ), true ) render.SetScissorRect( 0, 0, 0, 0, false ) end function modelpanel:DoClick() --THIS IS WHAT ACTUALLY MATTERS self.Entity:SetAngles( ( self.Entity:LocalToWorld(Vector(0,12,0)) - self.vCamPos ):GetNormalized():Angle() ) end function modelpanel:LayoutEntity( ent ) end end ) [/CODE][/QUOTE] i shall test this at once [code]self.Entity:SetAngles( (Vector(self.vCamPos.x, self.vCamPos.y, 0) - self.Entity:LocalToWorld(Vector(0, 12, 0)) ):GetNormalized():Angle())[/code] does that do what you want
[QUOTE=Z0mb1n3;48820262] does that do what you want[/QUOTE] Sadly not, but I'll do more fiddling around, thanks for trying anyway! Also, if I put that code into the example it doesn't seem to get the vector to be in the middle? Did you use that code or your own?
[QUOTE=MPan1;48820348]Sadly not, but I'll do more fiddling around, thanks for trying anyway! Also, if I put that code into the example it doesn't seem to get the vector to be in the middle? Did you use that code or your own?[/QUOTE] I used the vector you were using, I assumed you wanted it to face a direction based on the vector given?
[QUOTE=Z0mb1n3;48820762]I assumed you wanted it to face a direction based on the vector given?[/QUOTE] For me when I use your code the vector doesn't face the camera (i.e. I can't see the white cube anywhere)-maybe I didn't say but I didn't just want it in the centre, but also to face the camera (sorry if it works for you, but it doesn't for me).
Sorry, you need to Log In to post a reply to this thread.