Ergebnis 1 bis 6 von 6

Thema: Advanced HealthBar

  1. #1
    Avatar von Mentos
    Registriert seit
    08.09.2007
    Ort
    München

    Standard Advanced HealthBar

    Hy... schön zu sehen das die GMod.de community wieder lebt

    Auch ich bin nach kurzer Pause wieder am Scripten und kam auf die Idee das eine andere Art von Healthbar doch was schönes wäre.
    In meinem Denkstübchen sieht die Idee so aus, wie die Lebens und Mana Kugeln in Diablo II... nur halt übereinander!

    Natürlich strebe ich höhere Ziele an aber dazu dann eventuell später.
    Das ganze würde ich gerne so umsetzen, das sich die Bilder/Texturen überlappen, so das vorne Leben und dahinter Mana/Rüstung oder sonst was ist.
    Zu diesem Thema habe ich DAS gefunden...
    Bevor ich aber 2 Stunden Texturen entwerfe, welche dann aufgrund von bekannten Pixelbeschrenkungen grottig hingerichtet werden, würde ich lieber erst erfahren ob es überhaupt so geht und falls ja eventuell auch mit PNG oder BMP oder so

    Hintergrund ist eine entfernte Erinnerung an einen PropHunt Server der eine Art Kreis hatte der mit dem Leben abnahm.

    Vielen dank für alle Überlegungen!

    PS: Ich will keinen ganzen code oder so! Nur die Aussage ob es geht und mit welchen Befehlen besagtes Problem umgesetzt werden kann

    Gruß Mentos
    Zitat Zitat von pacmcmax Beitrag anzeigen
    ich kann mich nicht in kurzen worten zusammen fassen

  2. #2
    Avatar von Mentos
    Registriert seit
    08.09.2007
    Ort
    München

    Standard AW: Advanced HealthBar

    PUSH+

    habe jetzt doch schonmal angefangen...
    Ich habe das Script das ich oben angegeben hatte eingefelchtet und bin nun auch dazu gekommen die textur mit Material einzubinden.
    Jetzt bekomm ich allerdings einen Fehler, der mir noch nie unter kam
    Code:
    --- Missing Vgui material 010000materials/body
    --- Missing Vgui material 010000body
    (es kommen 2 texturen, da ich testweise versuche welches von beiden funktioniert!)
    Habe dafür die body.png auf dem Client in materials\body.png und auf dem Server im gamemodecontentordner\materials\body.png
    (da es irgendwann mal runtergeladen werden soll)

    eventuell könnt ihr mich aufklären D;

    CODE:
    Code:
    --- //// ---
    
    local HUDMAT = Material ( "materials/body.png", "nocull" )
    local THUDMAT = HUDMAT:GetTexture( "$basetexture" )
    
    if(THUDMAT) then
    	print("THUDMAT")
    else
    	print("not 1")
    end
    
    local HUDMATT = Material ( "body.png", "nocull" )
    local THUDMATT = HUDMATT:GetTexture( "$basetexture" )
    
    if(THUDMATT) then
    	print("THUDMATT")
    else
    	print("not 2")
    end
    
    --- //// --- im HUDDraw
    
    draw.DrawPartialTexturedRect( 100.0, 100.0, 50.0, 75.0, 0.0, 0.0, 2000.0, 3000.0, THUDMAT:GetName() )
    draw.DrawPartialTexturedRect( 200, 100, 50, 75, 0, 0, 2000, 3000, THUDMATT:GetName() )
    
    --- //// ---
    IMaterial ist insgesamt nicht wirklich alles in allem nicht so gut erklärt...

    IMaterial:GetTexture( string materialTexture )
    ...-> string materialTexture
    ........The name of the material texture.
    Zitat Zitat von pacmcmax Beitrag anzeigen
    ich kann mich nicht in kurzen worten zusammen fassen

  3. #3

    Standard AW: Advanced HealthBar

    Printe mal THUDMAT und THUDMAT:GetName()
    ohne die " "

    pack zur not mal die png files in den Materials ordner (im hauptordner, nicht content)

  4. #4
    Avatar von Mentos
    Registriert seit
    08.09.2007
    Ort
    München

    Standard AW: Advanced HealthBar

    das png habe ich schon auf dem client in den materials ordner gepackt...

    Code:
    print(THUDMAT)
    -- userdata: 0x29343d48
    print(THUDMAT:GetName())
    -- 010000materials/body
    
    
    print(THUDMATT)
    -- userdata: 0x29343dc8
    print(THUDMATT:GetName())
    -- 010000body
    Geändert von Mentos (27.01.2014 um 13:49 Uhr)
    Zitat Zitat von pacmcmax Beitrag anzeigen
    ich kann mich nicht in kurzen worten zusammen fassen

  5. #5

    Standard AW: Advanced HealthBar

    Probier mal das hier:

    http://facepunch.com/showthread.php?t=1218490

    Zitat:
    Use Material() instead of surface.GetTextureID(), and surface.SetMaterial() instead of surface.SetTexture()
    Also den DrawPartialTexturedRect code umschreiben.

    Edit:
    hab den code mal umgeschrieben, dass er funktioniert (Den drawpartialtexturedrect code, nicht deiner. Hab aber ein beispiel unter TEST CODE gelegt.
    Code:
    -- Check if we are being run on the server and add this file to the client
    if( SERVER )then
    	AddCSLuaFile( "textureSheet.lua" );
    	
    	-- We don't need these functions on the server
    	return;
    end;
    
    
    --- TEST CODE
    hook.Add("HUDPaint", "testhudpaint", function()
        draw.DrawPartialTexturedRect( 512, 512, 256, 256, 0, 0, CurTime(), CurTime(), "spawnicons/models/alyx_intro.png" );
    end);
    --- TEST CODE
    
    -- A function to draw a certain part of a texture
    function surface.DrawPartialTexturedRect( x, y, w, h, partx, party, partw, parth, texw, texh )
    	--[[ 
    		Arguments:
    		x: Where is it drawn on the x-axis of your screen
    		y: Where is it drawn on the y-axis of your screen
    		w: How wide must the image be?
    		h: How high must the image be?
    		partx: Where on the given texture's x-axis can we find the image you want?
    		party: Where on the given texture's y-axis can we find the image you want?
    		partw: How wide is the partial image in the given texture?
    		parth: How high is the partial image in the given texture?
    		texw: How wide is the texture?
    		texh: How high is the texture?
    	]]--
    	
    	-- Verify that we recieved all arguments
    	if not( x && y && w && h && partx && party && partw && parth && texw && texh ) then
    		ErrorNoHalt("surface.DrawPartialTexturedRect: Missing argument!");
    		
    		return;
    	end;
    	
    	-- Get the positions and sizes as percentages / 100
    	local percX, percY = partx / texw, party / texh;
    	local percW, percH = partw / texw, parth / texh;
    	
    	-- Process the data
    	local vertexData = {
    		{
    			x = x,
    			y = y,
    			u = percX,
    			v = percY
    		},
    		{
    			x = x + w,
    			y = y,
    			u = percX + percW,
    			v = percY
    		},
    		{
    			x = x + w,
    			y = y + h,
    			u = percX + percW,
    			v = percY + percH
    		},
    		{
    			x = x,
    			y = y + h,
    			u = percX,
    			v = percY + percH
    		}
    	};
    		
    	surface.DrawPoly( vertexData );
    end;
    
    -- A function to draw a certain part of a texture
    function draw.DrawPartialTexturedRect( x, y, w, h, partx, party, partw, parth, texture )
    	--[[ 
    		Arguments:
    		- Also look at the arguments of the surface version of this
    		texturename: What is the name of the texture?
    	]]--
    	
    	-- Verify that we recieved all arguments
    	if not( x && y && w && h && partx && party && partw && parth && texture ) then
    		ErrorNoHalt("draw.DrawPartialTexturedRect: Missing argument!");
    		
    		return;
    	end;
    	
    
    	-- Get the positions and sizes as percentages / 100
    	local mat = Material( texture, "nocull" );
    	local texW = mat:Height()
    	local texH = mat:Width()
    	local percX, percY = partx / texW, party / texH;
    	local percW, percH = partw / texW, parth / texH;
    	
    	-- Process the data
    	local vertexData = {
    		{
    			x = x,
    			y = y,
    			u = percX,
    			v = percY
    		},
    		{
    			x = x + w,
    			y = y,
    			u = percX + percW,
    			v = percY
    		},
    		{
    			x = x + w,
    			y = y + h,
    			u = percX + percW,
    			v = percY + percH
    		},
    		{
    			x = x,
    			y = y + h,
    			u = percX,
    			v = percY + percH
    		}
    	};
    	
    	surface.SetMaterial( mat );
    	surface.SetDrawColor( 255, 255, 255, 255 );
    	surface.DrawPoly( vertexData );
    end;
    http://s14.directupload.net/images/140127/apvgttjs.jpg
    (er zoomt langsam aus, in dem beispiel)
    Geändert von gamerpaddy (27.01.2014 um 15:00 Uhr)

  6. Folgender Benutzer sagt Danke zu gamerpaddy für den nützlichen Beitrag:


  7. #6
    Avatar von Mentos
    Registriert seit
    08.09.2007
    Ort
    München

    Standard AW: Advanced HealthBar

    Danke! ich versuche es gleich mal

    EDIT:
    Top! Klappt bestens.
    Es ist unglaublich wie einfach man hochqualitative Bilder damit darstellen kann...

    Ich lade bei gelegenheit mal ein paar "Finished" Bilder hoch ;D

    EDIT2:
    So ergebnis ist verfügbar ;D
    bsp.png
    Vielen Dank für die Hilfe

    Gruß Mentos
    Geändert von Mentos (28.01.2014 um 15:40 Uhr)
    Zitat Zitat von pacmcmax Beitrag anzeigen
    ich kann mich nicht in kurzen worten zusammen fassen

Ähnliche Themen

  1. Advanced Gyropod
    Von steven150 im Forum Addon: Wiremod
    Antworten: 7
    Letzter Beitrag: 30.09.2009, 17:10
  2. Adv.pod advanced hilfe
    Von Lt.Col.Phoenix im Forum Hilfe & Support
    Antworten: 1
    Letzter Beitrag: 27.05.2009, 20:40
  3. Advanced Duplicator
    Von freaky03 im Forum Addons
    Antworten: 2
    Letzter Beitrag: 26.02.2008, 03:00
  4. Advanced Duplicator?
    Von TDS Deadline im Forum Hilfe & Support
    Antworten: 2
    Letzter Beitrag: 11.12.2007, 09:14
  5. Advanced Lua Tutorial
    Von Scarecrow im Forum Wünsche
    Antworten: 0
    Letzter Beitrag: 05.04.2007, 15:03

Berechtigungen

  • Neue Themen erstellen: Nein
  • Themen beantworten: Nein
  • Anhänge hochladen: Nein
  • Beiträge bearbeiten: Nein
  •