Data

Data objects let you store lists of data. Each item in the list is separated by a space. You can see the basic structure in the first example. Unlike most SCL code, you must start your data on the line that follows "set" and your data ends with "end" being alone on the last line of the "create data" command.

To access your data you can use a number of commands such as "next", "select", "pluck" or "prev". Data is accessed in many ways. A very convenient way is in the order that the data appears in the list. In this way you can simply access each member of the list using "next". For example:

create data from list as BirdStats
set
    10 10 50 50 90 90
end
create routine SetStuff
    clone from bird using original
    update sprite _clone where x=data.BirdStats.next
    update sprite _clone where y=data.BirdStats.next
    clone from bird using original
    update sprite _clone where x=data.BirdStats.next
    update sprite _clone where y=data.BirdStats.next
    clone from bird using original
    update sprite _clone where x=data.BirdStats.next
    update sprite _clone where y=data.BirdStats.next
end

The code above creates three birds whose positions are determined by walking through the BirdStats data list. You could also use data.BirdStats.select to choose random positions from the list.

"pluck" and "select" choose a random value from the list except that "pluck" will never re-use a value.

You can treat your list as rows and columns by skipping. Skip by appending a number to your access command. For example, data.myList.next.3 will skip to the third item. You can combine access commands and skip values to support row/column access. See the second example.

See here for more about handling data

Next

A basic example showing how to move through a list one entry at a time.


editable

Pluck and skipping

Uses two lists to demonstrate randomly pulling images such that no image will be used twice (called 'plucking').
Also demonstrates how to skip entries to simulate row/column behaviour. In the example below, the coors list consists of rows equaling: x,y,degree (but don't use commas in the lists).


editable