Author Topic: Asteroid radius increase after it's creation  (Read 8706 times)

Orion63

  • Sapling
  • **
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 73
Asteroid radius increase after it's creation
« on: August 18, 2011, 03:15:41 AM »


Code: [Select]
function LevelSetup()

-- Global Values
Globals.G.Asteroids=(0)
SetBackdropColor(18, 0, 0)

roid = AddAsteroid(0, 0)
roid.Owner = 0
roid:SetRadius(50)
roid.Moveable = false

print(roid.Radius)
end


function LevelLogic()

print(roid.Radius)
coroutine.yield()
end
Code above should create a 50radius asteroid, but after LevelSetup it's radius increases to ~245.

Any reason and/or fix for the radius increase after level setup?

Aino

  • Ent
  • ******
  • Thank You
  • -Given: 4
  • -Receive: 30
  • Posts: 1,527
  • Eufloria: Yes
Re: Asteroid radius increase after it's creation
« Reply #1 on: August 18, 2011, 04:26:31 AM »
Use .Radius = 50

Or atleast I do and never got any problems... And keep in mind that 50 is a very small number, so the game might change it for visability sake :)

Orion63

  • Sapling
  • **
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 73
Re: Asteroid radius increase after it's creation
« Reply #2 on: August 18, 2011, 04:42:52 AM »
Nope, still doesn't work.

The thing is, that the zoom level is pretty small, and you at radius 50, it can be seen clearly

Funny thing is that if owner = 1, radius stays 50.

Thanks, anyway ;)

annikk.exe

  • Achiever
  • Ent
  • ****
  • Thank You
  • -Given: 0
  • -Receive: 4
  • Posts: 1,809
Re: Asteroid radius increase after it's creation
« Reply #3 on: August 18, 2011, 03:59:55 PM »
Problem:

Code: [Select]
function LevelLogic()

print(roid.Radius)
coroutine.yield()
end


You have a coroutine.yield(), but no While loop!

Pilchard123

  • Tester
  • Old Oak
  • ****
  • Thank You
  • -Given: 4
  • -Receive: 24
  • Posts: 932
  • Eufloria: Yes
Re: Asteroid radius increase after it's creation
« Reply #4 on: August 18, 2011, 06:42:58 PM »
It doesn't necessarily have to be in a loop. coroutine.yield() just passes back control to other coroutines, ready to be picked up again. In the case above, it is completely unnecessary, since there is nothing that takes up a lot of time, but in other cases, it could be advisable.

Again, I refer you to http://www.lua.org/pil/9.html

Orion63

  • Sapling
  • **
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 73
Re: Asteroid radius increase after it's creation
« Reply #5 on: August 18, 2011, 10:50:13 PM »
Problem:

Code: [Select]
function LevelLogic()

print(roid.Radius)
coroutine.yield()
end


You have a coroutine.yield(), but no While loop!

That was actually just a test. Even if I loop it, the outcome it's the same.
And regarding the tip that you gave me on the other topic(Of changing the radius on the LevelLogic function), I did that, but obviously the trees already planted there, stayed where they were initially(making them grow outside of the planet).

Thanks anyway ^^

Aino

  • Ent
  • ******
  • Thank You
  • -Given: 4
  • -Receive: 30
  • Posts: 1,527
  • Eufloria: Yes
Re: Asteroid radius increase after it's creation
« Reply #6 on: August 18, 2011, 11:58:39 PM »
How much does it change BTW?

Orion63

  • Sapling
  • **
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 73
Re: Asteroid radius increase after it's creation
« Reply #7 on: August 19, 2011, 12:13:55 AM »
...

Code above should create a 50radius asteroid, but after LevelSetup it's radius increases to ~245.

...

Aino

  • Ent
  • ******
  • Thank You
  • -Given: 4
  • -Receive: 30
  • Posts: 1,527
  • Eufloria: Yes
Re: Asteroid radius increase after it's creation
« Reply #8 on: August 19, 2011, 12:20:09 AM »
Ohh, didn't read it ;)

Pilchard123

  • Tester
  • Old Oak
  • ****
  • Thank You
  • -Given: 4
  • -Receive: 24
  • Posts: 932
  • Eufloria: Yes
Re: Asteroid radius increase after it's creation
« Reply #9 on: August 19, 2011, 12:39:27 AM »
You could add the trees in LevelLogic() too, just don't use the PlantTree() or whatever it's called.

Orion63

  • Sapling
  • **
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 73
Re: Asteroid radius increase after it's creation
« Reply #10 on: August 19, 2011, 12:51:22 AM »
You could add the trees in LevelLogic() too, just don't use the PlantTree() or whatever it's called.

As the only asteroid not empty, the game plants trees automatically. My luck, huh :P

annikk.exe

  • Achiever
  • Ent
  • ****
  • Thank You
  • -Given: 0
  • -Receive: 4
  • Posts: 1,809
Re: Asteroid radius increase after it's creation
« Reply #11 on: August 19, 2011, 03:49:17 PM »
Try adding player trees/seedlings in LevelSetup too.  Then it won't have to auto-add them, which might stop it from screwing everything up.  :>

Pilchard123

  • Tester
  • Old Oak
  • ****
  • Thank You
  • -Given: 4
  • -Receive: 24
  • Posts: 932
  • Eufloria: Yes
Re: Asteroid radius increase after it's creation
« Reply #12 on: August 19, 2011, 06:35:09 PM »
If it's NOT empty, why does it add trees to it?