arx-insanity / ArxLibertatis

Cross-platform port of Arx Fatalis, a first-person role-playing game
https://arx-libertatis.org/
GNU General Public License v3.0
3 stars 0 forks source link

add push/pop/shift/unshift commands to manage space separated strings, like ^$objontop #8

Closed meszaros-lajos-gyorgy closed 1 year ago

meszaros-lajos-gyorgy commented 2 years ago

This would allow managing space separated strings, like ^$objontop much easier.

Example codes on what to implement:

// remove 1 element from the end of a space separated string and load it into a variable
SET $x ""
SET $array "aaa bbb ccc"

POP $x $array

HEROSAY $x // "ccc"
HEROSAY $array // "aaa bbb"
// add 1 element to the end of a space separated string
SET $x "ddd"
SET $array "aaa bbb ccc"

PUSH $array $x

HEROSAY $x // "ddd"
HEROSAY $array // "aaa bbb ccc ddd"
// add 1 element to the beginning of a space separated string
SET $x "ddd"
SET $array "aaa bbb ccc"

SHIFT $array $x

HEROSAY $x // "ddd"
HEROSAY $array // "ddd aaa bbb ccc"
// remove 1 element from the beginning of a space separated string and load it into a variable
SET $x ""
SET $array "aaa bbb ccc"

UNSHIFT $x $array

HEROSAY $x // "aaa"
HEROSAY $array // "bbb ccc"
meszaros-lajos-gyorgy commented 2 years ago

Quote from Dscharrer: (source: https://arx-libertatis.org/irclogs/2022/%23arx.2022-06-16.log)

I think all other commands that modify a variable have the variable as the first argument so we should try to keep that so that would be pop $x $array and push $array $x hm, I guess pop modifies both though alternate command syntax should be a separate change, and maybe makes more sense after we have a parser

meszaros-lajos-gyorgy commented 2 years ago

note to self regarding that lvalue rvalue nonsense: https://www.youtube.com/watch?v=fbYknr-HPYE

meszaros-lajos-gyorgy commented 1 year ago

not related to arx insanity