For the past month, I have been doing a bit of adding some features to the game initialization script.
https://github.com/vaut/wz-spec-mod
From features made:
- adding greetings with the settings.
- hint to players where the oil towers are located
Spoiler:
Future plans
- winner determination refactor
- output of extended information about the past game
- processing technology output depending on the starting settings. (creating at the beginning of the game a list of technologies sorted by opening time. And replacing magic constants with the time of the game).
I am waiting for more ideas what else can should be changed in the initialization of the game. If there are no comments on the implemented features, I will cut the operating time into patches and send pullrequests.
I would also like to talk a bit about scripting. If my complaints are not substantiated or require a lot of work to eliminate, I ask you to write about this honestly.
And I had some pretty serious problems writing clean code. This is mainly the use of global functions and variables.
Take for example the syntax
queue (function [, milliseconds [, object]])
requires
1) creating a global function so that it can be called.
2) creation of global variables if parameters need to be passed to it.
As a result, for every one we have to create new global objects.
At the same time, if I'm not mistaken, setReticuleButton (id, filename, filenameHigh, tooltip, callback) in callback normally accepts a function.
The interpreter does not support Getters and Setters, which makes the code more cumbersome.
Also, a lot of blood spoiled me due to the lack of clarification of what this or that function expects to see coordinates:
As a result, magical multiplications by 128 appeared:
struct = addStructure ("A0ResourceExtractor", scavengerPlayer, oil.x * 128, oil.y * 128).
(there is a shift in the structure by less than a cell, but no turn)
Or addSpotter () which part of the arguments is waiting in the tile, part in small squares.
I understand that changing the syntax of previously created commands will require a lot of refactoring.
But at the moment, we can assume that 99% js of the code in the master version.
There are almost no third-party mods that break due to syntax changes. They are already broken by changes: 3.1.x -> 3.2.x -> 3.3.0 -> master
I hope that only those who can fool the game without a hint will read it here. I ask the moderators if they consider the further text dangerous to delete it.
Physfs currently in use searches for files in many places.
After searching for the file in base.wz and mp.wz he searches in mod, then the map and there are two more places from where he will read it. These two places make it easy to override any file.
Theoretically, at the beginning of the game, you can check the checksums of all resources and disable the player if there is a modification. And it works with /stats/
But not all files are checked. This makes it very easy for an attacker to execute third-party code.
For example, many well-known overlay for streams with stat display is based on this. The game does not require modification.
This is precisely what prevents the observers from gaining player status. This code can be used for illegal purposes in ordinary games...