Skip to content

Upvalued functions sometimes put above leading file comment #4

@ChessBerry

Description

@ChessBerry

E.g. for file projectiles/AIFQuantumWarhead02/AIFQuantumWarhead02_script.lua the upvalue output is

  -- Automatically upvalued moho functions for performance
  local ProjectileMethods = _G.moho.projectile_methods
  local ProjectileMethodsSetScaleVelocity = ProjectileMethods.SetScaleVelocity
  
  local EntityMethods = _G.moho.entity_methods
  local EntityMethodsShakeCamera = EntityMethods.ShakeCamera
  
  local IEffectMethods = _G.moho.IEffect
  local IEffectMethodsSetEmitterCurveParam = IEffectMethods.SetEmitterCurveParam
  local IEffectMethodsOffsetEmitter = IEffectMethods.OffsetEmitter
  
  local GlobalMethods = _G
  local GlobalMethodsCreateLightParticle = GlobalMethods.CreateLightParticle
  local GlobalMethodsCreateEmitterAtEntity = GlobalMethods.CreateEmitterAtEntity
  local GlobalMethodsCreateDecal = GlobalMethods.CreateDecal
  -- End of automatically upvalued moho functions --
  
  ------------------------------------------------------------------------------
  -- File     :  /projectiles/CIFEMPFluxWarhead02/CIFEMPFluxWarhead02_script.lua
  -- Author(s):  Gordon Duclos
  -- Summary  :  EMP Flux Warhead Impact effects projectile
  -- Copyright © 2005,2006 Gas Powered Games, Inc.  All rights reserved.
  ------------------------------------------------------------------------------
  local NullShell = import('/lua/sim/defaultprojectiles.lua').NullShell
  local RandomFloat = import('/lua/utilities.lua').GetRandomFloat
  local EffectTemplate = import('/lua/EffectTemplates.lua')

Which is obviously wrong. The reason for that is probably that the initial comment gets treated as part of the first local statement, not as part of the chunk due to there being no space between them.
To fix this I probably want to force the first statement's comments to always belong to the chunk, if the chunk doesn't already have a comment.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions