A recent discussion in chat about scripting finally prompted me to write down my thoughts on improving the scripting engine. My general aim was to make scripting a bit more user friendly, as well as to provide more functionality. It does not necessarily list all specific features I could think of. Therefore, if you have any suggestions that would fit in well, please post them below.
Now I don't imagine all of these ideas to be feasible for a near future release. I did try to keep things as compatible with the current engine as possible. However, I do not have any intimate knowledge about the code behind it, so the devs will have to be the judge of that.
And now, without further ado, we move on to the meat of the matter.
Control Flow
The way the if statement works feels unlike the way an if should work, and looks confusing in statements such as "
If... wait for entity Player at (1,1)-(1,1)"
. I suggest renaming the existing "
If"
function to "
Try"
and redesigning "
If"
to only take logical tests. These tests would include the ones you find among the "
wait for"
commands. There should also be a negation option for the test.
Commands providing further structure would be nice. As suggested elsewhere, an "
Else if"
would help to make scripts more concise. Proper For and While loops are appealing too, but they may not go well together with the Label/Goto structuring that is used, so I understand if this is infeasible.
Manipulate Self
Imperatives
I think it makes more sense to have "
End on room exit"
as an imperative, because it is more a property of an NPC than a command that fits in the flow of the script.
Moving
It would be useful if an NPC could execute a command after moving, but currently many such commands automatically end the turn. I would also suggest to make a clear distinction between three types of moves:
1) Single step moves - These are the traditional moves entities such as the player and monsters can make, i.e. a step in one of 8 directions or a rotation. These moves relate to physical motion (as opposed to teleportation), so they obey all direction based mechanics such as force arrows and pushing. These moves do not end the turn, in case the NPC needs to react to a result of that move.
2) Teleportation / Reorientation - commands that, regardless where the NPC is, make it reappear in a different spot or change its orientation. Should work as the current teleportation commands (once they have been fixed). This means they do not end the turn and ignore direction based mechanics.
3) Multi-step moves - shorthands for a sequence of moves, which only end when a specific goal is reached. They are the only ones that automatically end a turn, and only out of necessity. Otherwise each step is equivalent to a single step move.
Additionally, you could introduce a specific "
End turn"
command for user friendliness (of course "
Wait 0"
would do the trick as well, but is less obvious).
Waiting
There is a shipload of "
Wait for"
commands, that can all be merged into one. Just let them have the same argument as an if statement (see explanation above). Again include a negation option to reproduce and expand on the "
Wait until"
commands.
Manipulate Player
For consistency with other commands, rename "
Player role"
to "
Set player role"
. Besides "
Teleport player to"
, there should also be a "
Set player orientation"
, similar to NPC orientation. I'm not sure it would be wise to have functions modifying the invisibility and speed of a player, but it might be useful.
Manipulate Room
The command "
Attack tile"
could use more types of attack. Suggestions are (some of them from other people):
- Fall
- Drown
- Stun (this turn only)
- Stun (this turn and next)
- Push + direction
Variables
One of the most important missing features is that all functions should be allowed to take variables as arguments naturally. The _MyScript variables are an ugly hack, that should have never existed.
Considering the features I suggested earlier, you could very well make the predefined "
_"
variables read-only. The ability to change them is only there to cover up the lack of more intuitive commands that achieve the same effect.
Suggestions for other predefined variables:
_MyVisibility (bool) NPC visibility
_MyAppearance NPC appearance
_PlayerRole player role
_PlayerSpeed (bool) player is under influence of speed potion
_PlayerInvisible (bool) player is under influence of invisibility potion
_KeyboardInput key pressed this turn
_Turn current turn number
_SpawnCycle turn number within the spawn cycle (figure something out for half turns)
_RoomClean (bool) room has been cleared
_LevelClean (bool) level has been cleared
Obviously many of these rely on the fact that they would be read-only. A few of these also allow you to ditch some logical conditions for if statements.
Queries
One thing that had been significantly lacking is the ability to get very specific information about a room. With the "
Wait for entity (type)"
and "
Wait for item"
commands, now we have more than ever the freedom to see what is on a square, but they are not entirely comprehensive. There is no way to detect for arrows or swords, nor can you get information about orientation. Part of this can be resolved through expanding the list of items you can check for in logic tests.
Furthermore it would be nice to have a set of "
Get"
commands that takes some user variables as arguments and stores some piece of information in them. For example:
Distance from (x1,y1) to (x2,y2) can use beelining/brained/NPC pathmapping/etc...
Location of natural target natural target as suggested elsewhere on the forum
Entity at (x,y) returns some number corresponding to entity occupying (x,y)
Terrain at (x,y) same for terrain
Object at (x,y) idem
Arrow direction at (x,y) returns direction of arrow if there is one, otherwise -1(?)
Readability
A lot of commands take a number as argument that is a placeholder for another concept, such as a direction or orientation. It would be nice if we could use keywords instead of numbers enum style, e.g. type "
N"
as orientation and have it automatically be interpreted as 1. In addition, commands where you select a keyword from a menu as argument could also take a number instead. That way you can pass information such as an entity type to a function through variables.
____________________________
Holds:
An Architects Audition,
Artful Architecture,
Salamander,
Elusive Exhibitions,
Leftover Levels,
Six Times Six
Collaborative:
Way Forward,
Advanced Concepts 2
Styles/Mods:
Basalt,
Sandstone,
Garden,
Clock using game elements