Roblox Lua——“意外”指数

问题描述 投票:0回答:0

(已解决,但我很想知道为什么会发生这种情况。)

所以,我有这个脚本可以制作一大块“砖块”部件。这个想法是为了以某种方式打破它们(首先想到的是射箭场......)

Bricks 最初是 2x2x2,现在由于零件的性能而变成 4x4x4。主要是因为在这种规模下,这是一个相当愚蠢的想法。 然而,当我改变它时,它也在 Y 轴上以指数方式破坏了脚本

-- Origin == {POS = 0,0,0; SIZE = 4,4,4}
-- Finality == {POS == -477, 2, 243; SIZE = 4,4,4}

local location   =   {X = script.Origin.Position.X, 
                  Y = script.Origin.Position.Y, 
                  Ymoved = script.Origin.Position.Y,
                  Z = script.Origin.Position.Z}
--[[Previously Ymoved started at Origin.Position and went up how many tiles we went per floor.]]


local MATZ          = {"Marble","Ice"}
local Colours       = {Color3.new(0.25, 0.25, 0.25),Color3.new(0.811765, 0.992157, 1)}
local locationEnd   = script.Finality.Position
local count             = 0

local Vector = Vector3.new

while true do
    local brick = Instance.new("Part", game.Workspace)

        --Main Part creation
    brick.Name          = "Brick_"..count
    brick.Position      = Vector(location.X, location.Y, location.Z)
    brick.Size          = Vector(4,4,4)
    brick.Anchored      = true

        --Prettify (needs more options)
    local SEED          = math.random(1,2)
    brick.Material      = MATZ[SEED]
    brick.Color         = Colours[SEED]
    
    if location == locationEnd then 
                --unsafe, needs to be changed once i actually have an endpoint...
        break
    
    elseif location.X >= locationEnd.X then
        location.X = script.Origin.Position.X
        location.Z = location.Z - 4
        print("Next column")

    elseif location.Z <= locationEnd.Z then
        location.X = script.Origin.Position.X
        location.Z = script.Origin.Position.Z

                location.Ymoved = location.Ymoved + 2
        location.Y = script.Origin.Position.Y + location.Ymoved    --This line is antibepis
        print("Next floor")
    end
    
    if count % 250 == 0 then
        wait()
    end
    

    location.X = location.X + 4
    count = count + 1
end

不可避免地,在注意到问题出在 Y 轴上之后,我认为我应该研究脚本如何更改 Y 值。

因此:

location.Ymoved = location.Ymoved + 2
location.Y = script.Origin.Position.Y + location.Ymoved

这部分代码是所有坏掉的。

如上写,它将以指数方式产生更靠近的部分

location.Ymoved = location.Ymoved + 2
location.Y = location.Y + location.Ymoved

然而,当改变这个时,每一层都以指数方式放置得更远......
最终我记得亲吻*它,结果如下。 (*保持简单,愚蠢)

location.Y = location.Y + 4

这在技术上是防止奇怪指数的实际解决方案 然而,为什么指数会发生?当块大小为 2x2x2 时不会出现这些条纹...有什么区别? (因为我的大脑太炸了,无法修复它,哈哈)

roblox exponential roblox-studio
© www.soinside.com 2019 - 2024. All rights reserved.