Author Topic: New scripters ask advanced peeps how to script something  (Read 1753 times)

0 Members and 1 Guest are viewing this topic.

BC wins

  • Seedling
  • **
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 39
Re: New scripters ask advanced peeps how to script something
« Reply #15 on: August 17, 2010, 09:43:10 AM »
thx terrial
i tried it but the game crashes when i take the asteroid :(
plus i really need it to be player specific as in (Challenger(1))

and i really am confused now is the owner in
function OnAsteroidTaken (id, owner)
the new owner or old owner ?
it would explain why my function are going wrong :D


annikk.exe

  • Achiever
  • Ent
  • ****
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 1,794
Re: New scripters ask advanced peeps how to script something
« Reply #16 on: August 17, 2010, 02:44:49 PM »
BC,

Can you clarify what you want to happen.  Using words like "owner" is no good unless you also specify whether they are the owner before or after the asteroid is taken.

Remember that OnAsteroidTaken is run immedietely after the asteroid is taken, therefore it will return the asteroid's owner as being the aggressor, not the empire that lost the asteroid.




Depending on how you want this to work, try one of these:



Code: [Select]
function OnAsteroidTaken(id,owner)

  if id == 7 then

    Pause()
    MessageBox("Asteroid 7 was taken by Empire" .. owner)
    WaitDialog()
    Unpause()

  end

end
This code will display a message box anytime asteroid 7 gets a new owner.




Code: [Select]
function LevelLogic()

  runonce = false
  specificowner = 3  --change as you like, doesn't have to be empire 3

  while GameRunning() do



    if runonce == false and GetAsteroid(7).Owner == specificowner then

      Pause()
      MessageBox("Asteroid 7 was taken by Empire" .. specificowner)
      WaitDialog()
      Unpause()

      runonce = true

    end


    if GetAsteroid(7).Owner ~= 3 then

      runonce = false

    end

  coroutine.yield()
  end

end
This code will display a message box anytime the empire mentioned in "specificowner" captures asteroid 7 - but it won't display a message if a different empire captures it.



Hope this halps.  :>

Pilchard123

  • Tester
  • Old Oak
  • ****
  • Thank You
  • -Given: 0
  • -Receive: 17
  • Posts: 899
  • Eufloria: Yes
Re: New scripters ask advanced peeps how to script something
« Reply #17 on: August 17, 2010, 03:11:09 PM »
BC's code: (direct copy-paste)
Code: [Select]
if id == 7 and aggressor == 1 then
   GetAsteroid(7)SendDistance = 5000  
      return
   end

I'd guess that s/he wants Asteroid 7 to have a SendDistance of 5000 when captured by by the player.

I'd suggest:
Code: [Select]
OnAsteroidTaken(id, aggressor)
   if id == 7 and aggressor == 1 then
      GetAsteroid(7):SendDistance = 5000  
   end
end

BC, you need a colon ( : ) between the GetAsteroid(7) and SendDistance. I forgot it in the last code I gave you, which might explain why it doesn't work.

EDIT: Stupid smileys.

annikk.exe

  • Achiever
  • Ent
  • ****
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 1,794
Re: New scripters ask advanced peeps how to script something
« Reply #18 on: August 17, 2010, 03:25:05 PM »
I might be wrong, but I think that probably won't work; "aggressor" isn't naturally contained in OnAsteroidTaken.  You would need to use "owner".

Pilchard123

  • Tester
  • Old Oak
  • ****
  • Thank You
  • -Given: 0
  • -Receive: 17
  • Posts: 899
  • Eufloria: Yes
Re: New scripters ask advanced peeps how to script something
« Reply #19 on: August 17, 2010, 03:38:47 PM »
I know, but that confused BC. Just wondered if aggressor would work if you treated it like owner.

BC, just replace aggressor with owner. Should work then.