I feel like I'm being completely ignored D: :tinfoil:
[QUOTE=luavirusfree;39335855]Lol, damn. I guess I'm missing an '=' here?
[ERROR] lua_run:1: '=' expected near '<eof>'
1. unknown - lua_run:0
Also, what tag do you put errors in to make them look like that one comment on this thread?
[lua]
if (SERVER) then return nil end -- We only draw on the client. There is no screen for the server, EVER, even if the host is the server, it's the computer, not them. True for laptops and desktops!
hud = {} -- Creates a lonely table for ONE function.
--hud.maxammo = {} -- Table to get our current weapon's max ammo.
hud.maxammo = 18 -- Max ammo for the pistol. This will change if we have the SMG1.
-- I will comment this so that anyone can understand if they want to make their own HUD. --
function MetroHud() -- Main bulk of the code, loops on.
if hidden then return end -- The player wanted to hide the HUD. Too bad D: we do nothing!
local Scrw, Scrh = ScrW(), ScrH() -- Creates two variables, screen width Scrw, and screan height Scrh. They are exactly equal to the true game resolution.
local HudBG = { -- Names the table of settings.
texture = surface.GetTextureID "CombineHud/met_comb_ovr_2048", -- What texture to use
color = Color(255,255,255,255), -- What color (this color does no change) (RED,GReeN,BLUe,Alpha)
x = 0, -- 0 is the exact start of the width (X is width)
y = 0, -- 0 is the exact start of the height (Y is height)
w = Scrw, -- Cover the entire screen. Width = w
h = Scrh -- Cover the entire screen. Height = h
} -- Ends the table.
local Client = LocalPlayer() -- The player that sees the HUD. Always him or her, never a connected player.
draw.TexturedQuad( HudBG ) -- Draws what the {table} above, HudBG, says to draw.
local HealthBackMet = surface.GetTextureID "CombineHud/met_health_bg" -- Background image for the health readout.
local HealthBarMet = surface.GetTextureID "CombineHud/met_health_bar" -- Image of the actual meter for shields.
local SuitBackMet = surface.GetTextureID "CombineHud/met_shld_lvl" -- Background image for the shield readout.
local SuitBarMet = surface.GetTextureID "CombineHud/met_shld_lvl" -- Image of the actual meter for shields.
local CommandPost = surface.GetTextureID "CombineHud/met_command" -- Not used yet!
local Criminal = surface.GetTextureID "CombineHud/met_criminal" -- Not used yet!
local Promotion = surface.GetTextureID "CombineHud/met_promo" -- Not used yet!
local MeterWidth = Scrw / 4 -- The meter's actual size is one forth of the screen's width.
local MeterWidthBarEnd = MeterWidth-(MeterWidth*math.min((Client:Health()/40),1)*0.5) -- Max health as a metro cop? 40. This sets up the bar for health.
local MeterWidthBar = MeterWidth-(MeterWidth*math.min((Client:Armor()/25),1)*0.5) -- Max shield as a metro cop? 25. This sets up the bar for shield.
local MeterHeight = MeterWidth/4 -- Since the texture resolution for width is 4x the height, we take one forth of our width for height.
surface.SetTexture( HealthBackMet ) -- This tells the game what image to draw.
surface.DrawTexturedRectRotated(Scrw/4,Scrh+MeterHeight,MeterWidth,MeterHeight,0) -- This draws an image. Format: Position <>, position ^v, Width <>, Height &v, Counter Clock Rotation
surface.SetTexture( HealthBarMet ) -- This tells the game what image to draw, and overrides the last time it was set so we don't keep drawing the same thing.
surface.DrawTexturedRectUV(Scrw/4,Scrh+MeterHeight,MeterWidthBarEnd,MeterHeight,MeterWidthBarEnd,MeterHeight) -- Draws the image. Format: Pos Wide, Pos Tall, Image Width, Image Height, How much to show texture wide, same for height.
local PosShieldsX = Scrw-MeterWidth-(Scrw/4) -- Variable. Used so that we draw on the other side of the screen mathematically.
-- local PosShldMetX = Scrw-(MeterWidth*1.5)-(Scrw/4) -- Half way further away because we didn't flip it. -- This was removed when we did flip it.
surface.SetTexture( SuitBackMet ) -- Set and replace image...
surface.DrawTexturedRectRotated(PosShieldsX,Scrh,MeterWidth,MeterHeight,0) -- This draws an image. Format: Position <>, position ^v, Width <>, Height &v, Counter Clock Rotation
surface.SetTexture( SuitBarMet ) -- Set and replace image...
surface.DrawTexturedRectUV(PosShieldsX,Scrh,MeterWidthBar,MeterHeight,MeterWidthBarEnd,MeterHeight) -- Draws the image. Format: Pos Wide, Pos Tall, Image Width, Image Height, How much to show texture wide, same for height.
if Client:GetActiveWeapon():GetPrintName() == "USP Match mod" then hud.maxammo = 18 -- The max ammo for the pistol is 18, 19 with chamber.
elseif Client:GetActiveWeapon():GetPrintName() == "STUNSTICK" then hud.maxammo = -1 -- The Stunstick has 100% ammo, 100 Guass Energy 'rounds'.
elseif Client:GetActiveWeapon():GetPrintName() == "MP7A1 mod" then hud.maxammo = 45 -- The MP7 (SMG1) has 45 rounds, 46 with chamber.
elseif Client:GetActiveWeapon():GetPrintName() == "SPAS-12 mod" then hud.maxammo = 6 -- The shotgun has a 6 round 'clip', with no chamber.
elseif Client:GetActiveWeapon():GetPrintName() == "Pulse Rifle" then hud.maxammo = 30 end -- The shotgun has a 30 round 'clip', with no chamber.
end
hook.Add( "HUDPaint", "MetroHUD", MetroHud ) -- This tells the game to draw the function as the HUD. Format: What to do, A unique name (what purpose?), What function to use to do it. Called before every frame that is drawn.
function HideHUD( name ) -- Allow the combine elements, hide the regular.
if !hidden then -- If the HUD is hidden, then do this:
if name == "CHudHealth" then return false end -- Says that we don't want the DEFAULT health display.
if name == "CHudBattery" then return false end -- Says that we don't want the DEFAULT battery display.
if name == "CHudAmmo" then return false end -- Says that we don't want the DEFAULT ammo display.
if name == "CHudSecondaryAmmo" then return false end -- Says that we don't want the DEFAULT alt-fire ammo display.
if name == "CHudCrosshair" then return false end -- Says that we don't want the DEFAULT crosshair.
if name == "CHudDeathNotice" then return false end -- Says that we don't want to know who killed who, and who died.
if name == "CHudWeaponSelection" then return false end -- Says that we don't want the DEFAULT weapon selection.
if name == "CHudSquadStatus" then return false end -- Says that we don't want the squad display, for rebels.
if name == "CHudZoom" then return false end -- Says that we don't want things darker when we zoom.
if name == "CHudHistoryResource" then return false end -- Says that we don't want to know what we have picked up, ammo-wise.
end -- Closes the first "if" statement. The other ones close themselves.
return true -- Should we make "the drawing" of these things do what we say? true. Otherwise, false.
-- Format is: if name(default HUD function set) ==(is exactly) "Individual Function Name, case sensitive) then(Do this:) return(Give an answer) bool(false=no, true=yes) end(finishes it)
end -- We are done with this function, so stop it here.
hook.Add("HUDShouldDraw","HideHUD",HideHUD) -- Should we draw? Everything that the function doesn't say no to. Act, Name, Function.
local hidden = false -- Create the variable why don't we?
function hud.hideme() -- function used to hide this HUD.
if hidden == false then -- If we're not hidden, then
hidden = true --*cry* ... Hide us!
elseif hidden == true then -- If we're already hidden, then (elseif means that we add an if statement to this code block. We don't need to end the if we started with.)
hidden = false --oh now you want me back. Show us!
end -- Done. We now know what to do.
end -- Done, we have nothing else to do =P
concommand.Add("z420hud_toggle","Hide Combine Hud",hud.hideme) -- Create the console command that hides this HUD. Format: "CommandName", "Description", function to use.
[/lua]
Of course, my comments make no sense since it doesn't work...[/QUOTE]
And also, how do I make a prop_combine_ball that doesn't just go through every world surface? (with the owner of the swep as the owner of the combine's ball)?
Shouldn't you be posting this in the [URL=http://www.facepunch.com/forumdisplay.php?f=65]Lua section[/URL]?
I already did! ... and then quoted it. I'm just being ignored there.
[editline]24th January 2013[/editline]
That's why you see it as a quote here...
jesus christ why did you comment literally every line
?? What are you talking about?
[editline]24th January 2013[/editline]
If you mean "Why is there a message from you on every second line" then still, what are you talking about? For some of my threads, it is like that, but that's because I really want the answer. I have nothing else to do, right now.
[QUOTE=luavirusfree;39341101]I already did! ... and then quoted it. I'm just being ignored there.
[editline]24th January 2013[/editline]
That's why you see it as a quote here...[/QUOTE]
I see. Still, I'm pretty sure you're more likely to get help there.
Oh! In the script. That's because people sometimes take a script that someone else has made to give themselves an idea on how to make their own version.
[editline]24th January 2013[/editline]
[QUOTE=Mozartkugeln;39341165]I see. Still, I'm pretty sure you're more likely to get help there.[/QUOTE]
I've had this problem before, where I wasn't getting an answer in LUA. I got the answer in this thread section, instead.
Do you seriously think you need to add a comment to a line that just says "end"? You're actually making it twice as hard for people to read your code by adding all that useless junk that you can [I]read from the code itself anyway[/I].
Here's some advice:
[QUOTE=Linus Torvalds]Comments are good, but there is also a danger of over-commenting. NEVER try to explain HOW your code works in a comment: it's much better to write the code so that the [I]working[/I] is obvious, and it's a waste of time to explain badly written code. Generally, you want your comments to tell WHAT your code does, not HOW. Also, try to avoid putting comments inside a function body: if the function is so complex that you need to separately comment parts of it, you should probably go back to chapter 4 for a while. You can make small comments to note or warn about something particularly clever (or ugly), but try to avoid excess. Instead, put the comments at the head of the function, telling people what it does, and possibly WHY it does it.[/QUOTE]
[editline]24th January 2013[/editline]
[QUOTE=luavirusfree;39341048][lua]texture = surface.GetTextureID "CombineHud/met_comb_ovr_2048"[/lua][/QUOTE]
You're missing the parentheses; it should be [I]surface.GetTextureID("texturepath")[/I]. [I]GetTextureID[/I] is a function, and function take arguments which you put in their parentheses. Same mistake occurs several times in the code.
I really suggest getting a book on programming and starting from scratch as it'll help you get a hang of the basics and get rid of the bad habits. If you want to go with Lua, start with [I][URL=http://www.lua.org/pil/]Programming in Lua[/URL][/I] by the language's creator.
Also, if you're looking for help on a specific issue, you should post the error message you get when you run your code. That tells people where to look: which function caused the error and on what line.
Sorry, you need to Log In to post a reply to this thread.