Open nathan130200 opened 2 years ago
I forgot to reply but this is basically the AST macro thing I've had in my head for a while (I made a mistake following C's path, lul)
I think I will replace #!defineMember
by "A.B", basically if the define name has a dot, assume the first member is the type and the second is the name.
The multi-line macros will use inline def
, however I gotta think about the single-line macros, I thought about inline lambda somefunc(x): x+2
but it clashes with python's lambda syntax where the function name isn't specified. And for constants, inline const DEBUG_MODE = true
.
Thanks for reply, yeah i suggest for some complex macros that we must transfer variable name to invocation.
For example #!defineMember isPlayerValidForScoring(condition) eventPlayer.someVar == true
we can use eventPlayer
as usually but when i will invoke this macro on attacker
/victim
values will not work.
So for replacement we can transfer direct variable name #!defineMacro myFunc(param1, param2) this.param3 = [param1, param2]
where this.
is everything before .
after invoke this macro.
So: eventPlayer.botEntity.myFunc(1, 2)
, this.
will be translated as eventPlayer.botEntity
Or something similar to match with overpy syntax.
Also offtopic/non related to this suggestion is declare temporary variable names for for loop
reserve an global/player variable called _opyForLoopIndexex
when all non declared variables to for loop will automatically grab an index, then use While(...)
and End;
to peform an looping. Its like OSTW does but more simple
TL;DR
An way to declare arguments in #!defineMember like macros, introducing (new keyword? "macro") or using subroutines like declaration
def
, with explicit types where macro should apply.Detailed
New feature that will have 3rd param in #!defineMember ` so we can call
Structure:
#!defineMember <name> simple_expression|(complex expression) <type?>
Where:#!defineMember myX x Vector
(create membermyX
onVector
that reflect tox
component)#!defineMember isValidPlayer (__this__.isAlive() and not __this__.isDummy()) Player
Example:
#!defineMember tpToCenter (teleport(__this__, vect(0, 0, 0))) Player
__this__
will refer who is calling that macro and will replace value. Examples:myDummyBot.tpToCenter()
value in__this__
will be replaced bymyDummyBot
victim.tpToCenter()
->__this__
->victim
Z.tpToCenter()
-> error:Z
isVariable
, notPlayer
type. Except iftpToCenter
acceptObject
type, that means a generic value.Another example:
#!defineMember isBetterTargetToKill (__this__.getNormalizedHealth() <= 10) Player
, since its a complex call, we must put inside on(
...expression
...) <type?> (optional)
And if possible declaring params like virtual functions in
#!defineMember
or new preprocessorNotes
macro
keyword can be same way in subroutines usingdef
keyword.def
can have annotation@Macro
to identify as macro, so if not@Name
isn't subroutinekeepOnPayload(self: Player):
like in python typpings.Where
self
is value to current 'injected' value. In this exampleself
refer to player that invoked.self
=eventPlayer
for example.So we can attach and call dynamic macro that will be translated as actions: