Blackvoxel > Programming with Blackvoxel

Workaround for bugged GetX()

(1/1)

Qon:
The GetX() functions aren't updated instantly when the qomputer moves in BV 1.21. This is a quick and easy workaround.
Qall move(direction), getX(), getY(), getZ() everywhere in your qode where you would otherwise have used Move(direction), GetX(), GetY(), GetZ().
They work exactly the same except that they aren't bugged q:
I haven't tested what happens if you give faulty values to Move() so you shouldn't either xD
Add this to your qode:
Qall
--- Code: ---initP()
--- End code ---
as first line in Voxel_Step()!

--- Code: ---p <- null
function vaddir(a, dir){
return vadd(a, [(dir==1?1:0)-(dir==3?1:0), (dir==4?1:0)-(dir==5?1:0), (dir==0?1:0)-(dir==2?1:0)])
}
function vadd(a, b) {
return [a[0]+b[0], a[1]+b[1], a[2]+b[2]]
}
function initP() {
if(p==null)
p = [GetX(), GetY(), GetZ()]
}
function refreshP(dir) {
p = vaddir(p, dir)
}
function move(d){
if(Move(d)){
refreshP(d)
return true
}
return false
}
function getX(){
return p[0]
}
function getY(){
return p[1]
}
function getZ(){
return p[2]
}
--- End code ---
And don't put your qomputer on a qonveyor belt, then it will get out of sync :)

Navigation

[0] Message Index

Go to full version