# Thread: Editing post question - Lua to Javascript

1. ## Editing post question - Lua to Javascript

I am working on something that I hope I can apply to HSMworks... Currently we have a robot that is plasma cutting from code we have set up in SheetCAM....it is written in Lua... I would have so much more control over the toolpaths if I used HSMworks instead of SheetCAM....I can just use a 2D contour cut, and translate the spindle on/off to be read as firing the robot I/O for the plasma cutter.... I was hoping to be able to translate the Lua code to Javascript for this particular formula - but haven't a clue how to do it....

Below is the Lua code for certain arc points (rather than using I,J) that I need to translate into Javascript for HSMworks to use...if anyone has experience in translating between the two, any help would be appreciated...

function OnArc()
if(math.abs(endZ - currentZ) >.001 ) then
post.ArcAsMoves(.05)
return
end

halfpi = math.pi/2

difx = currentX - arcCentreX
dify = currentY - arcCentreY

startangle = math.atan2(difx,dify)
endangle = startangle + arcAngle
if(arcAngle > 0) then
quad = (math.toint((startangle / halfpi) + 10) - 10) * halfpi
repeat
doarc(endangle)
else
end
else
quad = -(math.toint((-startangle / halfpi) + 10) - 10) * halfpi
repeat
doarc(endangle)
else
end
end
end

function doarc(angle)
if(arcAngle <0) then
post.Text (" G03")
else
post.Text (" G02")
end
post.NonModalNumber (" X", ((math.sin(angle) * radius) + arcCentreX) * scale, "0.0000")
post.NonModalNumber (" Y", ((math.cos(angle) * radius) + arcCentreY) * scale, "0.0000")
post.NonModalNumber (" CX",(arcCentreX) * scale, "0.0000")
post.NonModalNumber (" CY",(arcCentreY) * scale, "0.0000")
post.NonModalNumber (" F", feedRate * scale, "0.0###")
post.Eol()
end

2. Got it taken care of....very simple modification to the post...

maximumCircularSweep = toRad(180) - changed (180) to (45) and it breaks out points along the arc up to 8 places....nice!!