Book a Demo

Author Topic: Problems with my first shape script  (Read 4689 times)

Mr Stuff

  • EA User
  • **
  • Posts: 64
  • Karma: +0/-0
    • View Profile
Problems with my first shape script
« on: June 09, 2017, 05:22:19 pm »
This shape script is supposed to replace the standard stick-figure Actor with a simple box. (I can't see how to post an image so I have to describe it)

Problem: the shape is wide and shallow, and the actor image is narrow and tall. The shape appears but the clickable area to select and resulting selection markers are those of the actor image not that of the defined shape.

I had to create sub shapes because the Print("#name#") string was wrapping inside the actor shape, which is obviously related to the same underlying problem of not having overridden (even though it is checked - the shape does appear as specified) the standard Actor shape.

Clearly this is wrong - but what is the right way to do this?

Code: [Select]
shape main

{
setfillcolor(255, 255, 255);  // (R,G,B)
        rectangle(0, 0, 360, 40);   // (x1,y1,x2,y2)
addsubshape("topspace", 360, 6);
shape topspace
{
Print("");
}
addsubshape("namecompartment", 360, 34);
shape namecompartment
{
h_align = "center";
Print("#name#");
}
}

Many thanks

Julian

Paolo F Cantoni

  • EA Guru
  • *****
  • Posts: 8626
  • Karma: +259/-129
  • Inconsistently correct systems DON'T EXIST!
    • View Profile
Re: Problems with my first shape script
« Reply #1 on: June 09, 2017, 06:17:54 pm »
Hi Julian,

you probably need a:
defsize(X,Y);

At the top of your script.

You may want to have a look at Geert Bellekens repository of shapescripts - search for the link in the forum - to see how to use shapescripts "in the wild".

HTH,
Paolo
Inconsistently correct systems DON'T EXIST!
... Therefore, aim for consistency; in the expectation of achieving correctness....
-Semantica-
Helsinki Principle Rules!

qwerty

  • EA Guru
  • *****
  • Posts: 13584
  • Karma: +397/-301
  • I'm no guru at all
    • View Profile
Re: Problems with my first shape script
« Reply #2 on: June 09, 2017, 09:47:47 pm »
Your main issue is the 360. Shape script renders in a virtual rectangle of 100x100. So 360 is 3.6 the width of what you would see as connector attaching frame.

q.

Mr Stuff

  • EA User
  • **
  • Posts: 64
  • Karma: +0/-0
    • View Profile
Re: Problems with my first shape script
« Reply #3 on: June 09, 2017, 10:13:43 pm »
Hi Paolo, qwerty

I made it
Code: [Select]
     defsize(180,40);
     setfillcolor(255, 255, 255);  // (R,G,B)
     rectangle(0, 0, 100, 100);   // (x1,y1,x2,y2)
After which it was fine - the rectangle dimensions seem to be % of the defsize.

Thanks for the suggestions!

Julian