contract: the Lua API reference, generated from core/
TICKET-388. contract/lua-reference/generate.py is a Python port of yugioh-legacy-server's duel-engine/ocgcore/lua-reference.sh (bash + awk): one api-<class>.md per luaL_Reg table in core/lib*.cpp (Card, Duel, Effect, Group, Debug; 670 functions) and api-globals.md for the 37 globals interpreter.cpp sets. Row counts match the server repo's committed reference exactly. Regenerate and commit after any core change to those files. Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01DJUFwdiGCHipsxLkgxssSR
This commit is contained in:
1 parent
69ca3fb5b5
commit
ffbfbf8522
7 files changed
+855
No files matched your search
@@ -0,0 +1,298 @@
|
||||
# `Card`
|
||||
|
||||
> Generated from `core/` by `contract/lua-reference/generate.py`; never edited by hand. Every function the core registers on `Card` is listed, and nothing else: a name that isn't here isn't in the core (the card scripts' `library/` defines the rest). A method is called on an object too (`c:IsCode(id)` is `Card.IsCode(c, id)`). *Arguments* is the fewest the core accepts, counting the object.
|
||||
|
||||
| Function | Arguments |
|
||||
|---|---|
|
||||
| `Card.AddCounter` | 3 |
|
||||
| `Card.AddMonsterAttribute` | 2 |
|
||||
| `Card.AssumeProperty` | 3 |
|
||||
| `Card.CancelCardTarget` | 2 |
|
||||
| `Card.CancelToGrave` | 1 |
|
||||
| `Card.CheckActivateEffect` | 4 |
|
||||
| `Card.CheckEquipTarget` | 1 |
|
||||
| `Card.CheckFusionMaterial` | 1 |
|
||||
| `Card.CheckFusionSubstitute` | 2 |
|
||||
| `Card.CheckRemoveOverlayCard` | 4 |
|
||||
| `Card.CheckSPSummonOnce` | 2 |
|
||||
| `Card.CheckUnionTarget` | 1 |
|
||||
| `Card.CheckUniqueOnField` | 2 |
|
||||
| `Card.ClearEffectRelation` | 1 |
|
||||
| `Card.ClearMeta` | 1 |
|
||||
| `Card.CompleteProcedure` | 1 |
|
||||
| `Card.CopyEffect` | 3 |
|
||||
| `Card.CreateEffectRelation` | 2 |
|
||||
| `Card.CreateRelation` | 3 |
|
||||
| `Card.EnableCounterPermit` | 2 |
|
||||
| `Card.EnableDualState` | 1 |
|
||||
| `Card.EnableReviveLimit` | 1 |
|
||||
| `Card.GetActivateEffect` | 1 |
|
||||
| `Card.GetAttack` | 1 |
|
||||
| `Card.GetAttackAnnouncedCount` | 1 |
|
||||
| `Card.GetAttackableTarget` | 1 |
|
||||
| `Card.GetAttackedCount` | 1 |
|
||||
| `Card.GetAttackedGroup` | 1 |
|
||||
| `Card.GetAttackedGroupCount` | 1 |
|
||||
| `Card.GetAttribute` | 1 |
|
||||
| `Card.GetAttributeInGrave` | 1 |
|
||||
| `Card.GetBaseAttack` | 1 |
|
||||
| `Card.GetBaseDefense` | 1 |
|
||||
| `Card.GetBattlePosition` | 1 |
|
||||
| `Card.GetBattleTarget` | 1 |
|
||||
| `Card.GetBattledGroup` | 1 |
|
||||
| `Card.GetBattledGroupCount` | 1 |
|
||||
| `Card.GetCardRegistered` | 2 |
|
||||
| `Card.GetCardTarget` | 1 |
|
||||
| `Card.GetCardTargetCount` | 1 |
|
||||
| `Card.GetCode` | 1 |
|
||||
| `Card.GetColumnGroup` | 1 |
|
||||
| `Card.GetColumnGroupCount` | 1 |
|
||||
| `Card.GetColumnZone` | 2 |
|
||||
| `Card.GetControler` | 1 |
|
||||
| `Card.GetCounter` | 2 |
|
||||
| `Card.GetCurrentScale` | 1 |
|
||||
| `Card.GetDefense` | 1 |
|
||||
| `Card.GetDestination` | 1 |
|
||||
| `Card.GetEffectCount` | 2 |
|
||||
| `Card.GetEquipCount` | 1 |
|
||||
| `Card.GetEquipGroup` | 1 |
|
||||
| `Card.GetEquipTarget` | 1 |
|
||||
| `Card.GetFieldID` | 1 |
|
||||
| `Card.GetFirstCardTarget` | 1 |
|
||||
| `Card.GetFlagEffect` | 2 |
|
||||
| `Card.GetFlagEffectLabel` | 2 |
|
||||
| `Card.GetFusionAttribute` | 1 |
|
||||
| `Card.GetFusionCode` | 1 |
|
||||
| `Card.GetFusionType` | 1 |
|
||||
| `Card.GetHandSynchro` | 1 |
|
||||
| `Card.GetLeaveFieldDest` | 1 |
|
||||
| `Card.GetLeftScale` | 1 |
|
||||
| `Card.GetLevel` | 1 |
|
||||
| `Card.GetLink` | 1 |
|
||||
| `Card.GetLinkAttribute` | 1 |
|
||||
| `Card.GetLinkCode` | 1 |
|
||||
| `Card.GetLinkMarker` | 1 |
|
||||
| `Card.GetLinkRace` | 1 |
|
||||
| `Card.GetLinkType` | 1 |
|
||||
| `Card.GetLinkedGroup` | 1 |
|
||||
| `Card.GetLinkedGroupCount` | 1 |
|
||||
| `Card.GetLinkedZone` | 1 |
|
||||
| `Card.GetLocation` | 1 |
|
||||
| `Card.GetMaterial` | 1 |
|
||||
| `Card.GetMaterialCount` | 1 |
|
||||
| `Card.GetMetaKeys` | 1 |
|
||||
| `Card.GetMetaValue` | 2 |
|
||||
| `Card.GetMutualLinkedGroup` | 1 |
|
||||
| `Card.GetMutualLinkedGroupCount` | 1 |
|
||||
| `Card.GetMutualLinkedZone` | 1 |
|
||||
| `Card.GetOriginalAttribute` | 1 |
|
||||
| `Card.GetOriginalCode` | 1 |
|
||||
| `Card.GetOriginalCodeRule` | 1 |
|
||||
| `Card.GetOriginalLeftScale` | 1 |
|
||||
| `Card.GetOriginalLevel` | 1 |
|
||||
| `Card.GetOriginalLinkMarker` | 1 |
|
||||
| `Card.GetOriginalRace` | 1 |
|
||||
| `Card.GetOriginalRank` | 1 |
|
||||
| `Card.GetOriginalRightScale` | 1 |
|
||||
| `Card.GetOriginalType` | 1 |
|
||||
| `Card.GetOverlayCount` | 1 |
|
||||
| `Card.GetOverlayGroup` | 1 |
|
||||
| `Card.GetOverlayTarget` | 1 |
|
||||
| `Card.GetOwner` | 1 |
|
||||
| `Card.GetOwnerTarget` | 1 |
|
||||
| `Card.GetOwnerTargetCount` | 1 |
|
||||
| `Card.GetPosition` | 1 |
|
||||
| `Card.GetPreviousAttackOnField` | 1 |
|
||||
| `Card.GetPreviousAttributeOnField` | 1 |
|
||||
| `Card.GetPreviousCodeOnField` | 1 |
|
||||
| `Card.GetPreviousControler` | 1 |
|
||||
| `Card.GetPreviousDefenseOnField` | 1 |
|
||||
| `Card.GetPreviousEquipTarget` | 1 |
|
||||
| `Card.GetPreviousLevelOnField` | 1 |
|
||||
| `Card.GetPreviousLocation` | 1 |
|
||||
| `Card.GetPreviousOverlayCountOnField` | 1 |
|
||||
| `Card.GetPreviousPosition` | 1 |
|
||||
| `Card.GetPreviousRaceOnField` | 1 |
|
||||
| `Card.GetPreviousRankOnField` | 1 |
|
||||
| `Card.GetPreviousSequence` | 1 |
|
||||
| `Card.GetPreviousTypeOnField` | 1 |
|
||||
| `Card.GetRace` | 1 |
|
||||
| `Card.GetRaceInGrave` | 1 |
|
||||
| `Card.GetRank` | 1 |
|
||||
| `Card.GetRealFieldID` | 1 |
|
||||
| `Card.GetReason` | 1 |
|
||||
| `Card.GetReasonCard` | 1 |
|
||||
| `Card.GetReasonEffect` | 1 |
|
||||
| `Card.GetReasonPlayer` | 1 |
|
||||
| `Card.GetRemovedOverlayCount` | 1 |
|
||||
| `Card.GetRightScale` | 1 |
|
||||
| `Card.GetRitualLevel` | 2 |
|
||||
| `Card.GetSequence` | 1 |
|
||||
| `Card.GetSpecialSummonInfo` | 1 |
|
||||
| `Card.GetSummonLocation` | 1 |
|
||||
| `Card.GetSummonPlayer` | 1 |
|
||||
| `Card.GetSummonType` | 1 |
|
||||
| `Card.GetSynchroLevel` | 2 |
|
||||
| `Card.GetSynchroType` | 1 |
|
||||
| `Card.GetTextAttack` | 1 |
|
||||
| `Card.GetTextDefense` | 1 |
|
||||
| `Card.GetTributeRequirement` | 1 |
|
||||
| `Card.GetTunerLimit` | 1 |
|
||||
| `Card.GetTurnCounter` | 1 |
|
||||
| `Card.GetTurnID` | 1 |
|
||||
| `Card.GetType` | 1 |
|
||||
| `Card.GetUnionCount` | 1 |
|
||||
| `Card.GetXyzType` | 1 |
|
||||
| `Card.HasMetaValue` | 2 |
|
||||
| `Card.IsAbleToChangeControler` | 1 |
|
||||
| `Card.IsAbleToDeck` | 1 |
|
||||
| `Card.IsAbleToDeckAsCost` | 1 |
|
||||
| `Card.IsAbleToDeckOrExtraAsCost` | 1 |
|
||||
| `Card.IsAbleToDecreaseAttackAsCost` | 1 |
|
||||
| `Card.IsAbleToDecreaseDefenseAsCost` | 1 |
|
||||
| `Card.IsAbleToExtra` | 1 |
|
||||
| `Card.IsAbleToExtraAsCost` | 1 |
|
||||
| `Card.IsAbleToGrave` | 1 |
|
||||
| `Card.IsAbleToGraveAsCost` | 1 |
|
||||
| `Card.IsAbleToHand` | 1 |
|
||||
| `Card.IsAbleToHandAsCost` | 1 |
|
||||
| `Card.IsAbleToRemove` | 1 |
|
||||
| `Card.IsAbleToRemoveAsCost` | 1 |
|
||||
| `Card.IsAllColumn` | 1 |
|
||||
| `Card.IsAllReasons` | 2 |
|
||||
| `Card.IsAllTypes` | 2 |
|
||||
| `Card.IsAttack` | 2 |
|
||||
| `Card.IsAttackAbove` | 2 |
|
||||
| `Card.IsAttackBelow` | 2 |
|
||||
| `Card.IsAttackPos` | 1 |
|
||||
| `Card.IsAttackable` | 1 |
|
||||
| `Card.IsAttribute` | 2 |
|
||||
| `Card.IsCanAddCounter` | 3 |
|
||||
| `Card.IsCanBeBattleTarget` | 2 |
|
||||
| `Card.IsCanBeDisabledByEffect` | 2 |
|
||||
| `Card.IsCanBeEffectTarget` | 1 |
|
||||
| `Card.IsCanBeFusionMaterial` | 1 |
|
||||
| `Card.IsCanBeLinkMaterial` | 2 |
|
||||
| `Card.IsCanBePlacedOnField` | 1 |
|
||||
| `Card.IsCanBeRitualMaterial` | 2 |
|
||||
| `Card.IsCanBeSpecialSummoned` | 6 |
|
||||
| `Card.IsCanBeSynchroMaterial` | 1 |
|
||||
| `Card.IsCanBeXyzMaterial` | 2 |
|
||||
| `Card.IsCanChangePosition` | 1 |
|
||||
| `Card.IsCanHaveCounter` | 2 |
|
||||
| `Card.IsCanOverlay` | 1 |
|
||||
| `Card.IsCanRemoveCounter` | 5 |
|
||||
| `Card.IsCanTurnSet` | 1 |
|
||||
| `Card.IsChainAttackable` | 1 |
|
||||
| `Card.IsCode` | 2 |
|
||||
| `Card.IsControler` | 2 |
|
||||
| `Card.IsControlerCanBeChanged` | 1 |
|
||||
| `Card.IsDefense` | 2 |
|
||||
| `Card.IsDefenseAbove` | 2 |
|
||||
| `Card.IsDefenseBelow` | 2 |
|
||||
| `Card.IsDefensePos` | 1 |
|
||||
| `Card.IsDestructable` | 1 |
|
||||
| `Card.IsDirectAttacked` | 1 |
|
||||
| `Card.IsDisabled` | 1 |
|
||||
| `Card.IsDiscardable` | 1 |
|
||||
| `Card.IsDualState` | 1 |
|
||||
| `Card.IsEffectProperty` | 2 |
|
||||
| `Card.IsExtraDeckMonster` | 1 |
|
||||
| `Card.IsExtraLinkState` | 1 |
|
||||
| `Card.IsFacedown` | 1 |
|
||||
| `Card.IsFaceup` | 1 |
|
||||
| `Card.IsFaceupEx` | 1 |
|
||||
| `Card.IsForbidden` | 1 |
|
||||
| `Card.IsFusionAttribute` | 2 |
|
||||
| `Card.IsFusionCode` | 2 |
|
||||
| `Card.IsFusionSetCard` | 2 |
|
||||
| `Card.IsFusionSummonableCard` | 1 |
|
||||
| `Card.IsFusionType` | 2 |
|
||||
| `Card.IsHasCardTarget` | 2 |
|
||||
| `Card.IsHasDefense` | 1 |
|
||||
| `Card.IsHasEffect` | 2 |
|
||||
| `Card.IsHasLevel` | 1 |
|
||||
| `Card.IsImmuneToEffect` | 2 |
|
||||
| `Card.IsLevel` | 2 |
|
||||
| `Card.IsLevelAbove` | 2 |
|
||||
| `Card.IsLevelBelow` | 2 |
|
||||
| `Card.IsLink` | 2 |
|
||||
| `Card.IsLinkAbove` | 2 |
|
||||
| `Card.IsLinkAttribute` | 2 |
|
||||
| `Card.IsLinkBelow` | 2 |
|
||||
| `Card.IsLinkCode` | 2 |
|
||||
| `Card.IsLinkMarker` | 2 |
|
||||
| `Card.IsLinkRace` | 2 |
|
||||
| `Card.IsLinkSetCard` | 2 |
|
||||
| `Card.IsLinkState` | 1 |
|
||||
| `Card.IsLinkSummonable` | 2 |
|
||||
| `Card.IsLinkType` | 2 |
|
||||
| `Card.IsLocation` | 2 |
|
||||
| `Card.IsMSetable` | 3 |
|
||||
| `Card.IsNonAttribute` | 2 |
|
||||
| `Card.IsNotTuner` | 2 |
|
||||
| `Card.IsOnField` | 1 |
|
||||
| `Card.IsOriginalCodeRule` | 2 |
|
||||
| `Card.IsOriginalEffectProperty` | 2 |
|
||||
| `Card.IsOriginalSetCard` | 2 |
|
||||
| `Card.IsPosition` | 2 |
|
||||
| `Card.IsPreviousControler` | 2 |
|
||||
| `Card.IsPreviousLocation` | 2 |
|
||||
| `Card.IsPreviousPosition` | 2 |
|
||||
| `Card.IsPreviousSetCard` | 2 |
|
||||
| `Card.IsPublic` | 1 |
|
||||
| `Card.IsRace` | 2 |
|
||||
| `Card.IsRank` | 2 |
|
||||
| `Card.IsRankAbove` | 2 |
|
||||
| `Card.IsRankBelow` | 2 |
|
||||
| `Card.IsReason` | 2 |
|
||||
| `Card.IsRelateToBattle` | 1 |
|
||||
| `Card.IsRelateToCard` | 2 |
|
||||
| `Card.IsRelateToChain` | 1 |
|
||||
| `Card.IsRelateToEffect` | 2 |
|
||||
| `Card.IsReleasable` | 1 |
|
||||
| `Card.IsReleasableByEffect` | 1 |
|
||||
| `Card.IsRitualType` | 2 |
|
||||
| `Card.IsSSetable` | 1 |
|
||||
| `Card.IsSetCard` | 2 |
|
||||
| `Card.IsSpecialSummonSetCard` | 2 |
|
||||
| `Card.IsSpecialSummonable` | 1 |
|
||||
| `Card.IsSpecialSummonableCard` | 1 |
|
||||
| `Card.IsStatus` | 2 |
|
||||
| `Card.IsSummonLocation` | 2 |
|
||||
| `Card.IsSummonPlayer` | 2 |
|
||||
| `Card.IsSummonType` | 2 |
|
||||
| `Card.IsSummonable` | 3 |
|
||||
| `Card.IsSummonableCard` | 1 |
|
||||
| `Card.IsSynchroSummonable` | 2 |
|
||||
| `Card.IsSynchroType` | 2 |
|
||||
| `Card.IsTuner` | 2 |
|
||||
| `Card.IsType` | 2 |
|
||||
| `Card.IsXyzLevel` | 3 |
|
||||
| `Card.IsXyzSummonable` | 2 |
|
||||
| `Card.IsXyzSummonableByRose` | 3 |
|
||||
| `Card.IsXyzType` | 2 |
|
||||
| `Card.RegisterEffect` | 2 |
|
||||
| `Card.RegisterFlagEffect` | 5 |
|
||||
| `Card.ReleaseEffectRelation` | 2 |
|
||||
| `Card.ReleaseRelation` | 2 |
|
||||
| `Card.RemoveCounter` | 5 |
|
||||
| `Card.RemoveOverlayCard` | 5 |
|
||||
| `Card.ReplaceEffect` | 3 |
|
||||
| `Card.ResetEffect` | 3 |
|
||||
| `Card.ResetFlagEffect` | 2 |
|
||||
| `Card.ResetNegateEffect` | 1 |
|
||||
| `Card.ReverseInDeck` | 1 |
|
||||
| `Card.SetCardData` | 3 |
|
||||
| `Card.SetCardTarget` | 2 |
|
||||
| `Card.SetCounterLimit` | 3 |
|
||||
| `Card.SetEntityCode` | 2 |
|
||||
| `Card.SetFlagEffectLabel` | 3 |
|
||||
| `Card.SetHint` | 3 |
|
||||
| `Card.SetMaterial` | 2 |
|
||||
| `Card.SetMetaValue` | 3 |
|
||||
| `Card.SetReason` | 2 |
|
||||
| `Card.SetSPSummonOnce` | 2 |
|
||||
| `Card.SetStatus` | 3 |
|
||||
| `Card.SetTurnCounter` | 2 |
|
||||
| `Card.SetUniqueOnField` | 4 |
|
||||
@@ -0,0 +1,17 @@
|
||||
# `Debug`
|
||||
|
||||
> Generated from `core/` by `contract/lua-reference/generate.py`; never edited by hand. Every function the core registers on `Debug` is listed, and nothing else: a name that isn't here isn't in the core (the card scripts' `library/` defines the rest). A method is called on an object too (`c:IsCode(id)` is `Card.IsCode(c, id)`). *Arguments* is the fewest the core accepts, counting the object.
|
||||
|
||||
| Function | Arguments |
|
||||
|---|---|
|
||||
| `Debug.AddCard` | 6 |
|
||||
| `Debug.Message` | 1 |
|
||||
| `Debug.PreAddCounter` | 2 |
|
||||
| `Debug.PreEquip` | 2 |
|
||||
| `Debug.PreSetTarget` | 2 |
|
||||
| `Debug.PreSummon` | 2 |
|
||||
| `Debug.ReloadFieldBegin` | 1 |
|
||||
| `Debug.ReloadFieldEnd` | any |
|
||||
| `Debug.SetAIName` | 1 |
|
||||
| `Debug.SetPlayerInfo` | 4 |
|
||||
| `Debug.ShowHint` | 1 |
|
||||
@@ -0,0 +1,266 @@
|
||||
# `Duel`
|
||||
|
||||
> Generated from `core/` by `contract/lua-reference/generate.py`; never edited by hand. Every function the core registers on `Duel` is listed, and nothing else: a name that isn't here isn't in the core (the card scripts' `library/` defines the rest). A method is called on an object too (`c:IsCode(id)` is `Card.IsCode(c, id)`). *Arguments* is the fewest the core accepts, counting the object.
|
||||
|
||||
| Function | Arguments |
|
||||
|---|---|
|
||||
| `Duel.Activate` | 1 |
|
||||
| `Duel.AddCustomActivityCounter` | 3 |
|
||||
| `Duel.AdjustAll` | any |
|
||||
| `Duel.AdjustInstantly` | any |
|
||||
| `Duel.AnnounceAttribute` | 3 |
|
||||
| `Duel.AnnounceCard` | 1 |
|
||||
| `Duel.AnnounceCardFilter` | 1 |
|
||||
| `Duel.AnnounceCardSilent` | any |
|
||||
| `Duel.AnnounceCoin` | 1 |
|
||||
| `Duel.AnnounceLevel` | 1 |
|
||||
| `Duel.AnnounceNumber` | 2 |
|
||||
| `Duel.AnnounceRace` | 3 |
|
||||
| `Duel.AnnounceType` | 1 |
|
||||
| `Duel.BreakEffect` | any |
|
||||
| `Duel.CalculateDamage` | 2 |
|
||||
| `Duel.ChainAttack` | any |
|
||||
| `Duel.ChangeAttackTarget` | 1 |
|
||||
| `Duel.ChangeAttacker` | 1 |
|
||||
| `Duel.ChangeBattleDamage` | 2 |
|
||||
| `Duel.ChangeChainOperation` | 2 |
|
||||
| `Duel.ChangePosition` | 2 |
|
||||
| `Duel.ChangeTargetCard` | 2 |
|
||||
| `Duel.ChangeTargetParam` | 2 |
|
||||
| `Duel.ChangeTargetPlayer` | 2 |
|
||||
| `Duel.CheckChainTarget` | 2 |
|
||||
| `Duel.CheckChainUniqueness` | any |
|
||||
| `Duel.CheckEvent` | 1 |
|
||||
| `Duel.CheckLPCost` | 2 |
|
||||
| `Duel.CheckLocation` | 3 |
|
||||
| `Duel.CheckMustMaterial` | 3 |
|
||||
| `Duel.CheckPhaseActivity` | any |
|
||||
| `Duel.CheckReleaseGroup` | any |
|
||||
| `Duel.CheckReleaseGroupEx` | any |
|
||||
| `Duel.CheckRemoveOverlayCard` | 5 |
|
||||
| `Duel.CheckSummonedCount` | any |
|
||||
| `Duel.CheckSynchroMaterial` | 5 |
|
||||
| `Duel.CheckTiming` | 1 |
|
||||
| `Duel.CheckTribute` | 2 |
|
||||
| `Duel.CheckTunerMaterial` | 6 |
|
||||
| `Duel.CheckXyzMaterial` | 6 |
|
||||
| `Duel.ClearChainMeta` | 1 |
|
||||
| `Duel.ClearMeta` | any |
|
||||
| `Duel.ClearOperationInfo` | 1 |
|
||||
| `Duel.ClearRegistry` | any |
|
||||
| `Duel.ClearTargetCard` | any |
|
||||
| `Duel.ConfirmCards` | 2 |
|
||||
| `Duel.ConfirmDecktop` | 2 |
|
||||
| `Duel.ConfirmExtratop` | 2 |
|
||||
| `Duel.CreateToken` | 2 |
|
||||
| `Duel.Damage` | 3 |
|
||||
| `Duel.Destroy` | 2 |
|
||||
| `Duel.DisableActionCheck` | 1 |
|
||||
| `Duel.DisableSelfDestroyCheck` | any |
|
||||
| `Duel.DisableShuffleCheck` | any |
|
||||
| `Duel.DiscardDeck` | 3 |
|
||||
| `Duel.DiscardHand` | 5 |
|
||||
| `Duel.Draw` | 3 |
|
||||
| `Duel.EnableGlobalFlag` | 1 |
|
||||
| `Duel.Equip` | 3 |
|
||||
| `Duel.EquipComplete` | any |
|
||||
| `Duel.Exile` | 2 |
|
||||
| `Duel.GetActivityCount` | 2 |
|
||||
| `Duel.GetAttackTarget` | any |
|
||||
| `Duel.GetAttacker` | any |
|
||||
| `Duel.GetBattleDamage` | 1 |
|
||||
| `Duel.GetBattleMonster` | 1 |
|
||||
| `Duel.GetBattledCount` | 1 |
|
||||
| `Duel.GetCardsInZone` | 2 |
|
||||
| `Duel.GetChainEvent` | 1 |
|
||||
| `Duel.GetChainInfo` | 1 |
|
||||
| `Duel.GetChainMaterial` | 1 |
|
||||
| `Duel.GetChainMetaKeys` | 1 |
|
||||
| `Duel.GetChainMetaValue` | 2 |
|
||||
| `Duel.GetCoinResult` | any |
|
||||
| `Duel.GetControl` | 2 |
|
||||
| `Duel.GetCounter` | 4 |
|
||||
| `Duel.GetCurrentChain` | any |
|
||||
| `Duel.GetCurrentPhase` | any |
|
||||
| `Duel.GetCustomActivityCount` | 3 |
|
||||
| `Duel.GetDecktopGroup` | 2 |
|
||||
| `Duel.GetDiceResult` | any |
|
||||
| `Duel.GetDrawCount` | 1 |
|
||||
| `Duel.GetExtraTopGroup` | 2 |
|
||||
| `Duel.GetFieldCard` | 3 |
|
||||
| `Duel.GetFieldGroup` | 3 |
|
||||
| `Duel.GetFieldGroupCount` | 3 |
|
||||
| `Duel.GetFirstMatchingCard` | 5 |
|
||||
| `Duel.GetFirstTarget` | any |
|
||||
| `Duel.GetFlagEffect` | 2 |
|
||||
| `Duel.GetFlagEffectLabel` | 2 |
|
||||
| `Duel.GetFusionMaterial` | 1 |
|
||||
| `Duel.GetLP` | 1 |
|
||||
| `Duel.GetLastSelectHint` | any |
|
||||
| `Duel.GetLinkedGroup` | 3 |
|
||||
| `Duel.GetLinkedGroupCount` | 3 |
|
||||
| `Duel.GetLinkedZone` | 1 |
|
||||
| `Duel.GetLocationCount` | 2 |
|
||||
| `Duel.GetLocationCountFromEx` | 1 |
|
||||
| `Duel.GetMZoneCount` | 1 |
|
||||
| `Duel.GetMasterRule` | any |
|
||||
| `Duel.GetMatchingGroup` | 5 |
|
||||
| `Duel.GetMatchingGroupCount` | 5 |
|
||||
| `Duel.GetMetaKeys` | any |
|
||||
| `Duel.GetMetaValue` | any |
|
||||
| `Duel.GetMustMaterial` | 2 |
|
||||
| `Duel.GetOperatedGroup` | any |
|
||||
| `Duel.GetOperationCount` | 1 |
|
||||
| `Duel.GetOperationInfo` | 2 |
|
||||
| `Duel.GetOverlayCount` | 3 |
|
||||
| `Duel.GetOverlayGroup` | 3 |
|
||||
| `Duel.GetRandomNumber` | any |
|
||||
| `Duel.GetReadyChain` | any |
|
||||
| `Duel.GetRegistry` | any |
|
||||
| `Duel.GetRegistryKeys` | any |
|
||||
| `Duel.GetRegistryValue` | 1 |
|
||||
| `Duel.GetReleaseGroup` | 1 |
|
||||
| `Duel.GetReleaseGroupCount` | 1 |
|
||||
| `Duel.GetRitualMaterial` | 1 |
|
||||
| `Duel.GetRitualMaterialEx` | 1 |
|
||||
| `Duel.GetSZoneCount` | 1 |
|
||||
| `Duel.GetSynchroMaterial` | 1 |
|
||||
| `Duel.GetTargetCount` | 5 |
|
||||
| `Duel.GetTargetsRelateToChain` | any |
|
||||
| `Duel.GetTributeCount` | 1 |
|
||||
| `Duel.GetTributeGroup` | 1 |
|
||||
| `Duel.GetTurnCount` | any |
|
||||
| `Duel.GetTurnPlayer` | any |
|
||||
| `Duel.GetUsableMZoneCount` | 1 |
|
||||
| `Duel.GrabSelectedCard` | any |
|
||||
| `Duel.HasChainMetaValue` | 2 |
|
||||
| `Duel.HasMetaValue` | any |
|
||||
| `Duel.Hint` | 3 |
|
||||
| `Duel.HintSelection` | 1 |
|
||||
| `Duel.IncreaseSummonedCount` | any |
|
||||
| `Duel.IsAbleToEnterBP` | any |
|
||||
| `Duel.IsBattlePhase` | any |
|
||||
| `Duel.IsCanAddCounter` | 1 |
|
||||
| `Duel.IsCanRemoveCounter` | 6 |
|
||||
| `Duel.IsChainDisablable` | 1 |
|
||||
| `Duel.IsChainDisabled` | 1 |
|
||||
| `Duel.IsChainNegatable` | 1 |
|
||||
| `Duel.IsChainSolving` | any |
|
||||
| `Duel.IsDamageCalculated` | any |
|
||||
| `Duel.IsEnvironment` | 1 |
|
||||
| `Duel.IsExistingMatchingCard` | 6 |
|
||||
| `Duel.IsExistingTarget` | 6 |
|
||||
| `Duel.IsGlobalFlag` | 1 |
|
||||
| `Duel.IsMainPhase` | any |
|
||||
| `Duel.IsPhase` | 1 |
|
||||
| `Duel.IsPlayerAffectedByEffect` | 2 |
|
||||
| `Duel.IsPlayerCanAdditionalSummon` | 1 |
|
||||
| `Duel.IsPlayerCanDiscardDeck` | 2 |
|
||||
| `Duel.IsPlayerCanDiscardDeckAsCost` | 2 |
|
||||
| `Duel.IsPlayerCanDraw` | 1 |
|
||||
| `Duel.IsPlayerCanFlipSummon` | 1 |
|
||||
| `Duel.IsPlayerCanMSet` | 1 |
|
||||
| `Duel.IsPlayerCanRelease` | 1 |
|
||||
| `Duel.IsPlayerCanRemove` | 1 |
|
||||
| `Duel.IsPlayerCanSSet` | 1 |
|
||||
| `Duel.IsPlayerCanSendtoDeck` | 1 |
|
||||
| `Duel.IsPlayerCanSendtoGrave` | 1 |
|
||||
| `Duel.IsPlayerCanSendtoHand` | 1 |
|
||||
| `Duel.IsPlayerCanSpecialSummon` | 1 |
|
||||
| `Duel.IsPlayerCanSpecialSummonCount` | 2 |
|
||||
| `Duel.IsPlayerCanSpecialSummonMonster` | 2 |
|
||||
| `Duel.IsPlayerCanSummon` | 1 |
|
||||
| `Duel.IsSummonCancelable` | any |
|
||||
| `Duel.IsTurnPlayer` | 1 |
|
||||
| `Duel.LinkSummon` | 3 |
|
||||
| `Duel.LoadScript` | 1 |
|
||||
| `Duel.MSet` | 4 |
|
||||
| `Duel.MajesticCopy` | 2 |
|
||||
| `Duel.MoveSequence` | 2 |
|
||||
| `Duel.MoveToField` | 6 |
|
||||
| `Duel.MoveTurnCount` | any |
|
||||
| `Duel.NegateActivation` | 1 |
|
||||
| `Duel.NegateAttack` | any |
|
||||
| `Duel.NegateEffect` | 1 |
|
||||
| `Duel.NegateRelatedChain` | 2 |
|
||||
| `Duel.NegateSummon` | 1 |
|
||||
| `Duel.Overlay` | 2 |
|
||||
| `Duel.PayLPCost` | 2 |
|
||||
| `Duel.RDComplete` | any |
|
||||
| `Duel.RaiseEvent` | 7 |
|
||||
| `Duel.RaiseSingleEvent` | 7 |
|
||||
| `Duel.ReadCard` | 2 |
|
||||
| `Duel.Readjust` | any |
|
||||
| `Duel.Recover` | 3 |
|
||||
| `Duel.RegisterEffect` | 2 |
|
||||
| `Duel.RegisterFlagEffect` | 5 |
|
||||
| `Duel.Release` | 2 |
|
||||
| `Duel.ReleaseRitualMaterial` | 1 |
|
||||
| `Duel.Remove` | 3 |
|
||||
| `Duel.RemoveCounter` | 6 |
|
||||
| `Duel.RemoveOverlayCard` | 6 |
|
||||
| `Duel.ResetFlagEffect` | 2 |
|
||||
| `Duel.ResetTimeLimit` | 1 |
|
||||
| `Duel.ReturnToField` | 1 |
|
||||
| `Duel.RevealSelectDeckSequence` | any |
|
||||
| `Duel.RockPaperScissors` | any |
|
||||
| `Duel.SSet` | 2 |
|
||||
| `Duel.SelectDisableField` | 5 |
|
||||
| `Duel.SelectEffectYesNo` | 2 |
|
||||
| `Duel.SelectField` | 5 |
|
||||
| `Duel.SelectFusionMaterial` | 3 |
|
||||
| `Duel.SelectMatchingCard` | 8 |
|
||||
| `Duel.SelectOption` | 1 |
|
||||
| `Duel.SelectPosition` | 3 |
|
||||
| `Duel.SelectReleaseGroup` | any |
|
||||
| `Duel.SelectReleaseGroupEx` | any |
|
||||
| `Duel.SelectSequence` | any |
|
||||
| `Duel.SelectSynchroMaterial` | 6 |
|
||||
| `Duel.SelectTarget` | 8 |
|
||||
| `Duel.SelectTribute` | 4 |
|
||||
| `Duel.SelectTunerMaterial` | 7 |
|
||||
| `Duel.SelectXyzMaterial` | 6 |
|
||||
| `Duel.SelectYesNo` | 2 |
|
||||
| `Duel.SendtoDeck` | 4 |
|
||||
| `Duel.SendtoExtraP` | 3 |
|
||||
| `Duel.SendtoGrave` | 2 |
|
||||
| `Duel.SendtoHand` | 3 |
|
||||
| `Duel.SetChainLimit` | 1 |
|
||||
| `Duel.SetChainLimitTillChainEnd` | 1 |
|
||||
| `Duel.SetChainMetaValue` | 3 |
|
||||
| `Duel.SetCoinResult` | any |
|
||||
| `Duel.SetDiceResult` | any |
|
||||
| `Duel.SetFlagEffectLabel` | 3 |
|
||||
| `Duel.SetFusionMaterial` | 1 |
|
||||
| `Duel.SetLP` | 2 |
|
||||
| `Duel.SetMetaValue` | any |
|
||||
| `Duel.SetMetatable` | 2 |
|
||||
| `Duel.SetOperationInfo` | 6 |
|
||||
| `Duel.SetRegistry` | 1 |
|
||||
| `Duel.SetRegistryValue` | 2 |
|
||||
| `Duel.SetSelectedCard` | 1 |
|
||||
| `Duel.SetSummonCancelable` | 1 |
|
||||
| `Duel.SetSynchroMaterial` | 1 |
|
||||
| `Duel.SetTargetCard` | 1 |
|
||||
| `Duel.SetTargetParam` | 1 |
|
||||
| `Duel.SetTargetPlayer` | 1 |
|
||||
| `Duel.ShuffleDeck` | 1 |
|
||||
| `Duel.ShuffleExtra` | 1 |
|
||||
| `Duel.ShuffleHand` | 1 |
|
||||
| `Duel.ShuffleSetCard` | 1 |
|
||||
| `Duel.SkipPhase` | 4 |
|
||||
| `Duel.SortDecktop` | 3 |
|
||||
| `Duel.SpecialSummon` | 7 |
|
||||
| `Duel.SpecialSummonComplete` | any |
|
||||
| `Duel.SpecialSummonRule` | 2 |
|
||||
| `Duel.SpecialSummonStep` | 7 |
|
||||
| `Duel.Summon` | 4 |
|
||||
| `Duel.SwapControl` | 2 |
|
||||
| `Duel.SwapDeckAndGrave` | 1 |
|
||||
| `Duel.SwapSequence` | 2 |
|
||||
| `Duel.SynchroSummon` | 3 |
|
||||
| `Duel.TossCoin` | 2 |
|
||||
| `Duel.TossDice` | 2 |
|
||||
| `Duel.Win` | 2 |
|
||||
| `Duel.XyzSummon` | 3 |
|
||||
| `Duel.XyzSummonByRose` | 4 |
|
||||
@@ -0,0 +1,68 @@
|
||||
# `Effect`
|
||||
|
||||
> Generated from `core/` by `contract/lua-reference/generate.py`; never edited by hand. Every function the core registers on `Effect` is listed, and nothing else: a name that isn't here isn't in the core (the card scripts' `library/` defines the rest). A method is called on an object too (`c:IsCode(id)` is `Card.IsCode(c, id)`). *Arguments* is the fewest the core accepts, counting the object.
|
||||
|
||||
| Function | Arguments |
|
||||
|---|---|
|
||||
| `Effect.CheckCountLimit` | 2 |
|
||||
| `Effect.ClearMeta` | 1 |
|
||||
| `Effect.Clone` | 1 |
|
||||
| `Effect.CreateEffect` | 1 |
|
||||
| `Effect.GetActivateLocation` | 1 |
|
||||
| `Effect.GetActivateSequence` | 1 |
|
||||
| `Effect.GetActiveType` | 1 |
|
||||
| `Effect.GetCategory` | any |
|
||||
| `Effect.GetCode` | any |
|
||||
| `Effect.GetCondition` | 1 |
|
||||
| `Effect.GetCost` | 1 |
|
||||
| `Effect.GetCountLimit` | 1 |
|
||||
| `Effect.GetDescription` | any |
|
||||
| `Effect.GetFieldID` | any |
|
||||
| `Effect.GetHandler` | 1 |
|
||||
| `Effect.GetHandlerPlayer` | 1 |
|
||||
| `Effect.GetLabel` | 1 |
|
||||
| `Effect.GetLabelObject` | 1 |
|
||||
| `Effect.GetMetaKeys` | 1 |
|
||||
| `Effect.GetMetaValue` | 2 |
|
||||
| `Effect.GetOperation` | 1 |
|
||||
| `Effect.GetOwner` | 1 |
|
||||
| `Effect.GetOwnerPlayer` | 1 |
|
||||
| `Effect.GetProperty` | 1 |
|
||||
| `Effect.GetRange` | any |
|
||||
| `Effect.GetTarget` | 1 |
|
||||
| `Effect.GetType` | any |
|
||||
| `Effect.GetValue` | 1 |
|
||||
| `Effect.GlobalEffect` | any |
|
||||
| `Effect.HasMetaValue` | 2 |
|
||||
| `Effect.IsActivatable` | 2 |
|
||||
| `Effect.IsActivated` | 1 |
|
||||
| `Effect.IsActiveType` | 2 |
|
||||
| `Effect.IsCostChecked` | 1 |
|
||||
| `Effect.IsHasCategory` | any |
|
||||
| `Effect.IsHasProperty` | 2 |
|
||||
| `Effect.IsHasRange` | any |
|
||||
| `Effect.IsHasType` | any |
|
||||
| `Effect.Reset` | 1 |
|
||||
| `Effect.SetAbsoluteRange` | 4 |
|
||||
| `Effect.SetCategory` | 2 |
|
||||
| `Effect.SetCode` | 2 |
|
||||
| `Effect.SetCondition` | 2 |
|
||||
| `Effect.SetCost` | 2 |
|
||||
| `Effect.SetCostCheck` | 2 |
|
||||
| `Effect.SetCountLimit` | 2 |
|
||||
| `Effect.SetDescription` | 2 |
|
||||
| `Effect.SetHintTiming` | 2 |
|
||||
| `Effect.SetLabel` | 2 |
|
||||
| `Effect.SetLabelObject` | 2 |
|
||||
| `Effect.SetMetaValue` | 3 |
|
||||
| `Effect.SetOperation` | 2 |
|
||||
| `Effect.SetOwner` | 2 |
|
||||
| `Effect.SetOwnerPlayer` | 1 |
|
||||
| `Effect.SetProperty` | 2 |
|
||||
| `Effect.SetRange` | 2 |
|
||||
| `Effect.SetReset` | 2 |
|
||||
| `Effect.SetTarget` | 2 |
|
||||
| `Effect.SetTargetRange` | 3 |
|
||||
| `Effect.SetType` | 2 |
|
||||
| `Effect.SetValue` | 2 |
|
||||
| `Effect.UseCountLimit` | 2 |
|
||||
@@ -0,0 +1,43 @@
|
||||
# `Globals`
|
||||
|
||||
> Generated from `core/` by `contract/lua-reference/generate.py`; never edited by hand. The values the core itself sets as Lua globals, beside the card scripts' `constant.lua`.
|
||||
|
||||
| Global |
|
||||
|---|
|
||||
| `CARDDATA_ALIAS` |
|
||||
| `CARDDATA_ATTACK` |
|
||||
| `CARDDATA_ATTRIBUTE` |
|
||||
| `CARDDATA_CODE` |
|
||||
| `CARDDATA_DEFENSE` |
|
||||
| `CARDDATA_LEVEL` |
|
||||
| `CARDDATA_LINK_MARKER` |
|
||||
| `CARDDATA_LSCALE` |
|
||||
| `CARDDATA_RACE` |
|
||||
| `CARDDATA_RSCALE` |
|
||||
| `CARDDATA_SETCODE` |
|
||||
| `CARDDATA_TYPE` |
|
||||
| `EFFECT_ADD_LINK_MARKER_KOISHI` |
|
||||
| `EFFECT_ADD_SUMMON_TYPE_KOISHI` |
|
||||
| `EFFECT_ALLOW_SYNCHRO_KOISHI` |
|
||||
| `EFFECT_CANNOT_LOSE_KOISHI` |
|
||||
| `EFFECT_CHANGE_LINK_MARKER_KOISHI` |
|
||||
| `EFFECT_CHANGE_SUMMON_LOCATION_KOISHI` |
|
||||
| `EFFECT_CHANGE_SUMMON_TYPE_KOISHI` |
|
||||
| `EFFECT_EXTRA_TOMAIN_KOISHI` |
|
||||
| `EFFECT_FLAG2_ACTIVATE_MONSTER_SZONE` |
|
||||
| `EFFECT_FLAG2_AVAILABLE_BD` |
|
||||
| `EFFECT_FLAG2_SPOSITCH` |
|
||||
| `EFFECT_LINK_SPELL_KOISHI` |
|
||||
| `EFFECT_MAP_OF_HEAVEN` |
|
||||
| `EFFECT_OVERLAY_REMOVE_COST_CHANGE_KOISHI` |
|
||||
| `EFFECT_REMOVE_LINK_MARKER_KOISHI` |
|
||||
| `EFFECT_REMOVE_SUMMON_TYPE_KOISHI` |
|
||||
| `GETEFFECT_ALL` |
|
||||
| `GETEFFECT_COPY` |
|
||||
| `GETEFFECT_GAIN` |
|
||||
| `GETEFFECT_GRANT` |
|
||||
| `GETEFFECT_INITIAL` |
|
||||
| `HINT_MUSIC` |
|
||||
| `HINT_MUSIC_OGG` |
|
||||
| `HINT_SOUND` |
|
||||
| `_WIN32` |
|
||||
@@ -0,0 +1,51 @@
|
||||
# `Group`
|
||||
|
||||
> Generated from `core/` by `contract/lua-reference/generate.py`; never edited by hand. Every function the core registers on `Group` is listed, and nothing else: a name that isn't here isn't in the core (the card scripts' `library/` defines the rest). A method is called on an object too (`c:IsCode(id)` is `Card.IsCode(c, id)`). *Arguments* is the fewest the core accepts, counting the object.
|
||||
|
||||
| Function | Arguments |
|
||||
|---|---|
|
||||
| `Group.AddCard` | 1 |
|
||||
| `Group.CancelableSelect` | 5 |
|
||||
| `Group.CheckWithSumEqual` | 5 |
|
||||
| `Group.CheckWithSumGreater` | 3 |
|
||||
| `Group.Clear` | 1 |
|
||||
| `Group.ClearMeta` | 1 |
|
||||
| `Group.Clone` | 1 |
|
||||
| `Group.CreateGroup` | any |
|
||||
| `Group.DeleteGroup` | 1 |
|
||||
| `Group.Equal` | 2 |
|
||||
| `Group.Filter` | 3 |
|
||||
| `Group.FilterCount` | 3 |
|
||||
| `Group.FilterSelect` | 6 |
|
||||
| `Group.FromCards` | any |
|
||||
| `Group.GetBinClassCount` | 2 |
|
||||
| `Group.GetClassCount` | 2 |
|
||||
| `Group.GetCount` | 1 |
|
||||
| `Group.GetFirst` | 1 |
|
||||
| `Group.GetMaxGroup` | 2 |
|
||||
| `Group.GetMetaKeys` | 1 |
|
||||
| `Group.GetMetaValue` | 2 |
|
||||
| `Group.GetMinGroup` | 2 |
|
||||
| `Group.GetNext` | 1 |
|
||||
| `Group.GetSum` | 2 |
|
||||
| `Group.HasMetaValue` | 2 |
|
||||
| `Group.IsContains` | 2 |
|
||||
| `Group.IsExists` | 4 |
|
||||
| `Group.KeepAlive` | 1 |
|
||||
| `Group.Merge` | 1 |
|
||||
| `Group.RandomSelect` | 3 |
|
||||
| `Group.Remove` | 3 |
|
||||
| `Group.RemoveCard` | 1 |
|
||||
| `Group.SearchCard` | 2 |
|
||||
| `Group.Select` | 5 |
|
||||
| `Group.SelectUnselect` | 3 |
|
||||
| `Group.SelectWithSumEqual` | 6 |
|
||||
| `Group.SelectWithSumGreater` | 4 |
|
||||
| `Group.SetMetaValue` | 3 |
|
||||
| `Group.Sub` | 1 |
|
||||
| `Group.__add` | 2 |
|
||||
| `Group.__band` | 2 |
|
||||
| `Group.__bor` | 2 |
|
||||
| `Group.__bxor` | 2 |
|
||||
| `Group.__len` | 1 |
|
||||
| `Group.__sub` | 2 |
|
||||
@@ -0,0 +1,112 @@
|
||||
#!/usr/bin/env python3
|
||||
# Writes the core's Lua API reference next to this script: one api-<class>.md per function table the
|
||||
# core registers with Lua (the luaL_Reg tables in core/lib*.cpp, named by the lua_setglobal that
|
||||
# follows each luaL_newlib) and api-globals.md for the globals interpreter.cpp sets. Ported from
|
||||
# yugioh-legacy-server's duel-engine/ocgcore/lua-reference.sh (bash + awk) so it runs on the Windows
|
||||
# build machine too. The committed copy is the contract; regenerate after any core change that touches
|
||||
# a lib*.cpp table and commit the result with it.
|
||||
# python contract/lua-reference/generate.py [<core dir>] [<out dir>]
|
||||
import re, sys
|
||||
from pathlib import Path
|
||||
|
||||
here = Path(__file__).resolve().parent
|
||||
core = Path(sys.argv[1]) if len(sys.argv) > 1 else here.parent.parent / "core"
|
||||
out = Path(sys.argv[2]) if len(sys.argv) > 2 else here
|
||||
|
||||
RE_FN = re.compile(r"^int32_t scriptlib::([a-z_0-9]+)\(")
|
||||
RE_ARGC = re.compile(r"check_param_count\(L, *([0-9]+)\)")
|
||||
RE_TABLE = re.compile(r"static const struct luaL_Reg ([a-z]+)\[\] *= *\{")
|
||||
RE_QUOTED = re.compile(r'"([^"]*)"')
|
||||
RE_NEWLIB = re.compile(r"luaL_newlib\(L, *([a-z]+)\)")
|
||||
RE_SETGLOBAL = re.compile(r'lua_setglobal\(L, *"([^"]*)"')
|
||||
|
||||
|
||||
def fail(msg):
|
||||
print("lua-reference: " + msg, file=sys.stderr)
|
||||
sys.exit(2)
|
||||
|
||||
|
||||
rows = set() # (class, name, cpp function, least arguments or "")
|
||||
for path in sorted(core.glob("lib*.cpp")):
|
||||
argc, entries, names, cls = {}, {}, {}, {}
|
||||
table = lib = fn = ""
|
||||
for raw in path.read_text(encoding="utf-8", errors="replace").splitlines():
|
||||
line = raw.rstrip("\r")
|
||||
m = RE_FN.match(line)
|
||||
if m:
|
||||
fn = m.group(1)
|
||||
m = RE_ARGC.search(line)
|
||||
if fn and m and fn not in argc:
|
||||
argc[fn] = m.group(1)
|
||||
m = RE_TABLE.search(line)
|
||||
if m:
|
||||
table = m.group(1)
|
||||
continue
|
||||
if table:
|
||||
if re.match(r"^[ \t]*(//.*)?$", line):
|
||||
continue
|
||||
if re.match(r"^[ \t]*#", line):
|
||||
fail("a preprocessor line inside " + table + ": " + line)
|
||||
if re.match(r"^[ \t]*\};", line):
|
||||
table = ""
|
||||
continue
|
||||
if "nullptr" in line:
|
||||
continue
|
||||
q = RE_QUOTED.search(line)
|
||||
if not q:
|
||||
fail("unreadable entry in " + table + ": " + line)
|
||||
f = re.sub(r"[^a-z_0-9].*", "", re.sub(r".*scriptlib::", "", line))
|
||||
entries[(table, q.group(1))] = f
|
||||
names.setdefault(table, []).append(q.group(1))
|
||||
continue
|
||||
m = RE_NEWLIB.search(line)
|
||||
if m:
|
||||
lib = m.group(1)
|
||||
m = RE_SETGLOBAL.search(line)
|
||||
if lib and m:
|
||||
cls[lib] = m.group(1)
|
||||
lib = ""
|
||||
for t, lst in names.items():
|
||||
if t not in cls:
|
||||
fail("no global for table " + t + " in " + path.name)
|
||||
for name in lst:
|
||||
f = entries[(t, name)]
|
||||
rows.add((cls[t], name, f, argc.get(f, "")))
|
||||
|
||||
if not rows:
|
||||
fail("no function tables found under " + str(core))
|
||||
|
||||
for old in out.glob("api-*.md"):
|
||||
old.unlink()
|
||||
|
||||
|
||||
def header(title, note):
|
||||
return ("# `" + title + "`\n\n> Generated from `core/` by `contract/lua-reference/generate.py`; "
|
||||
"never edited by hand. " + note + "\n\n")
|
||||
|
||||
|
||||
classes = sorted({r[0] for r in rows})
|
||||
for c in classes:
|
||||
lines = [header(c, "Every function the core registers on `" + c + "` is listed, and nothing else: a name "
|
||||
"that isn't here isn't in the core (the card scripts' `library/` defines the rest). A method is "
|
||||
"called on an object too (`c:IsCode(id)` is `Card.IsCode(c, id)`). *Arguments* is the fewest "
|
||||
"the core accepts, counting the object."),
|
||||
"| Function | Arguments |\n|---|---|\n"]
|
||||
for r in sorted(rows):
|
||||
if r[0] == c:
|
||||
lines.append("| `" + r[0] + "." + r[1] + "` | " + (r[3] or "any") + " |\n")
|
||||
(out / ("api-" + c.lower() + ".md")).write_text("".join(lines), encoding="utf-8", newline="\n")
|
||||
|
||||
globals_ = set()
|
||||
for raw in (core / "interpreter.cpp").read_text(encoding="utf-8", errors="replace").splitlines():
|
||||
if re.match(r"^\s*//", raw):
|
||||
continue
|
||||
m = re.search(r'lua_setglobal\(lua_state, *"([A-Za-z_0-9]*)"\)', raw)
|
||||
if m:
|
||||
globals_.add(m.group(1))
|
||||
lines = [header("Globals", "The values the core itself sets as Lua globals, beside the card scripts' `constant.lua`."),
|
||||
"| Global |\n|---|\n"]
|
||||
lines += ["| `" + g + "` |\n" for g in sorted(globals_)]
|
||||
(out / "api-globals.md").write_text("".join(lines), encoding="utf-8", newline="\n")
|
||||
|
||||
print("lua-reference: %d functions in %d tables, %d globals" % (len(rows), len(classes), len(globals_)), file=sys.stderr)
|
||||
Reference in new issue
Block a user