"Cascading" Object-Behaviors

classic Classic list List threaded Threaded
13 messages Options
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

"Cascading" Object-Behaviors

** Clarence P Martin ** via use-livecode
"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





_______________________________________________
use-livecode mailing list
[hidden email]
Please visit this url to subscribe, unsubscribe and manage your subscription preferences:
http://lists.runrev.com/mailman/listinfo/use-livecode
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: "Cascading" Object-Behaviors

** Clarence P Martin ** via use-livecode

> On 31 Jul 2017, at 3:50 am, Sannyasin Brahmanathaswami via use-livecode <[hidden email]> wrote:
>
> "Entralled with external scripts and GIT are We" says Yoda

I have implemented a scriptifier utility script if you are interested here https://github.com/livecode/livecode/pull/5600 <https://github.com/livecode/livecode/pull/5600>

It parses all objects in a stack looking for non-trivial scripts then generates a unique name based on object hierarchy and saves the script only stacks in a folder with the same name as the stack filename and sets the stackFiles appropriately. We have used it on some stacks in the IDE (the installer and the IDE startup stack) and have only found one side effect so far in an old script that used idle. Idle is only sent to objects that implement it and is not detected in their behaviors. For simplicity the script ignores any objects that already have behaviors as if you want a behavior hierarchy of script only stacks you need to script that when they are loaded.
>
> 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

My scriptifier (being a bit dumb about such matters) would do something similar when it encounters an object that is a behavior button used elsewhere. The behavior button scriipt will be exported and the hierarchy will be established. We haven’t noticed any issues with this although it probably wouldn’t take long to tweak the scriptifier to delete the button and set the behavior directly that would impact resource resolution like finding icons so it’s better to leave it in place. Such things are better done manually if necessary.

Cheers

Monte
_______________________________________________
use-livecode mailing list
[hidden email]
Please visit this url to subscribe, unsubscribe and manage your subscription preferences:
http://lists.runrev.com/mailman/listinfo/use-livecode
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: "Cascading" Object-Behaviors

** Clarence P Martin ** via use-livecode
Yes, better to leave in place..  i.e. behavior buttons with no scripts, now assigned behavior to external file.

We are using a JSON file on disk that we read in to set the stack files on start up, because with a team, things get crazy if you have this in the binary.

One Caveat

the PB does not show that  objects with the assigned behavior to a button with no script… has any code … it shows
 0 lines of code, when in fact the behavior assigned to the button which is assigned to that object *is*  in the msg path.

Other caveats: I am getting "bitten" by ambiguity of "me"  in scripts.  but that is a different subject.   for mobile, timin is everything and we are frequently needing to allow 200 milliseconds, 500 etc before calling some other handler, while the UI gets updated. So typically the events we want to fire are in the same "library" but you can do

Send to me  

you have to declare "this stack" to "stack "suchAndSuch" (which is the actual name of the file with these handlers)




Svasti Astu, Be Well
Brahmanathaswami

www.himalayanacademy.com

 

On 7/30/17, 10:28 AM, "use-livecode on behalf of Monte Goulding via use-livecode" <[hidden email] on behalf of [hidden email]> wrote:

    >
    >On 31 Jul 2017, at 3:50 am, Sannyasin Brahmanathaswami via use-livecode <[hidden email]> wrote:
    >"Entralled with external scripts and GIT are We" says Yoda
   
    I have implemented a scriptifier utility script if you are interested here https://github.com/livecode/livecode/pull/5600<https://github.com/livecode/livecode/pull/5600>
   
    It parses all objects in a stack looking for non-trivial scripts then generates a unique name based on object hierarchy and saves the script only stacks in a folder with the same name as the stack filename and sets the stackFiles appropriately. We have used it on some stacks in the IDE (the installer and the IDE startup stack) and have only found one side effect so far in an old script that used idle. Idle is only sent to objects that implement it and is not detected in their behaviors. For simplicity the script ignores any objects that already have behaviors as if you want a behavior hierarchy of script only stacks you need to script that when they are loaded.
    >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
   
    My scriptifier (being a bit dumb about such matters) would do something similar when it encounters an object that is a behavior button used elsewhere. The behavior button scriipt will be exported and the hierarchy will be established. We haven’t noticed any issues with this although it probably wouldn’t take long to tweak the scriptifier to delete the button and set the behavior directly that would impact resource resolution like finding icons so it’s better to leave it in place. Such things are better done manually if necessary.
   
    Cheers
   
    Monte

_______________________________________________
use-livecode mailing list
[hidden email]
Please visit this url to subscribe, unsubscribe and manage your subscription preferences:
http://lists.runrev.com/mailman/listinfo/use-livecode
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: "Cascading" Object-Behaviors

** Clarence P Martin ** via use-livecode
In reply to this post by ** Clarence P Martin ** via use-livecode
I click the link, I go there I log in I cannot see anywhere where there is a file to download or code to copy.

Bob S


> On Jul 30, 2017, at 13:27 , Monte Goulding via use-livecode <[hidden email]> wrote:
>
> I have implemented a scriptifier utility script if you are interested here https://github.com/livecode/livecode/pull/5600<https://github.com/livecode/livecode/pull/5600>


_______________________________________________
use-livecode mailing list
[hidden email]
Please visit this url to subscribe, unsubscribe and manage your subscription preferences:
http://lists.runrev.com/mailman/listinfo/use-livecode
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: "Cascading" Object-Behaviors

** Clarence P Martin ** via use-livecode
The url got messed up somehow there try:
https://github.com/livecode/livecode/pull/5600 <https://github.com/livecode/livecode/pull/5600>

> On 1 Aug 2017, at 6:12 am, Bob Sneidar via use-livecode <[hidden email]> wrote:
>
> I click the link, I go there I log in I cannot see anywhere where there is a file to download or code to copy.
>
> Bob S
>
>
>> On Jul 30, 2017, at 13:27 , Monte Goulding via use-livecode <[hidden email]> wrote:
>>
>> I have implemented a scriptifier utility script if you are interested here https://github.com/livecode/livecode/pull/5600<https://github.com/livecode/livecode/pull/5600>
>
>
> _______________________________________________
> use-livecode mailing list
> [hidden email]
> Please visit this url to subscribe, unsubscribe and manage your subscription preferences:
> http://lists.runrev.com/mailman/listinfo/use-livecode

_______________________________________________
use-livecode mailing list
[hidden email]
Please visit this url to subscribe, unsubscribe and manage your subscription preferences:
http://lists.runrev.com/mailman/listinfo/use-livecode
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: "Cascading" Object-Behaviors

** Clarence P Martin ** via use-livecode
OK got it. I take it this is supposed to be a script only stack? That is how I saved it.

Bob S


> On Jul 31, 2017, at 13:20 , Monte Goulding via use-livecode <[hidden email]> wrote:
>
> The url got messed up somehow there try:


_______________________________________________
use-livecode mailing list
[hidden email]
Please visit this url to subscribe, unsubscribe and manage your subscription preferences:
http://lists.runrev.com/mailman/listinfo/use-livecode
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: "Cascading" Object-Behaviors

** Clarence P Martin ** via use-livecode

> On 1 Aug 2017, at 7:00 am, Bob Sneidar via use-livecode <[hidden email]> wrote:
>
> OK got it. I take it this is supposed to be a script only stack? That is how I saved it.

Yes it will generate a very simple UI when you open it

Cheers

Monte
_______________________________________________
use-livecode mailing list
[hidden email]
Please visit this url to subscribe, unsubscribe and manage your subscription preferences:
http://lists.runrev.com/mailman/listinfo/use-livecode
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: "Cascading" Object-Behaviors

AndyP
Monte, great tool. thanks...saves a lot of time.
Andy Piddock

My software never has bugs. It just develops random features.

TinyIDE a Free alternative minimalist IDE Plugin for LiveCode TinyIDE

Script editor Themer for LC http://2108.co.uk

PointandSee is a FREE simple but full featured under cursor colour picker / finder. http://www.pointandsee.co.uk - made with LiveCode

Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: "Cascading" Object-Behaviors

** Clarence P Martin ** via use-livecode
In reply to this post by ** Clarence P Martin ** via use-livecode
"GIT DUMMY" here..


How does one get the script without downloading the entire LC repository?

All I can see is to copy it.. which works I guess you have to then remove all the leading "+" signs and save to your plugins folder?

BR


 

On 7/30/17, 10:28 AM, "use-livecode on behalf of Monte Goulding via use-livecode" <[hidden email] on behalf of [hidden email]> wrote:

    I have implemented a scriptifier utility script if you are interested here https://github.com/livecode/livecode/pull/5600<https://github.com/livecode/livecode/pull/5600>

_______________________________________________
use-livecode mailing list
[hidden email]
Please visit this url to subscribe, unsubscribe and manage your subscription preferences:
http://lists.runrev.com/mailman/listinfo/use-livecode
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: "Cascading" Object-Behaviors

** Clarence P Martin ** via use-livecode
Use the following url:

<https://raw.githubusercontent.com/montegoulding/livecode/811fa6e77e514c7e3ccae150af5fd856199719e1/tools/Scriptifier.livecodescript <https://raw.githubusercontent.com/montegoulding/livecode/811fa6e77e514c7e3ccae150af5fd856199719e1/tools/Scriptifier.livecodescript>>

I’d like to say you can go stack url with this url but you can’t because it’s broken for script only stacks although from the looks of things go stack byte 4 to -1 of url might work in LC 9…

http://quality.livecode.com/show_bug.cgi?id=18998 <http://quality.livecode.com/show_bug.cgi?id=18998>

Cheers

Monte

> On 2 Aug 2017, at 1:25 pm, Sannyasin Brahmanathaswami via use-livecode <[hidden email]> wrote:
>
> "GIT DUMMY" here..
>
>
> How does one get the script without downloading the entire LC repository?
>
> All I can see is to copy it.. which works I guess you have to then remove all the leading "+" signs and save to your plugins folder?
>
> BR
>
>
>
>
> On 7/30/17, 10:28 AM, "use-livecode on behalf of Monte Goulding via use-livecode" <[hidden email] on behalf of [hidden email]> wrote:
>
>    I have implemented a scriptifier utility script if you are interested here https://github.com/livecode/livecode/pull/5600<https://github.com/livecode/livecode/pull/5600>
>
> _______________________________________________
> use-livecode mailing list
> [hidden email]
> Please visit this url to subscribe, unsubscribe and manage your subscription preferences:
> http://lists.runrev.com/mailman/listinfo/use-livecode

_______________________________________________
use-livecode mailing list
[hidden email]
Please visit this url to subscribe, unsubscribe and manage your subscription preferences:
http://lists.runrev.com/mailman/listinfo/use-livecode
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: "Cascading" Object-Behaviors

** Clarence P Martin ** via use-livecode
I just tried it on Mac/Win and it works in LC9DP8 that way for me.

On Tue, Aug 1, 2017 at 10:34 PM, Monte Goulding via use-livecode <
[hidden email]> wrote:

> Use the following url:
>
> <https://raw.githubusercontent.com/montegoulding/livecode/
> 811fa6e77e514c7e3ccae150af5fd856199719e1/tools/Scriptifier.livecodescript
> <https://raw.githubusercontent.com/montegoulding/livecode/
> 811fa6e77e514c7e3ccae150af5fd856199719e1/tools/Scriptifier.livecodescript
> >>
>
> I’d like to say you can go stack url with this url but you can’t because
> it’s broken for script only stacks although from the looks of things go
> stack byte 4 to -1 of url might work in LC 9…
>
> http://quality.livecode.com/show_bug.cgi?id=18998 <
> http://quality.livecode.com/show_bug.cgi?id=18998>
>
> Cheers
>
> Monte
>
> > On 2 Aug 2017, at 1:25 pm, Sannyasin Brahmanathaswami via use-livecode <
> [hidden email]> wrote:
> >
> > "GIT DUMMY" here..
> >
> >
> > How does one get the script without downloading the entire LC repository?
> >
> > All I can see is to copy it.. which works I guess you have to then
> remove all the leading "+" signs and save to your plugins folder?
> >
> > BR
> >
> >
> >
> >
> > On 7/30/17, 10:28 AM, "use-livecode on behalf of Monte Goulding via
> use-livecode" <[hidden email] on behalf of
> [hidden email]> wrote:
> >
> >    I have implemented a scriptifier utility script if you are interested
> here https://github.com/livecode/livecode/pull/5600<https://
> github.com/livecode/livecode/pull/5600>
> >
> > _______________________________________________
> > use-livecode mailing list
> > [hidden email]
> > Please visit this url to subscribe, unsubscribe and manage your
> subscription preferences:
> > http://lists.runrev.com/mailman/listinfo/use-livecode
>
> _______________________________________________
> use-livecode mailing list
> [hidden email]
> Please visit this url to subscribe, unsubscribe and manage your
> subscription preferences:
> http://lists.runrev.com/mailman/listinfo/use-livecode
>
_______________________________________________
use-livecode mailing list
[hidden email]
Please visit this url to subscribe, unsubscribe and manage your subscription preferences:
http://lists.runrev.com/mailman/listinfo/use-livecode
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: "Cascading" Object-Behaviors

** Clarence P Martin ** via use-livecode
So is the BOM causing the issue with detection of the URL being a script
only stack or is it in the function that actually reads in the file?
Trying to wrap my head around how the go stack works (still looking at
code).

On Wed, Aug 2, 2017 at 8:02 AM, Brian Milby <[hidden email]> wrote:

> I just tried it on Mac/Win and it works in LC9DP8 that way for me.
>
> On Tue, Aug 1, 2017 at 10:34 PM, Monte Goulding via use-livecode <
> [hidden email]> wrote:
>
>> Use the following url:
>>
>> <https://raw.githubusercontent.com/montegoulding/livecode/81
>> 1fa6e77e514c7e3ccae150af5fd856199719e1/tools/Scriptifier.livecodescript <
>> https://raw.githubusercontent.com/montegoulding/livecode/81
>> 1fa6e77e514c7e3ccae150af5fd856199719e1/tools/Scriptifier.livecodescript>>
>>
>> I’d like to say you can go stack url with this url but you can’t because
>> it’s broken for script only stacks although from the looks of things go
>> stack byte 4 to -1 of url might work in LC 9…
>>
>> http://quality.livecode.com/show_bug.cgi?id=18998 <
>> http://quality.livecode.com/show_bug.cgi?id=18998>
>>
>> Cheers
>>
>> Monte
>>
>> > On 2 Aug 2017, at 1:25 pm, Sannyasin Brahmanathaswami via use-livecode <
>> [hidden email]> wrote:
>> >
>> > "GIT DUMMY" here..
>> >
>> >
>> > How does one get the script without downloading the entire LC
>> repository?
>> >
>> > All I can see is to copy it.. which works I guess you have to then
>> remove all the leading "+" signs and save to your plugins folder?
>> >
>> > BR
>> >
>> >
>> >
>> >
>> > On 7/30/17, 10:28 AM, "use-livecode on behalf of Monte Goulding via
>> use-livecode" <[hidden email] on behalf of
>> [hidden email]> wrote:
>> >
>> >    I have implemented a scriptifier utility script if you are
>> interested here https://github.com/livecode/livecode/pull/5600<
>> https://github.com/livecode/livecode/pull/5600>
>> >
>> > _______________________________________________
>> > use-livecode mailing list
>> > [hidden email]
>> > Please visit this url to subscribe, unsubscribe and manage your
>> subscription preferences:
>> > http://lists.runrev.com/mailman/listinfo/use-livecode
>>
>> _______________________________________________
>> use-livecode mailing list
>> [hidden email]
>> Please visit this url to subscribe, unsubscribe and manage your
>> subscription preferences:
>> http://lists.runrev.com/mailman/listinfo/use-livecode
>>
>
>
_______________________________________________
use-livecode mailing list
[hidden email]
Please visit this url to subscribe, unsubscribe and manage your subscription preferences:
http://lists.runrev.com/mailman/listinfo/use-livecode
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: "Cascading" Object-Behaviors

** Clarence P Martin ** via use-livecode

> On 3 Aug 2017, at 6:44 am, Brian Milby via use-livecode <[hidden email]> wrote:
>
> So is the BOM causing the issue with detection of the URL being a script
> only stack or is it in the function that actually reads in the file?
> Trying to wrap my head around how the go stack works (still looking at
> code).

Go stack tries to work out whether it has been passed a blob that is the content of a stack file. Script only stacks may have a BOM but the current detection doesn’t handle that.

Cheers

Monte
_______________________________________________
use-livecode mailing list
[hidden email]
Please visit this url to subscribe, unsubscribe and manage your subscription preferences:
http://lists.runrev.com/mailman/listinfo/use-livecode
Loading...