Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

AutowedgeCells isn't working for me?

Asked by 10 years ago

I've set up this simple plugin, and what it should do is smooth a radius of terrain around where the mouse is pointed at. It print 'Click', but doesn't smooth.

local plugin = PluginManager():CreatePlugin()
local toolbar = plugin:CreateToolbar("Hello World Plugin")
local terrain = Game.Workspace.Terrain

local smoothButton = toolbar:CreateButton(
    "Smooth", 
    "Use this to smooth an area of terrain", 
    "SmoothIcon.png" 
)

smoothButton.Click:connect(function()
    plugin:Activate(true)
    local mouse=plugin:GetMouse()
    mouse.Button1Down:connect(function()
        local mosPos = mouse.Hit
        local origin = terrain:WorldToCell(mosPos.p)
        local Radius = 4
        local region = Region3int16.new(Vector3int16.new(Vector3.new(-Radius,-Radius,-Radius) + mosPos.p), Vector3int16.new(Vector3.new(Radius,Radius,Radius) + mosPos.p))
        terrain:AutowedgeCells(region)
        print('Click')
    end)
end)

2 answers

Log in to vote
1
Answered by
Maxomega3 106
10 years ago
local plugin = PluginManager():CreatePlugin()
local toolbar = plugin:CreateToolbar("Hello World Plugin")
local terrain = Game.Workspace.Terrain

local smoothButton = toolbar:CreateButton(
    "Smooth", 
    "Use this to smooth an area of terrain", 
    "SmoothIcon.png" 
)

smoothButton.Click:connect(function()
    plugin:Activate(true)
    local mouse=plugin:GetMouse()
    mouse.Button1Down:connect(function()
        local mosPos = mouse.Hit
        local origin = terrain:WorldToCell(mosPos.p)
        local Radius = 4
        local region = Region3int16.new(Vector3int16.new(Vector3.new(-Radius,-Radius,-Radius) + mosPos.p), Vector3int16.new(Vector3.new(Radius,Radius,Radius) + mosPos.p))
        terrain:AutowedgeCells(terrain) -- He changed this line, which is calling a nil value. That won't work at all.
        print('Smooth')
    end)
end)

I'm not an expert in terrain, although I hope to get better. Why do you declare origin, but never index it?

0
Oh yeah, that explains it all actually. I meant to put origin instead of mosPos.p in the Region3Int16. Thanks! ColdSmoke 55 — 10y
0
Well it's still broken but I think I know where to go from here. Thanks a ton. ColdSmoke 55 — 10y
Ad
Log in to vote
-1
Answered by 10 years ago

Try this

local plugin = PluginManager():CreatePlugin()
local toolbar = plugin:CreateToolbar("Hello World Plugin")
local terrain = Game.Workspace.Terrain

local smoothButton = toolbar:CreateButton(
    "Smooth", 
    "Use this to smooth an area of terrain", 
    "SmoothIcon.png" 
)

smoothButton.Click:connect(function()
    plugin:Activate(true)
    local mouse=plugin:GetMouse()
    mouse.Button1Down:connect(function()
        local mosPos = mouse.Hit
        local origin = terrain:WorldToCell(mosPos.p)
        local Radius = 4
        local region = Region3int16.new(Vector3int16.new(Vector3.new(-Radius,-Radius,-Radius) + mosPos.p), Vector3int16.new(Vector3.new(Radius,Radius,Radius) + mosPos.p))
        terrain:AutowedgeCells(terrain)
        print('Smooth')
    end)
end)


0
What exactly did you change? ColdSmoke 55 — 10y
0
did it work? danielsarabia11 -2 — 10y
0
It still does nothing, you gave me the exact same code I originally posted. ColdSmoke 55 — 10y
0
no i didnt try it agian and try using diffrent scripts like scripts and local scripts danielsarabia11 -2 — 10y
View all comments (2 more)
0
This is in a plugin, it doesn't have local scirpts or scripts, it's simply a Main.lua file. I see nothing different about the code you posted, and it doesn't work any better either. ColdSmoke 55 — 10y
0
ugh you must be blind this should be working like a script rather than a plug in danielsarabia11 -2 — 10y

Answer this question