EntityByName

About programs, games and other things related to Algodoo and Phun.

EntityByName

Postby eeieeio » Tue Dec 03, 2019 5:09 am

Hi everyone. I've been searching the forum for an easy to follow instructions on how to assign a name to an object. The closest I have found is from Kilinich. I thought I was good at following directions, but just can't get it. The problem is adding a name to an object so I can refer to it in an 'on collision' event. When I type "_name = "rectangleshape1"" it does not appear in the script menu. Would really appreciate detailed step by step instructions on how to name an object.

Thanks, Dave
eeieeio
 
Posts: 25
Joined: Thu Nov 30, 2017 7:02 pm

Re: EntityByName

Postby FRA32 » Wed Dec 11, 2019 7:28 pm

Adding a custom variable to an object works like this:

Take your object, right click it
go to script menu,
go to the tiny empty black box in the top left corner
type _literallyAnything = someKindOfValue;
hit enter.

If done correctly, you will now see your new variable at the beginning of the variable list. Here some examples:

_id = 59;

_name = "Something propably";

_origin = pos;

_onJump = (e)=>{vel = vel + [0,5];_jump = false;};
FRA32
 
Posts: 227
Joined: Wed Dec 03, 2014 9:51 pm


Return to Algodoo related

Who is online

Users browsing this forum: No registered users and 4 guests