Are you developing tools to extend the LiveCode environment? This is the place to talk about the nuts and bolts of extending our nuts and bolts. If you want to use a LiveCode or third party Environment extension, visit the Using Evironment Extensions forum.
I have recently started to make plugins to speed up development. Ive come across a bit of a sticking point in that I can't get the plugin to create a graphic in the 'target card'.
Any tips as to where I am going wrong would be much appreciated (Code Below):
Created: 2020 05 12
Created By: HP
Modified: 2020 05 12
Modified By: HP
----------------------------------
--This is trying to create a line
----------------------------------
on mouseup
-----
put the loc of the selectedobject into t_loc
put the width of the selectedobject into t_width
-----
put the name of the topstack into t_stack
put the cardids of t_stack into t_card
answer the name of card t_card of stack t_stack
-----
create Graphic "rt_div_line" in t_card of t_stack
-----
set the width of it to t_width
set the height of it to "2"
set the loc of it to t_loc
put the left of it into t_left
put the right of it into t_right
-----
--sets the style of it
set the style of it to "line"
-----
-----
--sets the line points
put t_left & "," & item "2" of t_loc into t_points_line_1
put t_right & "," & item "2" of t_loc into t_points_line_2
put t_points_line_1 & \
return & \
t_points_line_2 & \
"" into t_points
set the points of it to t_points
-----
end mouseup
put the long name of the topstack into t_stack --<-- the long name could do the trick
put t_stack & cr --- <-- comment out later
put the cardids of t_stack into t_cards -- <-- notice that I changed this variable name to plural
put t_cards & cr after msg --- <-- comment out later
create Graphic "rt_div_line" in card id (line 1 of t_cards) of t_stack
Note that 'the CardIDs' will return a line delimited list of card ID numbers of cards in the target stack, so you probably want to use ..."in card ID (line x of t_cards) of stack t_stack"... and iterate through the cards in a repeat loop (I don't know what your goal is)
Last edited by PaulDaMacMan on Wed May 20, 2020 3:51 am, edited 2 times in total.
When I have been creating graphic lines, I also have to pay attention to the layer. The line was drawing and my points were there, but it was underneath other objects with a layer or 3 or 4, so I ended up putting an arbitrary 1000 into the layer property to pop it up to the top.
Thats wonderful, thank you very much all for your input, I have just had a play around with your suggestions... It has however lead me to another sticking point, is there a way to return the card of the selected object?
thanks for the swift reply, that is the method that I had been playing around with, with the aim of getting the card name of the selected object so that I can rename the card but I am getting an error saying:
error: execution error at line 38 (Chunk: can't find card), char 1
--renames the card
put the long name of the selectedobject into t_card
put offset("card id",t_card) into t_a
delete char "1" to (t_a - "1") of t_card
delete char "13" to "-1" of t_card
-- we now have the name of the card
put the long id of the topstack into t_stack
--put the long name of card t_card of t_stack
--** The following line is line 38 producing the ERROR **--
set the name of card t_card of t_stack to t_name
breakpoint
Again help shedding light on this would be greatly appreciated
--renames the card
get word 5 of long name of the selectedobject
replace quote with empty in it
put it into t_card
-- we now have the name of the card
put the long id of the topstack into t_stack
--put the long name of card t_card of t_stack
--** The following line is line 38 producing the ERROR **
put "theNewNameOfCd" into t_name
set the name of card t_card of t_stack to t_name
breakpoint
Plugins are just stacks with scripts. Any script can modify any object available in the session.
The second example only gets the card's long ID, which is then put into local variable "it". Add a statement to "set the name of it to NewName" and you should be good.
Richard Gaskin LiveCode development, training, and consulting services: Fourth World Systems
LiveCode Group on Facebook
LiveCode Group on LinkedIn