Author Topic: GetNumOwnedAsteroids() + GetEmpire()  (Read 4434 times)

Pilchard123

  • Tester
  • Old Oak
  • ****
  • Thank You
  • -Given: 4
  • -Receive: 24
  • Posts: 932
  • Eufloria: Yes
GetNumOwnedAsteroids() + GetEmpire()
« on: June 11, 2010, 11:40:40 PM »
How do I check if a certain empire owns all the asteroids, or none of them? Presumably its something the do with the two functions in the title, but how do I use them?

If it helps, I want to check if the player (empire 1?) has all or none of the asteroids.

AWS

  • Achiever
  • Arboreal Being
  • ****
  • Thank You
  • -Given: 0
  • -Receive: 2
  • Posts: 275
Re: GetNumOwnedAsteroids() + GetEmpire()
« Reply #1 on: June 11, 2010, 11:51:15 PM »
annikk's your guy for this one. but id imagine you use the get empire (1) then get num owned asteroids, equal to 0, then do such and such a command ...
just my thought on it

aws

annikk.exe

  • Achiever
  • Ent
  • ****
  • Thank You
  • -Given: 0
  • -Receive: 4
  • Posts: 1,809
Re: GetNumOwnedAsteroids() + GetEmpire()
« Reply #2 on: June 12, 2010, 12:34:44 AM »
The way I do it is, in LevelSetup(), I count (literally or procedurally, depending on how I'm doing the level) how many asteroids there are in the level, then I make a variable called roidnumber equal to that number.

So if I had 10 asteroids in the level, I would do:


Code: [Select]
roidnumber = 10

Then, during Levelogic(), I can query how many asteroids a particular empire owns, and check if it is the same as roidnumber, or if it is 0.

If it's equal to roidnumber, then that empire owns all of the asteroids in the level.
If it's equal to zero, well... then that empire doesn't own any asteroids.


Code: [Select]
While GameRunning() do

  if GetEmpire(1):GetNumOwnedAsteroids() == 0 then
    -- ooh look, no asteroids.  player 1 suck and fail!

  elseif GetEmpire(1):GetNumOwnedAsteroids() == roidnumber then
    -- EPIC WIN, i has all asteroids!

  end

  coroutine.yield()
end



roidnumber is used for loads and loads of stuff in my scripts.  I find it a useful variable to have around.

Pilchard123

  • Tester
  • Old Oak
  • ****
  • Thank You
  • -Given: 4
  • -Receive: 24
  • Posts: 932
  • Eufloria: Yes
Re: GetNumOwnedAsteroids() + GetEmpire()
« Reply #3 on: June 12, 2010, 08:37:40 PM »
Typed on DSi

I'm using you beginner's guide to do what I'm doing, and in particular your win/lose check. Would the gamewon variable be changed in the comments you added to the code you just gave, or elsewhere, and if elsewhere, then where?

Thanks for the help so far.

annikk.exe

  • Achiever
  • Ent
  • ****
  • Thank You
  • -Given: 0
  • -Receive: 4
  • Posts: 1,809
Re: GetNumOwnedAsteroids() + GetEmpire()
« Reply #4 on: June 13, 2010, 08:27:37 AM »
Well now that I've read through your level a bit more (in the other thread), and I can see how you've structured things... basically the best way to do it is to make the While loop repeat as long as gamewon = 0.  Then, if either EPIC WIN or PLAYER 1 SUCK & FAIL (the If statements) are triggered, you can add gamewon = 1  or gamewon = 2

Then gamewon doesn't equal 0 anymore.  So the while loop will end, and then you can have some more If statements below that to evaluate whether the game was won or lost, based on whether the gamewon variable is 1 or 2.

This is the reasoning behind the changes I suggested in the other thread.


Great job on this by the way :>  It's not terribly easy to get started, I promise you though it gets easy very quickly :>  And then comes the power....muahahahaha...

AWS

  • Achiever
  • Arboreal Being
  • ****
  • Thank You
  • -Given: 0
  • -Receive: 2
  • Posts: 275
Re: GetNumOwnedAsteroids() + GetEmpire()
« Reply #5 on: June 15, 2010, 04:38:37 AM »
and fun too!
notsure about the power bit yet...perhaps that will hit me in time!

 ;D