Never been to DZone Snippets before?

Snippets is a public source code repository. Easily build up your personal collection of code snippets, categorize them with tags / keywords, and share them with the world

script an object using bind (See related posts)

Suppose you have a robot object with methods like
move , attack etc. You can store a "script" in a block to automate the object

rebol []

robot: make object! [
move: func [amount] [...] ; whatever
turn: func [angle][..] 
fire: func [] [...]
run: func [code][
                   do bind code 'self
]
]

script: [
           move 100
           turn 45
           fire
           turn 23
           move 34
]
; etc

robbie: make robot []

robbie/run script


You need to create an account or log in to post comments to this site.


Click here to browse all 5140 code snippets

Related Posts