Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Script.maxBuildHeight = 100
- Script.minBuildHeight = 0
- Script.distancePerBlock = 0.5 --Example
- Script.minXRandom = -0.2 --Example
- Script.maxXRandom = 0.2 --Example
- Script.minYRandom = -0.2 --Example
- Script.maxYRandom = 0.2 --Example.
- Script.minZRandom = -0.1 --Example
- Script.maxZRandom = 0.1 --Example
- Script.totalBlocks = 50 --Example
- Script.FinishBlock=-1
- function Script:Start()
- --Create a light
- local light = DirectionalLight:Create()
- light:SetRotation(35,35,0)
- --creating table
- self.blocks = {}
- self.blockCount = 0 --Example (maybe this way it won't show up in the editor?)
- ----[[
- --Create a player
- self.camera = Camera:Create()
- self.camera:SetFOV(70)
- self.camera:SetRange(0.05,1000)
- self.camera:SetPosition(0,0,0)
- self.camera:SetScript("Scripts/Objects/Camera/SpectatorCam.lua")
- --]]
- --[[
- --spawning the player
- self.player = Pivot:Create()
- self.player:SetMass(10)
- self.healthbar = Pivot:Create()
- self.healthbar:SetParent(self.player)
- self.player:SetScript("Scripts/Objects/Player/LeadBlocksFps.lua")
- --self.healthbar:SetScript("Scripts/Objects/Player/PlayerHealthBar.lua")
- --self.player:SetShape(shape)
- self.player:SetPhysicsMode(Entity.CharacterPhysics)
- math.randomseed(tostring(self:MakeRndSeed()))
- for n = 0, 15 do
- num = math.random(9)
- --System:Print(num)
- end
- ----]]
- --create origin point box
- model = Model:Box()
- local color = Context:GetCurrent():GetColor()
- color.r = 0.6
- color.g = 0.6
- color.b = 1
- for i=0 , (self.totalBlocks-1) do
- local num = Vec3(math.random(self.minXRandom, self.maxXRandom),math.random(self.minYRandom,self.maxYRandom),math.random(self.minZRandom,self.maxZRandom)) --Careful! num was global here before, and wouldn't delete after the scope.
- --System:Print(num.z.." <<")
- --System:Print(math.random(9).." <<")
- self:MakeBox(num.x,num.y,num.z,color)
- end
- self.FinishBlock = self.blocks[self.totalBlocks]
- self.camera:SetPosition(self.blocks[1]:GetPosition(true))
- end
- function Script:MakeRndSeed()
- local seed = 1
- seed = Math:Random(1,9)
- seed = seed*10000000*Time:GetCurrent()+Math:Random(0,400)
- return Math:Round(seed)
- end
- function Script:MakeBox(x, y, z, color)
- local box = Model:Box()
- local shape = Shape:Box()
- box:SetShape(shape)
- --if y > 99.0 then
- -- color.r = 11
- --System:Print(">> >> "..y)
- --end
- local newZ = (self.blockCount * self.distancePerBlock) + z --Example ( + z for that little bit of extra randomness)
- box:SetPosition(x,y,newZ,true)
- box:SetColor(color)
- --[[
- if math.random(0,1) == 1 then
- box:SetScript("floatupanddown/floating.lua")
- box:SetColor(1,1,1)
- box:SetKeyValue("box","floating")
- end
- --]]
- --put the block in tabledasdasdasdasd
- self.blocks[self.blockCount+1] = box
- self.blockCount = self.blockCount + 1
- end
- function Script:UpdatePhysics()
- --end the level if player reched the end
- --if self.player:GetPosition(true).x >= self.FinishBlock:GetPosition(true).x then
- if Window:GetCurrent():KeyHit(Key.E) then
- changemapname = "start"
- end
- end
- --[[
- --This can be used to select which objects an entity collides with. This overrides collision types completely.
- function Script:Overlap(e)
- return Collision:Collide
- end
- ]]
- --[[
- function Script:Collision(entity, position, normal, speed)
- end
- ]]
- --[[
- function Script:Draw()
- end
- ]]
- --[[
- function Script:DrawEach(camera)
- end
- ]]
- --[[
- --This function will be called after the world is rendered, before the screen is refreshed.
- --Use this to perform any 2D drawing you want the entity to display.
- function Script:PostRender(context)
- end
- ]]
- --[[
- --This function will be called when the entity is deleted.
- function Script:Detach()
- end
- ]]
- --[[
- --This function will be called when the last instance of this script is deleted.
- function Script:Cleanup()
- end
- ]]
Advertisement
Add Comment
Please, Sign In to add comment