Not logged inOpenClonk Forum
Up Topic Development / Scenario & Object Development / Growing the C4Script standard library
- - By Günther [de] Date 2011-01-15 22:32
When we introduced arrays, we intentionally didn't add a lot of functions that worked on them, since we wanted to gather some experience on how they were used first. Well, that experience should be available now, but I don't have it myself. What I remember being requested are functions to sort and append to an array. There's probably also a use for a deep comparison function (one that returns true when comparing two distinct arrays/proplists with the same contents). Are there other commonly used functions that should be documented and/or moved into the engine?
Reply
Parent - - By Newton [de] Date 2011-01-15 23:31
Do you only mean functions that work on arrays or also mean functions that work with arrays? For example we got (a lot?) of stuff like
for(var i=0,j; i=GetPlayerByIndex(j);++i)
which could also be written like this if a function were available (like FindObjects):
for(var player in GetPlayers())

Just from the top of my head, there would at least be stuff for player, inventory, crew(?). But if the introduction makes sense, is another question. To add functions that work on arrays, like you suggest, probably make a lot more sense first.

------------

However, I think I never stumbled upon any function for arrays I missed so far in my implementation work.

------------

>Are there other commonly used functions that should be documented and/or moved into the engine?


Why moved to the engine? What's wrong about System.c4g?
Parent - - By Gurkenglas [de] Date 2011-01-15 23:36
I heard, to implement something in the engine rather than in the System.c4g leads to a better performance. Dunno why or who said this, maybe because this way you dont have to parse the System.c4g every time.
Reply
Parent - - By Newton [de] Date 2011-01-15 23:39
If performance was the #1 goal, everything would be in C++ and there would be no C4Script.
Parent - By Zapper [de] Date 2011-01-16 00:24
That does not mean that we should not use the engine for stuff it is perfect for (C4Script-language internal features that will most likely never need a change - that is in this case).
Parent - By Günther [de] Date 2011-01-16 00:22
Some functions which could be implemented in script really need to be in the engine for performance reasons. (FindObjects could be replaced with script and a function which just returned a list of all objects, but it'd be unplayable.) GetPlayers is not one of them, but it probably makes more sense to make GetPlayers be the engine function and remove GetPlayersByIndex at some later point. The same for the other lists.
Reply
Up Topic Development / Scenario & Object Development / Growing the C4Script standard library

Powered by mwForum 2.29.7 © 1999-2015 Markus Wichitill