"Cascading" Object-Behaviors

Sannyasin Brahmanathaswami brahma at hindu.org
Sun Jul 30 13:50:11 EDT 2017


"Entralled with external scripts and GIT are We" says Yoda

hence refactoring old stacks with all code in the stack/card/behavior buttons "out" to *.Livecodescript files and then assigning these "back" to the stack/card/objects

OK so not wanting to mess too much with actually refactoring scripts…

in our puzzle game we have assigned  the behavior of image "tiles" to a button that was off screen, the "old way" of creating and assigning a behavior.

So I selected that button in the PB and (very cool) made a behavior from the control script and saved it out to external file…
then deleted the script in the button itself
then assigned the external behavior file of that button. Added the external script to the stack files saved everything, rebooted and tried the puzzle

Ha! it works! the tiles are assigned the behavior of the button off screen which has zero script lines, but which is assigned the behavior_tileScript.Livecodescript on disk.

Wow.. that was too easy.

It this bad practice? Of course it is a trivial matter to make a direct assignment to the external file since it is in the stack files

set the behavior of me to to (the long id of stack "behavior_tileScript")

OTHO there is a use case/some "utillity" for having all those behaviors as buttons (with no scripts but behaviors assigned to external fiels) on some space, like card 2…then you could access the scripts on disk view those objects vs having to go through the Project Browser.

then in your code you assign the behaviors by using the button ID's.

So, many ways to peel the mango. Anyone one see issues with this?

as ever, just trying to keep from creating a snake pit of "bad practice" code…

BR







More information about the use-livecode mailing list