Sorry, we don't support your browser.  Install a modern browser

Pen Events#2188

While there is already a suggestion for events regarding drawing, they are a little over the top for what I am looking for. If we could have two event functions that return the index of the line that triggered the event, that would allow for the ability to use scripted drawing without worrying about losing track of it as players draw or erase stuff themselves.

By keeping track of the indexes of scripted drawings, one only needs to subtract 1 any time OnPenErased(index) gave an index less then the index of the scripted drawing, or in the event that the scripted drawing was erased, re-apply it.

Something like:

ourDrawing = drawScriptedImage() --returns index at time of drawing image.

function onPenErased(i)
  if i < ourDrawing then ourDrawing = ourDrawing-1 end
  if i == ourDrawing then ourDrawing = drawScriptedImage() end
end

Its partner function would be onPenFinished(i) which returns the index of the finished drawing. This could be used in conjunction with scripted drawings to make things like the mario party drawing game.

Example:

function onPenFinished(i)
  lines = Global.getVectorLines()
  score = 0
  for k=1, #lines[ourDrawing].points do
    score = score+lines[i].points[k]:distance(lines[ourDrawing].points[k])
  end
  print("Lower scores are better: "..score)
end

With just those two new functions we are already able to make a new minigame and score it without worrying about players erasing or drawing outside of the game.

5 months ago
2