Minimap Rendering?

I got on a server that had a picture of the map as a minimap and just a blue marker pointing out where you are on the map.
How did they do this? Did they just get a picture from the map or did they render it?

They render it.

render.RenderView

Render view is pretty expensive, they might been using an image, you can create yours with cl_leveloverlay but trust me when I say that implementation is WAAAY hard than you can imagine, either way you might want to use render view

Thanks! One more question. How would i remove the Derma frame without hurting the rendering code.
Because it keeps asking for the frame:Paint whenever i remove the Dframe


 function frame:Paint( w, h )

	local x, y = self:GetPos()

	render.RenderView( {
		origin = Vector( 0, 0, 0 ), -- change to your liking
		angles = Angle( 0, 0, 0 ), -- change to your liking
		x = x,
		y = y,
		w = w,
		h = h,
	 } )

end 

You can use guards in your code:

[lua]
local bIsRenderingView = false
function frame:Paint( w, h )

if ( bIsRenderingView ) then return end
local x, y = self:GetPos()

bIsRenderingView = true
render.RenderView( {
	origin = Vector( 0, 0, 0 ), -- change to your liking
	angles = Angle( 0, 0, 0 ), -- change to your liking
	x = x,
	y = y,
	w = w,
	h = h,
 } )
bIsRenderingView = false

end
[/lua]

I would recommend instead rendering the map to a rendertarget however, and rendering that instead, and update the rendertarget less frequently than the framerate, otherwise you are halving the framerate on a single UI element.

As said above, what you are trying to achieve is easy to say but hard to implement. I have a link here to how some portals worked. The code is complicated because it is trying to achieve something a tad more difficult, however assuming you can ignore that which isn’t pertinent, this link should be helpful: https://github.com/JamesxX/Lobby/blob/master/garrysmod/gamemodes/lobby2_base/entities/entities/lobby_portal/cl_init.lua

Thanks, i will try it out!

The code is giving a error and im a bit confused with the code from JamesxX.


 
[ERROR] lua/autorun/client/cl_map_load.lua:2: attempt to index global 'frame' (a nil value)
  1. unknown - lua/autorun/client/cl_map_load.lua:2

 

I assumed you had defined frame, because you have given me code with a variable called frame:

My code was merely an example of what to do, don’t just copy paste code and complain that it doesn’t work. Most of the time, people will give you pseudocode, not actual code.

Yeah, it defined by itself. But how would i apply that to the new one?

What do you mean it is defined by itself, if you are making the code, you are defining it, not some godly power. How would you apply it to what new one?

Basically, I won’t help you learn Lua, I’ll only show you what parts of the gLua API you’ll want to achieve what you want to achieve. I’ve done this, so I would suggest the PiL as further reading.

I know what you mean and i did not copy and paste it, but i did not understand it. Neither am i complaining just asking for some help.

It justs saying that frame is nil, if you really didn’t copy and paste it, you would know that you had to create your own frame

He’s copied it directly from the wiki:

[lua]
local frame = vgui.Create( ‘DFrame’ )
frame:SetSize( 500, 500 )
frame:Center()
frame:MakePopup()

function frame:Paint( w, h )

local x, y = self:GetPos()

render.RenderView( {
	origin = Vector( 0, 0, 0 ), -- change to your liking
	angles = Angle( 0, 0, 0 ), -- change to your liking
	x = x,
	y = y,
	w = w,
	h = h,
 } )

end
[/lua]

Seem familiar?

Like this?


 local Frame = vgui.Create( "DFrame" )
Frame:SetPos( 15, 5 )
Frame:SetSize( 300, 150 )
Frame:SetTitle( "Map" )
Frame:SetVisible( true )
Frame:SetDraggable( false )
Frame:ShowCloseButton( false )
Frame:MakePopup()
 

If it is saying the Frame is undefined, were there any errors before this? That is to say, was there more than one error, and can you also point out the line of code the error refers to? What color was the error? There are so many things you could be telling us but you don’t.

I ment this one yes: https://github.com/JamesxX/Lobby/blo...al/cl_init.lua

[editline]21st September 2017[/editline]

The error is yellow. Line 2 of the code that you put in the last comment.


 
[ERROR] lua/autorun/client/cl_map_load.lua:2: attempt to index local 'frame' (a nil value)
  1. unknown - lua/autorun/client/cl_map_load.lua:2
 

Try putting it inside a concommand, it might just be too early to create a dFrame when the game loads your file.

Okay, let me try that