Page 1 of 1

Refuel pads.

Posted: 10 Apr 2010, 05:55
by SanadaUjiosan
So, I'm looking into how to make refuel pads for my planes. I'm guessing the tag i'm looking for is isAirBase. I looked at the lua wiki and the only bit I saw for repair pads was this:
QueryLandingPads ( ) -> { number piece1, number piece2, ... }
Called one time for units with landing pads. Should return a table with pieces which should be used as landing pads. The number of pieces returned also determines the number of pads, so for Lua unit scripts there is no QueryLandingPadCount.
Buuut that, of course, didn't work for me. So here I am.

UnitDef:

Code: Select all

unitDef = {

  unitname                      = [[brefuel]],
  name                          = [[Combat Air Base]],
  description                   = [[Produces warplanes and support aircraft.]],
  amphibious                    = false,
  activateWhenBuilt             = true,
  acceleration                  = 0,
  bmcode                        = [[0]],
  brakeRate                     = 0,
  buildCostEnergy               = 0,
  buildCostMetal                = 0,
  builder                       = false,
  buildoptions                  = {
    [[bfighter]],
    [[bbomber]],
    [[brocketplane]],
    [[bradarplane]],
  },
  buildPic                      = [[bairport.png]],
  buildTime                     = 1,
  canMove                       = false,
  canPatrol                     = true,
  canstop                       = [[1]],
  canBeAssisted                 = false,
  category                      = [[SINK]],
  isAirBase                     = true,
  collisionVolumeOffsets        = [[0 8 0]],
  collisionVolumeScales         = [[172 112 188]],
  collisionVolumeTest           = 1,
  collisionVolumeType           = [[box]],
  corpse                        = [[DEAD]],
  energyMake                    = 0.15,
  energyUse                     = 0,
  explodeAs                     = [[LARGE_BUILDINGEX]],
  footprintX                    = 11,
  footprintZ                    = 12,
  idleAutoHeal                  = 0,
  mass                          = 275,
  maxDamage                     = 8500,
  maxSlope                      = 15,
  maxVelocity                   = 0,
  maxWaterDepth                 = 0,
  metalMake                     = 0.15,
  minCloakDistance              = 150,
  noAutoFire                    = false,
  objectName                    = [[bairport.s3o]],
  seismicSignature              = 4,
  selfDestructAs                = [[LARGE_BUILDINGEX]],
  showNanoSpray                 = false,
  side                          = [[NKG]],
  sightDistance                 = 273,
  smoothAnim                    = true,
  sortbias                      = [[0]],
  TEDClass                      = [[PLANT]],
  turnRate                      = 0,
  workerTime                    = 1,
  yardMap                       = [[ooccccccooo ooccccccooo ooccccccooo 
ccccccccooo ccccccccooo ccccccccooo ccccccccooc ccccccccooc ccccccccooc ooccccccooc ooccccccooc ccccccccooc]],
  script                        = [[brefuel.lua]],
  featureDefs                   = {
    DEAD  = {
      description      = [[Wreckage - Combat Air Base]],
      blocking         = true,
      category         = [[corpses]],
      damage           = 8000,
      energy           = 0,
      featureDead      = [[DEAD2]],
      featurereclamate = [[SMUDGE01]],
      footprintX       = 7,
      footprintZ       = 6,
      height           = [[40]],
      hitdensity       = [[100]],
      metal            = 275,
      object           = [[bgenericwreckage.s3o]],
      reclaimable      = true,
      reclaimTime      = 275,
      seqnamereclamate = [[TREE1RECLAMATE]],
      world            = [[All Worlds]],
    },
    DEAD2 = {
      description      = [[Debris - Combat Air Base]],
      blocking         = false,
      category         = [[heaps]],
      damage           = 8000,
      energy           = 0,
      featurereclamate = [[SMUDGE01]],
      footprintX       = 11,
      footprintZ       = 12,
      height           = [[4]],
      hitdensity       = [[100]],
      metal            = 275,
      object           = [[b11x12heap.s3o]],
      reclaimable      = true,
      reclaimTime      = 275,
      seqnamereclamate = [[TREE1RECLAMATE]],
      world            = [[All Worlds]],
    },
  },
}
return lowerkeys({ brefuel = unitDef })
Animation script:

Code: Select all

	local building = piece "building"
	local dish = piece "dish"
	local nano = piece "nano"
	local pad = piece "pad"

	function script.Create(unitID)
	end

	function script.QueryLandingPads()
		return pad
	end

	function script.Killed(recentDamage, maxHealth)
		return 0
	end
Note: this is just a test unit. Unit Def was taken from my airport.

The final product for this will be an airport/refuel pad. I'm guessing that's no big deal, just combine the two?

Re: Refuel pads.

Posted: 10 Apr 2010, 11:22
by Tobi
Should return a table with pieces which should be used as landing pads.
i.e.

Code: Select all

   script.QueryLandingPads()
      return { pad }
   end

Re: Refuel pads.

Posted: 10 Apr 2010, 17:18
by SanadaUjiosan
Beautiful. Now I know what table means.

So, I see this Refuel Time tag that I can use. Would I put this in the plane, or the refuel pad? And, I'm guessing it's 1 fuel point a second?

And, my planes are all landing on the same point (I gave my unit 3), clipping into eachother. How do I get them to go to different pads?

Re: Refuel pads.

Posted: 10 Apr 2010, 18:28
by Tobi
How does your script look now?

They should automatically choose a free landing pad..

Re: Refuel pads.

Posted: 10 Apr 2010, 18:30
by SanadaUjiosan

Code: Select all

	local building = piece "building"
	local nano = piece "nano"
	local pad = piece "pad"
	local rpad1 = piece "rpad1"
	local rpad2 = piece "rpad2"
	local rpad3 = piece "rpad3"

	function script.Create(unitID)
	end

	function script.QueryBuildInfo() return pad end

	function script.QueryNanoPiece() return nano end

	function script.Activate()
		SetUnitValue(COB.YARD_OPEN, 1)
		SetUnitValue(COB.INBUILDSTANCE, 1)
		SetUnitValue(COB.BUGGER_OFF, 1)
		return 1
	end

	function script.Deactivate()
		SetUnitValue(COB.YARD_OPEN, 0)
		SetUnitValue(COB.INBUILDSTANCE, 0)
		SetUnitValue(COB.BUGGER_OFF, 0)
		return 0
	end

	function script.QueryLandingPads()
		return { rpad1, rpad2, rpad3 }
	end

	function script.Killed(recentDamage, maxHealth)
		return 0
	end