euddraft
euddraft copied to clipboard
eudplib modularization and add star import to epScript
translated from: https://cafe.naver.com/edac/126996
Currently, there are a whopping 588 imports by from eudplib import *
.
We've decided to separate rarely used or too advanced features into separate modules, using
from eudplib.modulename import *
or from eudplib import modulename as alias
.
We're going to change this so that you have to import them separately to use them.
For now, we're going to make sure that features that can be used natively without importing We're considering changing some of the lesser-used features to require imports in the future.
Currently, from eudplib import *
imports every items in eudplib, including features for map creators, library/plugin creators, and map-related tool creators. They are imported all at once without splitting modules.
It is not easy for users to avoid from eudplib import *
and only import desired parts of eudplib, because of the Python circular import problem or because it is categorized by eudplib creator.
Already in eudplib, there are eudplib.trigtrg
and eudplib.offsetmap
modules.
Both of them are advanced features, so you have to import them separately to use them.
I'm going to extend this further.
(I won't do it right away in the next version, it takes a while to bundle related functions together).
(added in 24.09.05) memio
, string
, qgc
modules are already separated from eudlib
module since euddraft 0.9.11.0 (eudplib 0.77.4).
I'm a little cautious about breaking backwards compatibility. If you take the example of creating an autocomplete feature in another tool like eps-server or EUD Editor 3. If 588 features are proposed all at once by autocompletion, the autocompletion doesn't effectively propose what you need in practice. Of course the tool creator could mitigate this by adding priority of suggestion to improve the quality of the suggestions, but it's hard to remove everything that's available from the suggestions, so still listing every 588 items in suggestion is the current situation.
We're going to write a migration guide to make it as easy as possible to modify existing crafting maps, and we're going to be as thoughtful as possible. I would appreciate it if you could share your concerns about this or your own use cases in the comments.
This is just a small list of features that I think shouldn't be imported with from eudplib import *.
- Functions that are only used at most once per map: CompressPayload, ShufflePayload, EP_SetRValueStrictMode, EPS_SetDebug,
- eudplib core.allocator functions: ConstExpr, EUDObject, GetObjectAddr, RlocInt, RegisterCreatePayloadCallback, toRlocInt, Forward, CreatePayload, etc.
- eudplib core.eudfunc functions: EUDFullFunc, EUDFuncN, EUDTracedFunc, EUDTracedMethod, EUDTracedTypedFunc, EUDTracedTypedMethod, EUDTraceLog, EUDXTypedFunc
- eudplib Namespace functions: EUDClearNamespace, EUDRegistered, EUDRegisterObjectToNamespace, GetEUDNamespace
- Library/plugin related functions: IsMapdataInitialized, TBL, GetPlayerInfo, etc.
- Type conversion redundant functions: EncodeWeapon (=Weapon.cast), EncodeUpgrade (=Upgrade.cast), GetLocationIndex, etPropertyIndex, GetStringIndex, GetSwitchIndex, GetUnitIndex, etc.
- Advanced functions: Action, Condition, EUDLightBool, EUDLightVariable, EUDXVariable, EUDIsContinuePointSet, EUDSetContinuePoint, EPSLoader, epsCompile, EUDLoopList
- Features not supported in the remaster: EUDLoopBullet, EUDGrp, etc.
- All QueueGameCommand Functions
Below is a complete list of what eudplib currently imports with star import.
P1, P2, P3, P4, P5, P6, P7, P8, P9, P10, P11, P12
TBL, Accumulate, Action, Add
AddCurrentPlayer, All, AlliedVictory, Allies
AllPlayers, Ally, Always, AtLeast
AtMost, Attack, Bring, Buildings
CenterView, Clear, Cleared, Command
CommandLeast, CommandLeastAt, CommandMost, CommandMostAt
Comment, CompressPayload, Condition, ConstExpr
CountdownTimer, CreatePayload, CreateUnit, CreateUnitWithProperties
CurrentPlayer, Custom, Db, Deaths
DeathsX, Defeat, Disable, Disabled
DisplayText, Draw, ElapsedTime, Enable
EncodeAIScript, EncodeAllyStatus, EncodeComparison, EncodeCount
EncodeFlingy, EncodeIcon, EncodeImage, EncodeIscript
EncodeLocation, EncodeModifier, EncodeOrder, EncodePlayer
EncodePortrait, EncodeProperty, EncodePropState, EncodeResource
EncodeScore, EncodeSprite, EncodeString, EncodeSwitch
EncodeSwitchAction, EncodeSwitchState, EncodeTBL, EncodeTech
EncodeUnit, EncodeUnitOrder, EncodeUpgrade, EncodeWeapon
Enemy, EP_SetRValueStrictMode, EUDClearNamespace, EUDCreateVariables
EUDFullFunc, EUDFunc, EUDFuncN, EUDFuncPtr
EUDLightBool, EUDLightVariable, EUDMethod, EUDObject
EUDRegistered, EUDRegisterObjectToNamespace, EUDReturn, EUDStruct
EUDTracedFunc, EUDTracedMethod, EUDTracedTypedFunc, EUDTracedTypedMethod
EUDTraceLog, EUDTypedFunc, EUDTypedFuncPtr, EUDTypedMethod
EUDVariable, EUDVArray, EUDXTypedFunc, EUDXVariable
Evaluate, Exactly, Flingy, Foes
Force1, Force2, Force3, Force4
Forward, Gas, GetChkTokenized, GetEUDNamespace
GetLocationIndex, GetObjectAddr, GetPlayerInfo, GetPropertyIndex
GetStringIndex, GetSwitchIndex, GetTraceStackDepth, GetTriggerCounter
GetUnitIndex, GiveUnits, HighestScore, Icon
Image, IsConstExpr, Iscript, IsEUDVariable
IsMapdataInitialized, Kills, KillsAndRazings, KillUnit
KillUnitAt, LeaderBoardComputerPlayers, LeaderBoardControl, LeaderBoardControlAt
LeaderBoardGoalControl, LeaderBoardGoalControlAt, LeaderBoardGoalKills, LeaderBoardGoalResources
LeaderBoardGoalScore, LeaderBoardGreed, LeaderBoardKills, LeaderBoardResources
LeaderBoardScore, LeastKills, LeastResources, LowestScore
Memory, MemoryEPD, MemoryX, MemoryXEPD
MinimapPing, ModifyUnitEnergy, ModifyUnitHangarCount, ModifyUnitHitPoints
ModifyUnitResourceAmount, ModifyUnitShields, MostKills, MostResources
Move, MoveLocation, MoveUnit, MuteUnitSpeech
NeutralPlayers, Never, NextTrigger, NonAlliedVictoryPlayers
NonSeqCompute, Opponents, Order, Ore
OreAndGas, Patrol, PauseGame, PauseTimer
Player1, Player2, Player3, Player4
Player5, Player6, Player7, Player8
Player9, Player10, Player11, Player12
PlayWAV, PopTriggerScope, Portrait, PreserveTrigger
PushTriggerScope, Random, RawTrigger, Razings
RegisterCreatePayloadCallback, RemoveUnit, RemoveUnitAt, RlocInt
RlocInt_C, RunAIScript, RunAIScriptAt, Score
SeqCompute, Set, SetAllianceStatus, SetCountdownTimer
SetCurrentPlayer, SetDeaths, SetDeathsX, SetDoodadState
SetInvincibility, SetKills, SetMemory, SetMemoryEPD
SetMemoryX, SetMemoryXEPD, SetMissionObjectives, SetNextPtr
SetNextScenario, SetNextTrigger, SetResources, SetScore
SetSwitch, SetTo, SetVariables, ShufflePayload
Sprite, StatText, Subtract, Switch
TalkingPortrait, Tech, Toggle, Total
Transmission, TrgAIScript, TrgAllyStatus, TrgComparison
TrgCount, TrgLocation, TrgModifier, TrgOrder
TrgPlayer, TrgProperty, TrgPropState, TrgResource
TrgScore, TrgString, TrgSwitch, TrgSwitchAction
TrgSwitchState, TrgUnit, UnitOrder, UnitProperty
Units, UnitsAndBuildings, UnMuteUnitSpeech, UnpauseGame
UnpauseTimer, Upgrade, Victory, VProc
Wait, Weapon, f_bitand, f_bitlshift
f_bitnand, f_bitnor, f_bitnot, f_bitnxor
f_bitor, f_bitrshift, f_bitsplit, f_bitxor
f_div, f_mul, selftype, toRlocInt
DoActions, EUDJump, EUDJumpIf, EUDJumpIfNot
EUDTernary, EUDBreak, EUDBreakIf, EUDBreakIfNot
EUDContinue, EUDContinueIf, EUDContinueIfNot, EUDIsContinuePointSet
EUDSetContinuePoint, CtrlStruOpener, EUDEndInfLoop, EUDEndLoopN
EUDEndWhile, EUDInfLoop, EUDLoopN, EUDLoopRange
EUDWhile, EUDWhileNot, EUDSCAnd, EUDSCOr
EUDElse, EUDElseIf, EUDElseIfNot, EUDEndExecuteOnce
EUDEndIf, EUDExecuteOnce, EUDIf, EUDIfNot
EPDSwitch, EUDEndSwitch, EUDSwitch, EUDSwitchCase
EUDSwitchDefault, EPS_SetDebug, EPSLoader, IsSCDBMap
epsCompile, EUDArray, EUDGrp, EUDDeque
EUDQueue, EUDStack, f_addloc, f_dilateloc
f_getlocTL, f_setloc, f_setloc_epd, f_atan2
f_atan2_256, f_div_euclid, f_div_floor, f_div_towards_zero
f_lengthdir, f_lengthdir_256, f_pow, f_sqrt
CPByteWriter, EUDByteReader, EUDByteStream, EUDByteWriter
EUDVArrayReader, f_addcurpl, f_badd_epd, f_bread
f_bread_cp, f_bread_epd, f_bsubtract_epd, f_bwrite
f_bwrite_cp, f_bwrite_epd, f_cunitepdread_cp, f_cunitepdread_epd
f_cunitread_cp, f_cunitread_epd, f_dwadd_cp, f_dwadd_epd
f_dwbreak, f_dwbreak2, f_dwepdread_cp, f_dwepdread_epd
f_dwepdread_epd_safe, f_dwread, f_dwread_cp, f_dwread_epd
f_dwread_epd_safe, f_dwsubtract_cp, f_dwsubtract_epd, f_dwwrite
f_dwwrite_cp, f_dwwrite_epd, f_epdcunitread_cp, f_epdcunitread_epd
f_epdread_cp, f_epdread_epd, f_epdread_epd_safe, f_epdspriteread_cp
f_epdspriteread_epd, f_flagread_epd, f_getcurpl, f_maskread_cp
f_maskread_epd, f_maskwrite_cp, f_maskwrite_epd, f_memcmp
f_memcpy, f_posread_cp, f_posread_epd, f_readgen_cp
f_readgen_epd, f_repmovsd_epd, f_setcurpl, f_setcurpl2cpcache
f_spriteepdread_cp, f_spriteepdread_epd, f_spriteread_cp, f_spriteread_epd
f_wadd_epd, f_wread, f_wread_cp, f_wread_epd
f_wsubtract_epd, f_wwrite, f_wwrite_cp, f_wwrite_epd
PVariable, QueueGameCommand, QueueGameCommand_AddSelect, QueueGameCommand_MergeArchon
QueueGameCommand_MergeDarkArchon, QueueGameCommand_MinimapPing, QueueGameCommand_PauseGame, QueueGameCommand_QueuedRightClick
QueueGameCommand_RemoveSelect, QueueGameCommand_RestartGame, QueueGameCommand_ResumeGame, QueueGameCommand_RightClick
QueueGameCommand_Select, QueueGameCommand_TrainUnit, QueueGameCommand_UseCheat, FixedText
PColor, PName, f_cpstr_adddw, f_cpstr_addptr
f_cpstr_print, f_eprintln, f_gettextptr, f_raise_CCMU
CPString, GetMapStringAddr, f_cp949_to_utf8_cpy, DBString
epd2s, f_dbstr_adddw, f_dbstr_addptr, f_dbstr_addstr
f_dbstr_addstr_epd, f_dbstr_print, hptr, ptr2s
f_eprintAll, f_eprintf, f_sprintf, f_sprintf_cp
LocalLocale, f_parse, IsPName, SetPName
SetPNamef, DisplayTextAllAt, f_printAll, f_printAllAt
DisplayTextAt, GetGlobalStringBuffer, StringBuffer, f_printAt
f_println, f_simpleprint, f_strcmp, f_strcpy
f_strlen, f_strlen_epd, f_strnstr, GetTBLAddr
f_eprintln2, f_settbl, f_settbl2, f_settblf
f_settblf2, TextFX_FadeIn, TextFX_FadeOut, TextFX_Remove
TextFX_SetTimer, f_cpchar_adddw, f_cpchar_print, UnitGroup
CenterViewAll, DisplayTextAll, EUDAnd, EUDBinaryMax
EUDBinaryMin, EUDEndPlayerLoop, EUDLoopBullet, EUDLoopCUnit
EUDLoopList, EUDLoopNewCUnit, EUDLoopNewUnit, EUDLoopPlayer
EUDLoopPlayerCUnit, EUDLoopPlayerUnit, EUDLoopSprite, EUDLoopTrigger
EUDLoopUnit, EUDLoopUnit2, EUDNot, EUDOr
EUDPlayerLoop, IsUserCP, MinimapPingAll, PlayWAVAll
SetMissionObjectivesAll, TalkingPortraitAll, f_blockpatch_epd, f_dwpatch_epd
f_dwrand, f_getgametick, f_getseed, f_getuserplayerid
f_playerexist, f_rand, f_randomize, f_srand
f_unpatchall, InitialWireframe, Is64BitWireframe, SetGrpWire
SetTranWire, SetWirefram, SetWireframes, PRT_SkipPayloadRelocator
EUDDoEvents, EUDOnStart, PRT_SetInliningRate, LoadMap
MPQAddFile, MPQAddWave, MPQCheckFile, SaveMap
CSprite, CUnit, EPDCUnitMap, EUDBranch
PTrigger, Trigger, GetFirstTrigTrigger, GetLastTrigTrigger
RunTrigTrigger, TrigTriggerBegin, TrigTriggerEnd, b2i1
b2i2, b2i4, bits, i2b1
i2b2, i2b4, EUDCreateBlock, EUDGetBlockList
EUDGetLastBlock, EUDGetLastBlockOfName, EUDPeekBlock, EUDPopBlock
EPError, EPWarning, TriggerScopeError, ep_assert
ep_eprint, ep_warn, EPD, Assignable2List
FlattenList, List2Assignable, SCMD2Text, cachedfunc
find_data_file, ExprProxy, isUnproxyInstance, unProxy
b2u, b2utf8, u2b, u2utf8
I think the cleanest way to fix the source would be to just write import eudplib.modulename.*;
in epScript so that it's a seamless transition from the existing map, so I'm thinking that the glob import (from a import *
) feature for epScript should be introduced first.