Skip to main content

Indie game storeFree gamesFun gamesHorror games
Game developmentAssetsComics
SalesBundles
Jobs
TagsGame Engines

Some questions I have about grids:
1. What are some ways that I could "lock," for lack of a better term, a column of a grid? I mean, I suspect I can use a format function to make it so that whenever a cell in that column gets changed to something else that it would replace the original letter, but I'm only half aware on how to pull that off and curious as to whether their exists a lock function for parts of a grid. But I digress.

2. Follow-up question to the first one, how would I rearrange the order of values in a column via button pressing? For example, changing the arrangement of values in a column, letters specifically, from alphabetical to by frequency, etc.

3. Is it possible to extract the values from a column in a grid and turn it into a string that can be used in dictionary functions?

If you give columns in a grid widget a format character of "L", "I", or "T", the column will not be user-editable. L displays cells in a column as plain strings (preformatted), I interprets cells as an icon index, and T displays cells as non-editable Rich Text.

Grids are containers for tables. To rearrange the rows of a table you probably want a query with an orderby clause. For example, sorting the contents of a grid "myGrid" by the "price" column, ascending, might require a button with a script like

on click do
 myGrid.value:select orderby price asc from myGrid.value
end

Note that the default order[] event handler for grids offers something like this out of the box; you could overload this on a grid-by-grid basis if you wanted more elaborate behavior:

on order col do
 if !me.locked
  me.value:select orderby me.value[col] asc from me.value
 end
end

If you have a column in a table, you can index it by name to get a list. The "fuse" operator can convert any list into a flat string:

myGrid.value.fruit
# ("cherry","banana","elderberry","apple","durian")
"" fuse myGrid.value.fruit
# "cherrybananaelderberryappledurian"
"|" fuse myGrid.value.fruit
# cherry|banana|elderberry|apple|durian