変数名に予約語を使うのはやめて
- User
変数名に予約語を使うのはやめて
Assistant
以下は、予約語を避けたMAXScriptです:
maxscript
Other models, same or similar prompt
Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.
変数名に予約語を使うのはやめて
以下は、予約語を避けたMAXScriptです:
Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.
-- グリッドパラメータ
gridCols = 6
gridRows = 5
gridStartPos = [0,0,0]
gridEndPos = [500,400,0]
-- 初期グリッド作成
gridSpacingX = (gridEndPos.x - gridStartPos.x)/(gridCols-1)
gridSpacingY = (gridEndPos.y - gridStartPos.y)/(gridRows-1)
gridHelpers = #()
for i = 1 to gridCols do (
for j = 1 to gridRows do (
x = gridStartPos.x + (i-1)*gridSpacingX
y = gridStartPos.y + (j-1)*gridSpacingY
helperObj = Point name:("Helper_"+i as string+"_"+j as string) size:5 pos:[x,y,0]
append gridHelpers helperObj
)
)
-- グリッド再計算関数
fn repositionGrid = (
helperPositions = for h in gridHelpers collect h.pos
minX = amin (for p in helperPositions collect p.x)
maxX = amax (for p in helperPositions collect p.x)
minY = amin (for p in helperPositions collect p.y)
maxY = amax (for p in helperPositions collect p.y)
newSpacingX = (maxX - minX)/(gridCols-1)
newSpacingY = (maxY - minY)/(gridRows-1)
for i = 1 to gridCols do (
for j = 1 to gridRows do (
idx = (j-1)*gridCols + i
helperObj = gridHelpers[idx]
helperObj.pos = [minX + (i-1)*newSpacingX,
minY + (j-1)*newSpacingY, 0]
)
)
)
-- when構文でのコールバック
when transform $ changes do (
if findItem gridHelpers $ != 0 then (
repositionGrid()
)
)
予約語を避けることで、スクリプトの安全性と保守性が向上します。