SRB2 Message Board  

Go Back   SRB2 Message Board > Sonic Robo Blast 2 > Editing > Editing Help

Reply
 
Thread Tools Search this Thread
Old 3 Weeks Ago   #1
Pizza
 
Pizza's Avatar
Default HUD help

Hud won't load


Code:
local client
local p_startseg
local p_onseg
local p_offseg
local p_endseg
local p_ki

local function kihud(v, player)
    client = player
		if player.mo and player.mo.skin == "songoku"
		  local kipower = 0
		  local kimax   = 0
		  local kidrain = 0
		  if player.kimeter == nil
		      return
		  end
		   kipower = $1 + 80
		   kimax = $1 + player.kimeter
		   kidrain = $1 + player.kimeter+1

          local p_startseg = v.cachePatch("KIGAUGE")
	      local p_onseg    = v.cachePatch("KIGAUGE3")
	      local p_offseg   = v.cachePatch("KIGAUGE4")
	      local p_endseg   = v.cachePatch("KIGAUGE2")
	      local p_ki       = v.cachePatch("KI")	
	      local posx = 130
		  local posy = 0
		  
				posy = 155
			else
				posy = 174 
			end
	
		-- Ending segment first
	v.draw(posx, posy, p_endseg, V_SNAPTOTOP|V_SNAPTORIGHT|V_HUDTRANS)
	posx = $1 - 1
	
    	-- Step through backwards, to match the way we're drawing.
	for i = kimax, 1, -1
		if kipower >= i
			v.draw(posx, posy, p_onseg, V_SNAPTOTOP|V_SNAPTORIGHT|V_HUDTRANS)
		else
			v.draw(posx, posy, p_offseg, V_SNAPTOTOP|V_SNAPTORIGHT|V_HUDTRANS)
		end
		posx = $1 - 8;
	end     	 
		 
		 
		 -- Start segment and BOSS text
	v.draw(posx, posy, p_startseg, V_SNAPTOTOP|V_SNAPTORIGHT|V_HUDTRANS)
	v.draw(posx, posy, p_ki, V_SNAPTOTOP|V_SNAPTORIGHT|V_HUDTRANS);
	        return
	    end
	return
end
hud.add(kihud)
Pizza is offline   Reply With Quote
Old 3 Weeks Ago   #2
NAR the Fox
Self-taught Lua Amateur
 
NAR the Fox's Avatar
Default

I don't know a thing about drawing custom HUD patches, but I think it's a problem with the indentation. Not only that, but you seem to have a problem with your "assignment" operations.
Code:
 local p_onseg    = v.cachePatch("KIGAUGE3")
Here, you have 3 whitespaces. You should only have one. The resulting line should look like this:
Code:
local p_onseg = v.cachePatch("KIGAUGE3")
Not only that, but you also seem to have an unfinished conditional.


This code:

Code:
local posx = 130
     local posy = 0
    -- Don't mind me, just filling in the blank line.

         posy = 155
    else
        posy = 174
    end
should turn into:
Code:
local posx = 130
local posy = 0 -- This line was indented incorrectly, and the same thing goes for the five lines below it.
--IF Statement goes here
    posy = 155
 else
    posy = 174
end

There might be a lot of other errors I haven't caught, but that should be the basic stuff.
__________________
You can just call me "NARbluebear"
My YouTube Channel
NAR the Fox is offline   Reply With Quote
Old 3 Weeks Ago   #3
Pizza
 
Pizza's Avatar
Default

Thanks, i tried it but the hud still won't show up
Edit- never mind solved it

Last edited by Pizza; 3 Weeks Ago at 06:42 PM.
Pizza is offline   Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT. The time now is 12:32 PM.


Powered by vBulletin® Version 3.8.7
Copyright ©2000 - 2020, vBulletin Solutions, Inc.