I was working on a script after seeing a lot of tutorials, and it actually worked! Then, I tried combining it into a new, better script. The purpose of the original is to echo the difference of scores at every freeze. The purpose of the other is to do that, and when the player is winning to put a transparent box in the lower right corner, a blue box when Uke is winning, and a white box when it's a draw. Here is the original:
function winscore()
Player1_Score = get_player_info(1).injury
Player2_Score = get_player_info(0).injury
if(Player1_Score > Player2_Score) then
echo("Player 1 is winning by" .. " " .. (Player1_Score - Player2_Score))
elseif(Player2_Score > Player1_Score) then
echo("Player 2 is winning by" .. " " .. (Player2_Score - Player1_Score))
else
echo("It's a draw!")
end
end
add_hook("enter_freeze","echowinner",winscore)
And here is the new one:
function winscorehit()
Player1_Score = get_player_info(1).injury
Player2_Score = get_player_info(0).injury
if(Player1_Score > Player2_Score) then
function draw2dfunc1()
set_color(1,1,0,0.2)
draw_quad(10,300,100,200)
end
end
elseif(Player2_Score > Player1_Score) then
function draw2dfunc2()
set_color(0,1,1,0.2)
draw_quad(10,300,100,200)
end
end
else
function draw2dfunc3()
set_color(1,1,1,0.2)
draw_quad(10,300,100,200)
end
end
function winscore()
Player1_Score = get_player_info(1).injury
Player2_Score = get_player_info(0).injury
if(Player1_Score > Player2_Score) then
echo("Player 1 is winning by" .. " " .. (Player1_Score - Player2_Score))
elseif(Player2_Score > Player1_Score) then
echo("Player 2 is winning by" .. " " .. (Player2_Score - Player1_Score))
else
echo("It's a draw!")
end
add_hook("draw2d","draw",draw2dfunc1)
add_hook("enter_freeze","echowinner",winscorehit)
add_hook("draw2d","draw",draw2dfunc2)
add_hook("draw2d","draw",draw2dfunc3)
add_hook("enter_freeze","echowinner",winscore)
I am posting here for 2 reasons: 1: How do I fix the second script? 2: Would you suggest any rounding function that would get rid of the .365127344 after the score? Thanks, and yes the spacing is there.