You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Currently context scripts use a mix of explicit character variables and implicit event variables in their scope. E.g. player.inventory.remove(item.id) rather than inventory.remove(dropEvent.item.id).
Currently a piece of player looks like:
But there's a strong argument to be made for a more implicit style where the player is not called directly.
This is shorter and simple to understand from a reading perspective but introduces ambiguity, for example, given the example above
Is inventory referring to the player's inventory or the inventory id in the InventoryOption event?
It's not clear.
If both variables have the same name then even the compiler will warn about issues, this means that all variables would have to have distinct names within a shared scope.
Or how about: given a few lines in isolation, you don't know if it's being applied to a Player or an NPC without finding the top of the function it is located in.
start("timer", 1)
setAnimation("wave")
RuneScript uses the implicit method and it seems to work, it's a tricky decision. It's hard to know without trying the alternative (implicit) which will be better, but switching will bring a lot change and risk so for now I'm putting my thoughts here and seeing what other people might think.
Which do you prefer? Explicit or implicit?
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
-
Currently context scripts use a mix of explicit character variables and implicit event variables in their scope. E.g.
player.inventory.remove(item.id)
rather thaninventory.remove(dropEvent.item.id)
.Currently a piece of player looks like:
But there's a strong argument to be made for a more implicit style where the player is not called directly.
This is shorter and simple to understand from a reading perspective but introduces ambiguity, for example, given the example above
Is
inventory
referring to the player's inventory or the inventory id in the InventoryOption event?It's not clear.
If both variables have the same name then even the compiler will warn about issues, this means that all variables would have to have distinct names within a shared scope.
Or how about: given a few lines in isolation, you don't know if it's being applied to a Player or an NPC without finding the top of the function it is located in.
RuneScript uses the implicit method and it seems to work, it's a tricky decision. It's hard to know without trying the alternative (implicit) which will be better, but switching will bring a lot change and risk so for now I'm putting my thoughts here and seeing what other people might think.
Which do you prefer? Explicit or implicit?
Beta Was this translation helpful? Give feedback.
All reactions