Carpet

Carpet

2M Downloads

[Scarpet] [Discussion] Some functions should be in system_info()

altrisi opened this issue ยท 9 comments

commented

This is a list of some functions that just return that: Information about the system.

I'd say those could be moved into the system_info() function to remove the amount of individual info functions, just like what happened with seed():

Link: Current system_info() functions
Link: Class that gets system_info() data

  • view_distance() -> system_info('game_view_distance')
    This one is actually already in system_info(), it's duplicated, and the standalone one could be deprecated
  • unix_time() -> system_info('server_unix_time')?
    I'd say it's definitely system info
  • tick_time() -> system_info('server_tick_time')?
    Not sure about the scope and names of this and next. Don't really know what they do/difference
  • world_time() -> system_info('world_time')?
    Not sure about the scope and names of this and previous. Don't really know what they do/difference
  • last_tick_times() -> system_info('server_last_tick_times')?

These are just suggestions, maybe the most used ones shouldn't be moved.

Open to discussion and suggestions if others should be moved, or if some shouldn't.

This list doesn't include functions with parameters since system_info() doesn't currently have anything with extra parameters, those could maybe be returned in a long list, but that would also mean more changes.

commented

ihmo system_info was a good idea - removing the mental load of keeping track of rarely useful readonly information to one function.

for that reason I think view distance should be deprecated and moved.
same with world_time - you probably don't want to use that, same for last_tick_times

tick_time and unix_time - I would leave as universal functions that one would use often.

And yes, I wouldn't remove the other functions, just mark them deprecated in code, docs with a pointer to system_info and remove after next major version (so carpet 1.16, whenever that is)

commented

History about this in Discord (1 message, but more than nothing):

commented

I would not want tick_time() in system_info()
i use it a lot for executing thins every couple of ticks, and it would looks a lot messier with system_info

__on_tick() -> (
    if(tick_time()%20 == 0,
        ...
    );
);

view distance can definetly go there, not sure about the rest tho

commented

I would say don't remove the previous commands, cos people may have used them. Also cos then they would have to query system_info evry tick which would be super intensive to parse all that info evry time.

commented

Not really, system_info is (almost?) as performant as a standalone function, just it exists inside another one (it initializes a map with all functions, consisting of their name and the code to run, and when called runs the chosen one from the map, doesn't initialize them every time).

And of course the already existing functions would be kept, at least temporarily, just like seed() still exists but is deprecated.

commented

but then y did u tell me here:

I can't remember how costly was world_scarpet_rules, to suggest adding it after checking the block maybe to prevent running it on every block placed.

commented

Because world_scarpet_rules loops through all SettingsManagers from all extensions, then loops through all rules from each of those and then gets every value (not because all other system_info is called)

commented

postulate deprecation of view_distance(), world_time and last_tick_times as a valid efford of cleaning up the built-in function space and moving them to `system_info: 'world_view_distance', 'world_time', and 'server_tick_times'

commented

I concurr