Plug-in mouse tools (fry.tool{name, help, click(at, normal, object)}): listed in the Toolbox, a click in the view calls it (one undo); Stamp comes as an example; the Plug-ins window: look for one, make your own copy of one that comes with Fry3DX

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
Nexoniarz 2026-10-21 08:10:24 +02:00
commit b9b6932d0e
4 changed files with 155 additions and 4 deletions

View file

@ -0,0 +1,22 @@
-- Stamp: a mouse tool. Click on anything (or the ground) and a copy of the picked object is put
-- there, standing on the surface. Shows how a plug-in adds a tool to the Toolbox (fry.tool).
fry.plugin{name = "Stamp", about = "A tool: click to put copies of the picked object on what you click, standing on it."}
fry.tool{
name = "Stamp copies",
help = "Click to put a copy of the picked object there, standing on the surface (pick one first).",
click = function(at, normal, onto)
local picked = fry.selected()
local o = picked[#picked]
if not o or (onto and o.id == onto.id) then
-- nothing picked to copy (or clicking on it): a little ball, to show where
o = fry.add("sphere", {radius = 0.1})
o.position = at + normal * 0.1
return
end
local c = o:copy()
local lo, hi = o:bounds()
c.position = at + normal * ((hi.z - lo.z) / 2)
o:select()
end,
}