(Whoa I'm posting in AaP)
This code works fine in that the logic is correct – just the things aren't in the right place.
We know from sinusoidal functions that any function, f(x) = a sin(p * t) + s, where a is the amplitude, t is any given angle and s is a translation factor from the x-axis. P also represents the period in which the sine-graph completes a cycle. To demonstrate this works without any additional a, p or s values:
local sx, sy = term.getSize()
for i = 1, sx do
local h = math.sin(i) + math.floor(sy/2)
term.setCursorPos(i, h)
term.write("#")
end
local doNothing = {os.pullEvent()}
… and running this, you'll see a sine wave in the middle of the screen. Changing the multiplication factor in front of math.sin(i) is going to affect the amplitude of the graph, but as your amplitude grows, you will lose points along the way. To fix this, you also need to change the period of the function (the p factor) to use a value such as 1 / 4 (which is really i / 4)!
Also, remember (iirc) Lua uses Radians for angular measurements – so be careful not to be caught up on that trick. Good luck!