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

0 Members and 1 Guest are viewing this topic.

Redsparx

  • Jr. Member
  • **
  • Posts: 47
  • If it doesnt drop anything, it not worth killing.
    • View Profile
    • Awards
  • 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: 2576
  • Hallo
  • Awards 3 years on site+600 posts Members who have unlocked the robotic avatar Awarded to exemplary forum members 2 years on site+300 posts Was in the top 10 of the forum stats page as of 4/12/15 1 year on site+100 posts
    • View Profile
    • Awards
  • Xbox: A1ienizdPixe1
  • Steam: Alienizd
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.
    • View Profile
    • Awards
  • 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: 2576
  • Hallo
  • Awards 3 years on site+600 posts Members who have unlocked the robotic avatar Awarded to exemplary forum members 2 years on site+300 posts Was in the top 10 of the forum stats page as of 4/12/15 1 year on site+100 posts
    • View Profile
    • Awards
  • Xbox: A1ienizdPixe1
  • Steam: Alienizd
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: 878
  • The God of the Galaxy
  • Awards 1 year on site+100 posts
    • View Profile
    • 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]
If
IsVar [x] [=] [0]
Then
Loop
ElseIf
IsVar [z] [=] [0]
Then
Loop
Else
//Do your script here
EndIf

This basically checks if one of the x or z coords is 0, if so, it retries

Craig

  • Developer
  • Extreme Member
  • ******
  • Posts: 6497
  • Dig Deep
  • Awards Developer 4 years on site+1000 posts 3 years on site+600 posts 2 years on site+300 posts Was in the top 10 of the forum stats page as of 4/12/15 Members who have unlocked the robotic avatar 1 year on site+100 posts Day 1 w/25+ posts (4/12/13)
    • View Profile
    • Twitter
    • Awards
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]
If
IsVar [x] [=] [0]
Then
Loop
ElseIf
IsVar [z] [=] [0]
Then
Loop
Else
//Do your script here
EndIf

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.
    • View Profile
    • Awards
  • 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: 2576
  • Hallo
  • Awards 3 years on site+600 posts Members who have unlocked the robotic avatar Awarded to exemplary forum members 2 years on site+300 posts Was in the top 10 of the forum stats page as of 4/12/15 1 year on site+100 posts
    • View Profile
    • Awards
  • Xbox: A1ienizdPixe1
  • Steam: Alienizd
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