Lingo alt to adding code to an object at runtime

Want to move your code and projects to LiveCode but don't know where to start?

Moderators: Klaus, FourthWorld, heatherlaine, robinmiller

Post Reply
CenturyMan1979
Posts: 86
Joined: Tue May 15, 2012 5:56 pm
Location: Minneapolis, MN

Lingo alt to adding code to an object at runtime

Post by CenturyMan1979 » Tue May 15, 2012 6:17 pm

Was looking for a little help on how I can add code to a dynamically created object in livecode.

In Lingo I could do the following to add an object then add code to it. Sorry for the [dot] but this forum does not let me post using dot syntax lingo code.

tNewMem = new(Object)
tNewSprite = sprite(spriteNum)
tNewSprite[dot]puppet = true
tNewSprite[dot]member = tNewMem
sprite(spriteNum)[dot]scriptInstanceList[dot]add(Script Reference)

What would a script look like to do this in livecode if it is possible?

Klaus
Posts: 11218
Joined: Sat Apr 08, 2006 8:41 am
Location: Germany
Contact:

Re: Lingo alt to adding code to an object at runtime

Post by Klaus » Tue May 15, 2012 6:47 pm

Hi CenturyMan1979,

geeez, I immediately abandoned Director when the first version of MetaCard (the grandfather of LiveCode)
for Mac/Win came out and before I dived into the Director OOP stuff in 1999 :-)

You can add a "behavior", which is "just" the script of a "premade" button, to newly created objects:
...
create button
## or field or player or graphic or whatever you like to create
## No "sprites" or "puppets" in Livecode!
set the behavior of last button to the long ID of btn "the premade behavior button here..."
...
Yep, something like this :D

And welcome to the forum!


Best

Klaus

Post Reply

Return to “Converting to LiveCode”