### Author Topic: [Scripts] Random coord generator  (Read 779 times)

0 Members and 1 Guest are viewing this topic.

#### Redsparx

• Jr. Member
• Posts: 47
• If it doesnt drop anything, it not worth killing.
• Xbox: Redsparx
##### [Scripts] Random coord generator
« on: December 03, 2016, 04:01:27 PM »
Redsparx at it again.

So I am trying to develop a random coordinate generator for my disaster survival world, but I cant figure out how to make the script execute at a random position in the world.
Anyone know how to make that happen?

#### AlienizdPixel

• Tester
• Supreme Member
• Posts: 2720
• Hello
• Awards
• Xbox: A1ienizdPixe1
##### Re: Random coord generator
« Reply #1 on: December 03, 2016, 04:14:55 PM »
Var [x] = [rand:1023]
Var [y] = [rand:511]
Var [z] = [rand:1023]

Type "x", "y", or "z" where you are attempting to enter coordinates
Example:

SetBlock [x,y,z]
-Alionz

#### Redsparx

• Jr. Member
• Posts: 47
• If it doesnt drop anything, it not worth killing.
• Xbox: Redsparx
##### Re: Random coord generator
« Reply #2 on: December 03, 2016, 04:22:03 PM »
so am i just entering vars that  pick a number up to that number?

#### AlienizdPixel

• Tester
• Supreme Member
• Posts: 2720
• Hello
• Awards
• Xbox: A1ienizdPixe1
##### Re: Random coord generator
« Reply #3 on: December 03, 2016, 05:21:50 PM »
Yes. You can have more specific numbers by using addition
Example: If you want all of these disasters to only occur above the surface, then use

Var [y] = [rand:311] + [200]
-Alionz

#### Lunar

• Elite Member
• Posts: 954
• The God of the Galaxy
• Awards
• Xbox: Qvzw
• PSN: Widumn_Boise
##### Re: Random coord generator
« Reply #4 on: December 03, 2016, 05:22:30 PM »
Yep, but if im correct, 0,y,z or x,y,0 are not real coordinates, and the var rand: has a chance at being 0, so add something like this

Code: [Select]
`IfIsVar [x] [=] [0]ThenLoopElseIfIsVar [z] [=] [0]ThenLoopElse//Do your script hereEndIf`
This basically checks if one of the x or z coords is 0, if so, it retries

#### Craig

• Developer
• Extreme Member
• Posts: 6650
• Dig Deep
• Awards
• Steam: tota1miner
##### Re: Random coord generator
« Reply #5 on: December 03, 2016, 05:38:18 PM »
Yep, but if im correct, 0,y,z or x,y,0 are not real coordinates, and the var rand: has a chance at being 0, so add something like this

Code: [Select]
`IfIsVar [x] [=] [0]ThenLoopElseIfIsVar [z] [=] [0]ThenLoopElse//Do your script hereEndIf`
This basically checks if one of the x or z coords is 0, if so, it retries

No, if you don't want zero's then just add 1.

var [x] = [1] + [rand:1022]
var [y] = [1] + [rand:510]
var [z] = [1] + [rand:1022]

i.e. var [x] = [a] + [rand:b] is the same as pick a number between a and a + b

#### Redsparx

• Jr. Member
• Posts: 47
• If it doesnt drop anything, it not worth killing.
• Xbox: Redsparx
##### Re: Random coord generator
« Reply #6 on: December 10, 2016, 01:14:53 PM »

No, if you don't want zero's then just add 1.

var [x] = [1] + [rand:1022]
var [y] = [1] + [rand:510]
var [z] = [1] + [rand:1022]

i.e. var [x] = [a] + [rand:b] is the same as pick a number between a and a + b

So, what if i want to have a random script generator to work on both types of maps (D.D. and the others), without making anentirely new script?

#### AlienizdPixel

• Tester
• Supreme Member
• Posts: 2720
• Hello
• Awards
• Xbox: A1ienizdPixe1
##### Re: Random coord generator
« Reply #7 on: December 10, 2016, 03:02:36 PM »
So, what if i want to have a random script generator to work on both types of maps (D.D. and the others), without making anentirely new script?
For the Dig-Deep gamemode, you will have to change the numbers to fit the different map size.
var [x] = [rand:511]
var [y] = [rand:3071]
var [z] = [rand:511]
-Alionz