Author Topic: Upgrade event  (Read 1497 times)

wecl0me12

  • Guest
Upgrade event
« on: 5 May 2011, 01:01:56 »
Is it possible to have an event that triggers whenever a specified upgrade is completed? (in scenarios)

ElimiNator

  • Airship
  • ********
  • Posts: 3,391
  • The MegaGlest Moder.
    • View Profile
Re: Upgrade event
« Reply #1 on: 5 May 2011, 02:10:16 »
I don't think so, just have it start a timer after it starts the upgrade, make the timer a bit longer than the upgrade time.
Get the Vbros': Packs 1, 2, 3, 4, and 5!

wecl0me12

  • Guest
Re: Upgrade event
« Reply #2 on: 5 May 2011, 02:15:32 »
How do I tell when an upgrade is started?
Tracking resources and checking for a change in the resources: I'm using now, but is glitchy.

Omega

  • MegaGlest Team
  • Dragon
  • ********
  • Posts: 6,167
  • Professional bug writer
    • View Profile
    • Personal site
Re: Upgrade event
« Reply #3 on: 5 May 2011, 06:27:13 »
just have it start a timer after it starts the upgrade, make the timer a bit longer than the upgrade time.
In GAE (not MegaGlest), commands return boolean values if they were successfully given (but not necessarily completed), such as with giveUpgradeCommand(unitId, upgrade). However, the major limitation of this is that it only works if the Lua script gives the upgrade command, not if the player does, which is not currently possible and there is no way to detect if the upgrade starts!

This could perhaps use some expansion in the future, but in the meanwhile, I would advise against trying to check for changes in the resources, as that would be limited and prone to error. Instead, try and find ways around this inability. For example, in most of my tutorials, where a unit requires an upgrade to be produced, I don't tell the player to perform the upgrade in one step then produce the unit in the next, but rather tell them to do both in one step (that is, perform the upgrade then produce the unit once it's complete). Since the unit requires the upgrade anyway, we can be assured that if the player makes said unit, they must have the upgrade. Of course, it all depends on why exactly you are trying to detect the upgrade. Can you elaborate more?
Edit the MegaGlest wiki: http://docs.megaglest.org/

My personal projects: http://github.com/KatrinaHoffert

wecl0me12

  • Guest
Re: Upgrade event
« Reply #4 on: 5 May 2011, 18:43:00 »
I am creating a faction (in the magitech techtree) , and a tutorial for it.
The tutorial requires the player to buy an upgrade that increases stats of some units, so they know how to use the upgrade.

Omega

  • MegaGlest Team
  • Dragon
  • ********
  • Posts: 6,167
  • Professional bug writer
    • View Profile
    • Personal site
Re: Upgrade event
« Reply #5 on: 5 May 2011, 19:01:23 »
The tutorial requires the player to buy an upgrade that increases stats of some units, so they know how to use the upgrade.
Yeah, no way to do that, I'm afraid. You can try and say how to use it in the game as part of another step, though no way to check if they actually did use it.
Edit the MegaGlest wiki: http://docs.megaglest.org/

My personal projects: http://github.com/KatrinaHoffert

 

anything