Hello AGS comunnity!
I really honestly tried to find a solution to my problem myself, the solution that works for me seems too weird.
So - I have two objects in a room located on same place (a cabinets with an open/closed door) and I want the door to open and close by clicking, by changing the visibility of the objects. I was try:
------------------------------------------------------------------------------------------------------------------------------------------
1: In this version, only the first part ("opening the cabinet") works, and the game does not respond to further clicks.
Code: ags ------------------------------------------------------------------------------------------------------------------------------------------
2: In this attempt, only the first part works again (again only "opened door"), but I suspect that this code is completely wrong.
Code: ags -----------------------------------------------------------------------------------------------------------------------------------------
3: The only solution I came up with is to use a function on both objects.
Code: ags
This work, but I suspect the situation could be handled much more elegantly. I hope that you, experienced guys, can advise how to solve such situations.
I will also add that BaselineOverriden is false, oCabinedClose is visible after startup(on top of oCabinetOpen), I make sure that the visibility states in the properties correspond to the start of code.
Thank you
I really honestly tried to find a solution to my problem myself, the solution that works for me seems too weird.
So - I have two objects in a room located on same place (a cabinets with an open/closed door) and I want the door to open and close by clicking, by changing the visibility of the objects. I was try:
------------------------------------------------------------------------------------------------------------------------------------------
1: In this version, only the first part ("opening the cabinet") works, and the game does not respond to further clicks.
function oCabinetClose_Interact()
{
if ((oCabinetClose.Visible == true) && (oCabinetOpen.Visible == false))
{
oCabinetClose.Visible = false;
oCabinetOpen.Visible = true;
}
else if ((oCabinetClose.Visible == false) && (oCabinetOpen.Visible == true))
{
oCabinetClose.Visible = true;
oCabinetOpen.Visible = false;
}
}
2: In this attempt, only the first part works again (again only "opened door"), but I suspect that this code is completely wrong.
function oCabinetClose_Interact()
{
int i;
i = oCabinetClose.Visible == true;
if (i == true)
{
oCabinetClose.Visible = false;
}
else if (i == false)
{
oCabinetClose.Visible = true;
}
}
3: The only solution I came up with is to use a function on both objects.
function oCabinetClose_Interact()
{
if (oCabinetClose.Visible == true)
{
oCabinetOpen.Visible = true;
oCabinetClose.Visible = false;
}
}
function oCabinetOpen_Interact()
{
if (oCabinetOpen.Visible == true)
{
oCabinetOpen.Visible = false;
oCabinetClose.Visible = true
}
}
This work, but I suspect the situation could be handled much more elegantly. I hope that you, experienced guys, can advise how to solve such situations.
I will also add that BaselineOverriden is false, oCabinedClose is visible after startup(on top of oCabinetOpen), I make sure that the visibility states in the properties correspond to the start of code.
Thank you
