|
| 14 Jul 2016 12:35 PM |
I need help with a block generation script that generates blocks when you destroy a block like in azure mines, epic mining 2, or the quarry.
|
|
|
| Report Abuse |
|
|
| |
|
Ryuzoji
|
  |
| Joined: 21 Dec 2015 |
| Total Posts: 937 |
|
| |
|
|
| 14 Jul 2016 05:21 PM |
| Do some research don't just ask for something to be handed to you. |
|
|
| Report Abuse |
|
|
|
| 14 Jul 2016 05:24 PM |
Search in wiki for while or for loops, then search up how to use vector3 positioning, or preferably cframes. |
|
|
| Report Abuse |
|
|
|
| 14 Jul 2016 05:39 PM |
Mouse.TargetSurface Mouse.Target CFraming A bit of math
#code print("while false do end") |
|
|
| Report Abuse |
|
|
|
| 14 Jul 2016 05:40 PM |
I've been searching this was my last option
|
|
|
| Report Abuse |
|
|
|
| 14 Jul 2016 05:41 PM |
Thx RemasteredBox but I am looking for it to generate blocks when I break a block in my game
|
|
|
| Report Abuse |
|
|
|
| 14 Jul 2016 06:21 PM |
I made that type of game once. It involves a huge array table to hold block data
MineData = {}
function GetBlockXYZ(pos) if pos.Y < 10007 then return MineData["X" .. pos.X .. "Y" .. pos.Y .. "Z" .. pos.Z] else return 0 end end
function SetBlockXYZ(pos,val) MineData["X" .. pos.X .. "Y" .. pos.Y .. "Z" .. pos.Z] = val end
once you destroy the block I did this
if GetBlockXYZ(block.Position + Vector3.new(0,-7,0)) == nil then PickBlockType(block.Position + Vector3.new(0,-7,0)) SetBlockXYZ(block.Position + Vector3.new(0,-7,0),1) end if GetBlockXYZ(block.Position + Vector3.new(0,7,0)) == nil then PickBlockType(block.Position + Vector3.new(0,7,0)) SetBlockXYZ( block.Position + Vector3.new(0,7,0),1) end if GetBlockXYZ(block.Position + Vector3.new(-7,0,0)) == nil then PickBlockType(block.Position + Vector3.new(-7,0,0)) SetBlockXYZ(block.Position + Vector3.new(-7,0,0),1) end if GetBlockXYZ(block.Position + Vector3.new(7,0,0)) == nil then PickBlockType(block.Position + Vector3.new(7,0,0)) SetBlockXYZ(block.Position + Vector3.new(7,0,0),1) end the PickBlockType is a function that chooses what should spawn there using math.random and it also places a block at that position. the 7 is the size of the block grid I used
I am actually amazed on how much work I did on this game as I thought I abandoned it early into development.
|
|
|
| Report Abuse |
|
|
|
| 14 Jul 2016 06:27 PM |
Omg thanks a ton. i'll make sure to try it later!
|
|
|
| Report Abuse |
|
|
|
| 14 Jul 2016 08:53 PM |
Alright I can't find my problem I know it's wrong pls don't laugh I am new to scripting, I think everything is right except for the PickBlockType. Here's what I have:
local block = game.workspace.Ores.Stone MineData = {}
function GetBlockXYZ(pos) if pos.Y < 10007 then return MineData["X" .. pos.X .. "Y" .. pos.Y .. "Z" .. pos.Z] else return 0 end end
function SetBlockXYZ(pos,val) MineData["X" .. pos.X .. "Y" .. pos.Y .. "Z" .. pos.Z] = val end
function PickBlockType(Stone) for _ = 1, 10 do if (math.random(100))> 20 then PickBlockType = Stone end wait(1) end end
function onClicked(PlayerWhoClicked) block:Destroy() if GetBlockXYZ(block.Position + Vector3.new(0,-7,0)) == nil then PickBlockType(block.Position + Vector3.new(0,-7,0)) SetBlockXYZ(block.Position + Vector3.new(0,-7,0),1) end if GetBlockXYZ(block.Position + Vector3.new(0,7,0)) == nil then PickBlockType(block.Position + Vector3.new(0,7,0)) SetBlockXYZ( block.Position + Vector3.new(0,7,0),1) end if GetBlockXYZ(block.Position + Vector3.new(-7,0,0)) == nil then PickBlockType(block.Position + Vector3.new(-7,0,0)) SetBlockXYZ(block.Position + Vector3.new(-7,0,0),1) end if GetBlockXYZ(block.Position + Vector3.new(7,0,0)) == nil then PickBlockType(block.Position + Vector3.new(7,0,0)) SetBlockXYZ(block.Position + Vector3.new(7,0,0),1) end end
game.workspace.Ores.Stone.ClickDetector.MouseClick:connect(onClicked)
|
|
|
| Report Abuse |
|
|