So, blocks should exist only on one corner, and not another?
If yes, then:
local X = (OreCF.X-Origin.X)/6
local Z = (OreCF.Z-Origin.Z)/6
if (X >= 8 and X < 0) or (Z >= 8 and Z < 0) then return end
So, blocks should exist only on one corner, and not another?
If yes, then:
local X = (OreCF.X-Origin.X)/6
local Z = (OreCF.Z-Origin.Z)/6
if (X >= 8 and X < 0) or (Z >= 8 and Z < 0) then return end
oof, sorry. I made small mistake with <> symbols
if (X <= 8 and X > 0) or (Z <= 8 and Z > 0) then return end
This is what happened:
hm, IDK why this occured. Did you kept this?
local X = (OreCF.X-Origin.X)/6
local Z = (OreCF.Z-Origin.Z)/6
Yes i need to keep that or it will error
IS your ORIGIN at 0, 0 now? Because the only reason it can behave like this is incorrect origin or incorrect subtraction. Maybe, try switch spots for OreCF and Origin (Origin - OreCF)
The origin is at 0,0,0 and i only have it so that i can tell the right amount of blocks
Then IDK what causes this issue, try manipulate with some variables by random? Sorry.
I saw other mining games have barriers too so there must be something to solve this issue
Yes, thereās should be answer. But itās hard to do smth if you donāt know everything.
At what I see rn, you have code which:
a = (5, 3), b = (1, 1), c = (10, 4), d = (-4, 0)
, assuming that they are divided by 6 already.ra = (5 - 0, 3 - 0) = (5, 3) and etc.
a.X <= 8 -> yes
. . . a.X > 0 -> yes
. . . a.Z <= 8 -> yes
. . . a.Z > 0 -> yes
ā allow spawnb.X <= 8 -> yes
. . . b.X > 0 -> yes
. . . b.Z <= 8 -> yes
. . . b.Z > 0 -> yes
ā allow spawnc.X <= 8 -> NOU
. . . c.X > 0 -> yes
. . . c.Z <= c -> yes
. . . c.Z > 0 -> yes
ā disallow spawnd.X <= 8 -> yes
. . . d.X > 0 -> NOU
. . . d.Z <= 8 -> yes
. . . d.Z > 0 -> NOU
ā disallow spawna
and b
block placed, while c
and d
wonāt.Thatās how I see it working.
I also would see it working like that but how do i turn it into a if statement
UNDERSTOOD (I think)
if (X <= 8 and X > 0) and (Z <= 8 and Z > 0) then
--CODE TO SPAWN BLOCK!!!
end
(I did code to spawn block, but not to prevent it from spawning .-.)
So if you want use return end, then use
if not ((X <= 8 and X > 0) and (Z <= 8 and Z > 0)) then return end=
That doesnt spawn any blocks at all
Try that codes again, I changed <> symbols again =|
Doesnāt work sorry i think ill rewrite my system or something
Maybe, Iāll be able to fix it. But I need see entire code and run/debug it. Can you give me file with place? (If you want)
Are there negative coordinates involved here? (e.g. Z = -10, X = number) That could be the problem, because math.abs CANNOT return a negative number (it returns the absolute, non-negative value). It would instead return the positive equivalent (ex: math.abs(-6) = 6). For example, if OreCF.X is -10 and Origin.X is 10, then math.abs((OreCF.X-Origin.X)/6) will return 3.33, which is less than 24, even though the distance is actually 20. Instead, try using
-- Change this variable, this is the distance limit.
local max = 24
local X = (OreCF.X-Origin.X) -- Difference between X
local Z = (OreCF.Z - Origin.Z) -- Difference between Z coords
local distance = math.sqrt(X^2 + Z^2) -- Square root of XĀ² + ZĀ²
if distance >= max then return end -- If the distance is greater than the max variable, skip the block placing.
I obviously havenāt tested this, but it could work. This would create a circular barrier as it uses Euclidean distance, but I think itās better than nothing. Also, the max variable I provided would probably too large, make sure to change it.
That still doesnt work for me because in one corner i can mine 24 blocks sideways and in the other i can mine only 1.
Could you give me a screenshot of that?