Setting solid objects

Started by dronon, Sat 22/07/2006 06:40:58

Previous topic - Next topic

dronon

Hi; real noob here. In my first room, I've got an object called oDoorclosed that I don't want my character to be able to walk through. My character is set to be solid, but how do I set solidity on the object?

I've looked through the manual and found .Solid mentioned, but I can't seem to implement it. I assume I'm supposed to put it in the room script, but each time I try I get an error when I try a test-run.

For example, when I put: "oDoorclosed.Solid = true;" (without the quotes) in the room script, I get the error "Parse error: unexpected 'oDoorclosed'".  When I try "bool oDoorclosed.Solid = true;", I get "Variable 'oDoorclosed' is already imported".  Should I be using the (custom) properties/Edit Properties Schema window in some way instead?

monkey0506

You have to put the script inside of a function, i.e., go to the Room's interaction editor (open the room and click the 'i' button), then under "Player enters room (before fade-in)" add a new run-script action (right click on "Player enters room (...)" and choose to add a new run-script action), then put the code inside of that script.

oDoorclosed.Solid = true;

Let me know if you need more explanation.

dronon

Thanks, that worked great!

And it created a new related question. When I interact with oDoorclosed, it's removed from the room and a second object, oDooropen becomes visible using the "Object - Switch an object back on" action; it's set to invisible before then. It's supposed to be solid too, but I can't get it to happen. I tried putting the equivalent code alongside the first, but it didn't seem to have an effect.

monkey0506

You could just use the same object for both. Name it oDoor, and then change the "oDoorclosed.Solid = true;" to "oDoor.Solid = true;" and whenever you "open" the door, just change it's Graphic (i.e., oDoor.Graphic = 27;) to the appropriate sprite.

Although I'm not really sure why using two objects and having them both solid wouldn't work...perhaps (the manual doesn't specify, so I'm not sure) since the object isn't Visible AGS won't allow it to be Solid?

If you wanted to use two objects, you could change the "Object - Switch an object back on" action to a "Run Script" action and do it like this:

Code: ags
oDooropen.Visible = true;
oDooropen.Solid = true;

dronon

#4
The two-object way was my original setup; now I'm experimenting with the one-object idea.

Code: ags
oDooropen.Visible = true;

I didn't have that in the two-object script I'd tried earlier, because it was already handled by an Interact Object action, and it didn't seem to have an effect. I can try putting it explicity in a script instead and see what happens. (edit: nothing. I guess the object can't be solid unless it's set to be visible from the start.)

For the one-object route, hey! something new learned - changing the graphic. Although that makes a whole world of changes, since the two-object way, I had two sets of actions to move my character to different locations depending on whether he was miming opening or closing the door. If I use one object, I have to set conditionals. "if (object[0].Graphic == 6) {" seemed to work, but is so much more fiddly - I think I'll go back to the two-object way.

Still, the solidity thing has been perplexing. While trying it the one-object way, I discovered that although the documentation says that .BlockingHeight is centered around an object's baseline, changing the .Baseline doesn't change anything; BlockingHeight is always centered around the base of the graphic. In the end, it was easier to edit the room's walkable area to avoid the area of the open door altogether.

Small steps, slowly but surely. Thanks for your help!

Ophidic

weird, I'm using this:

function room_Load()
{
bool oFridge.Solid = true;
}

And it's telling me:

"room4.asc(13): Error (line 13): Expected ',' or ';', not '.'"

It's not a period, it's quite clearly a semi colon. I don't get the error.

Ophidic

Wait... maybe I don't need that bool thing. What's a bolean uhh thing again? I'm sure it's very important but I can't keep track.

Anyway, I managed to get things configured correctly without bool and maybe that's because AGS has been updated since this thread lol

Snarky

#7
A boolean is a value that is true or false.

You shouldn't have bool at the beginning of the line because starting a line with the name of a data type (such as bool, int, String, etc.) means that you want to create a new variable of that type. What you actually want to do is to just set the value of a variable that already exists.

In this case it's giving you an error when it gets to the period in oFridge.Solid because it thinks you're trying to create a variable, and you can't create a variable inside an Object (at least not this way), or use periods in variable names.

So, as you found, you just need to delete bool and it works. This has nothing to do with any AGS updates, it has always worked like this.

Khris

The manual entry https://adventuregamestudio.github.io/ags-manual/Object.html#objectsolid does say
Code: ags
bool Object.Solid
but that means that .Solid is a bool property, i.e. either true or false.

Further down is a usage example which reads
Code: ags
oSmallrock.Solid = true;

SMF spam blocked by CleanTalk