Open and Close [Solved]

Anonynn
Yeah, I know. You wouldn't think this would be a problem but for some reason, an item I created keeps auto-closing no matter WHAT I do. Here are the details...

I have

Features
Container (marked)

Container
Openable/Closable
Can be opened (marked)
Can be closed (marked)

Script to Run when Opening Object:
First time: Blah blah
Otherwise: Blah blah.
gh_guest_bedroom_curtains.flag = True

Script to Run when Closing Object:
msg: blah blah
gh_guest_bedroom_curtains.flag = False


I have another object that is also Openable/Closable and it works just fine. I even tried manipulating the scripts manually like this...
gh_guest_bedroom_curtains.open=True
gh_guest_bedroom_curtains.open=False

But that didn't work. I'm not sure why but as I said the open script is working it just auto-closes the curtains afterward. What gives?

The Pixie
As a general point, it is better to check gh_guest_bedroom_curtains.islocked to see if the room is locked, rather than using your own flag. Quest will set and unset it for you - it is the definitive attribute on the state of a container.

I would guess something else is changing the curtains. Go into code view, and do a search for gh_guest_bedroom_curtains. (note the dot at the end) and see what you find.

Anonynn

As a general point, it is better to check gh_guest_bedroom_curtains.islocked to see if the room is locked, rather than using your own flag.



I've never set the item to lock and I didn't see any evidence that it was. All the new flag does is allow me to change the room descriptions depending on if the curtains are opened or closed, so I doubt they would have any barring on shutting the curtains after they are opened. I used the same technique for a lamp in another room and it stays switched on, or switched off. I even have a "closet door" in the same room as the curtains and that scripting works fine. It's absolutely identical. Maybe I should just switch the curtains to a "switchable" instead of openable/closeable.

Quest will set and unset it for you - it is the definitive attribute on the state of a container.



Haha, I know, that's why I'm really confused. It's like the command isn't going through and opening the curtains. I wonder if it has to do with the switch script or something. No idea. I'll keep looking though :)

XanMag
If you are still having problems, you can always just add a command to the room like 'open curtains; open shades; etc... And run a script that sets a flag 'curtains open' and check for curtains open in the room description. Your problem seems familiar to me and I didn't fuss with it - just switched away from a container entirely.

Good luck!

Anonynn

If you are still having problems, you can always just add a command to the room like 'open curtains; open shades; etc... And run a script that sets a flag 'curtains open' and check for curtains open in the room description. Your problem seems familiar to me and I didn't fuss with it - just switched away from a container entirely.

Good luck!



Yeah, still having the problem. I tried switching between all the container types and none of them are working for a simple open and close script, but I have another object a closet door that works perfect fine. I'm going to try the ole' copy and paste and see if that does anything. I would switch from a container but it would be dumb to say "switch open" curtains lol. I'll let you know what happens.

UPDATE
Nope. I copied the working open and close object and transferred all descriptions and whatnot to the new curtains object copied directly from it and the fucking thing still isn't working. It's pissing me off >.<

XanMag
Try copy-pasting the code you think should work into a new game. Or recreate it in a new game. If I've ever changed container types, sometimes I have those problems. Try recreating it in a totally new game. Try deleting everything in your current game and starting over. Good luck!

Anonynn

Try copy-pasting the code you think should work into a new game. Or recreate it in a new game. If I've ever changed container types, sometimes I have those problems. Try recreating it in a totally new game. Try deleting everything in your current game and starting over. Good luck!



When you mentioned starting all over, I just about choked on my water. The game is over a 1000 pages >_>;; And I did. I copy/pasted a working openable/closeable container and put back in all the coding from the not working object like msgs and the like. Same error cropped up. I think it has to do with the Quest Engine itself or something. I have no idea.

The only part of the script that isn't working though is the "closing" of the object. Or maybe the opening since it's "already closed"

HegemonKhan
I would create a new game, and see if you can get a simple open/close/lock/unlock example working in the new game, then see if you can correct/change over to this for your big-actual game. Then, if it's not working, that's likely an indicator that you might have changed the underlying code for open/close/lock/unlock (Filter -> Show Library Elements), which would mean you'd have to search for all related Scripts/Functions for open/close/lock/unlock handling in the underlying code, and then compare it to a new game's underlying code, to see what you've changed...

(this is a big reason why not to mess with changing the underlying code... as I don't think there's any way for us to see your underlying code, as I believe it isn't shown in your game code or file, unless you were to post the code of the quest core-code files themselves in your quest folder, but that would then take us to be familiar with quest's underlying code and/or good programmers to spot errors with it).

---------

I've had issues with open/close/lock/unlock myself... especially when I tried to open/close/lock/unlock on one side/direction/object/exit and have it handle the other side/direction/exit/object (ie, if you open/close a 'door/exit/curtain/ from one side/room, then the other side's/room's 'door/exit/curtain' should be open/closed ... the logic gets confusing in trying to get it to work as you want... lol)*

* I was trying to make a royal-king-like 'bed' (those fancy beds surrounded by curtains) at one point in one of my games, which I think I ended up having to make the 'bed' a room (which I then had issues with how to deal with 'sleep/lay on' the bed, lol), and use the 'curtains' as my 'doors/exits' to the rest of the bedroom (a separate room), lol. And I also wanted to have the 'bed' have an 'under the bed' for hiding/putting items, but that didn't work very well with being a container (for hiding/revealing them): open under the bed, lol.

--------

if open/close/lock/unlock is working correctly for everything else... then it's likely some typo/stupid mistake/whatever with specifically that code-game aspect that isn't working.

XanMag
Neonayon wrote:When you mentioned starting all over, I just about choked on my water.

Problem identified. When writing games, you need to be drinking ALCOHOL, not water!! Get a good bourbon or IPA, open quest, drink, attack problem, problem solved!

And I meant, start your container over, not your entire game! :shock:

Good luck!

Anonynn

And I meant, start your container over, not your entire game! :shock:

Good luck!



Oh! LOL! I don't see how starting the object over will help, but I'll give it a shot. I mean, I essentially did that when I cloned the working object. I wonder if Quest has some kind of error when using "Switch" scripts in the openable/closeable ones. I'll let you know how it turns out. Also, alcohol...good man xD

Pertex
Perhaps you could change to codeview and copy the entire object to post it here?

Anonynn
Sure! Here's the item's code.

 <object name="gh_guest_bedroom_curtains">
<inherit name="editor_object" />
<inherit name="openable" />
<alias>Curtains</alias>
<usedefaultprefix type="boolean">false</usedefaultprefix>
<alt type="stringlist">
<value>curtain</value>
<value>curtains</value>
</alt>
<displayverbs type="stringlist">
<value>Look at</value>
</displayverbs>
<feature_container />
<listchildren />
<takemsg><![CDATA[You can't take them, but you can <i>open</i> and <i>close</i> them!]]></takemsg>
<drop type="boolean">false</drop>
<hidechildren />
<close />
<visible />
<flag type="boolean">false</flag>
<look type="script"><![CDATA[
msg ("<br/>You can see a pair of curtains that are currently {if gh_guest_bedroom_curtains.flag=False:closed and are letting very little light as a result. You can <i>open</i> them if you wish.{once: Beyond them, you can clearly see a window, even if you aren't sure how you didn't notice any when approaching the tree earlier.}}{if gh_guest_bedroom_curtains.flag=True:open and flooding the room with light as a result. You can <i>close</i> them as a result.{once: Outside you can clearly see zombies still wandering the area as well.}} <br/>")
]]></look>
<openscript type="script"><![CDATA[
firsttime {
switch script here! Too much code to post though.
otherwise {
msg ("<br/>You decide to open the curtains once more and feel the warm light from beyond the window pane bathe your {player.skin} skin in it's warmth. Behind you, the light in the room intensifies, brightening all the colors within. You also see the zombies meandering around out there as well. Just when are they going to move on!?<br/>")
}
gh_guest_bedroom_curtains = True
]]></openscript>
<closescript type="script"><![CDATA[
msg ("<br/>Feeling a little paranoid about the zombies, you decide to close the curtains. Now only a tiny beam of light penetrates between them and flows into the room. Luckily, the illumination is strong enough to shine through the material of the curtains as well, you just can't feel the warmth like this.<br/>")
gh_guest_bedroom_curtains = False
]]></closescript>
</object>
</object>

Pertex
Neonayon wrote:
I have another object that is also Openable/Closable and it works just fine. I even tried manipulating the scripts manually like this...
gh_guest_bedroom_curtains.open=True
gh_guest_bedroom_curtains.open=False


Try this:

gh_guest_bedroom_curtains.isopen=true
gh_guest_bedroom_curtains.isopen=false

HegemonKhan
in quest, I think in general, they use this terminology/labeling-naming convention/system for the built-in stuff:

-able : usually an Inherited Attribute (Object Type) ... sometimes this is involved with an entire process (Function/Script) or it may just be used like a Boolean Attribute, for checking on it, as to what action to do or not do.

no prefix/suffix (ie: open/take/etc) : usually a Function/Script

is- : usually a Boolean Attribute

-------

so you got to be careful, as if you use 'open' or 'openable', then you may be activating an entire process (Function/Script), which may do more stuff than you want and/or stuff that you don't want done (changing various Boolean Attributes and etc), when you just wanted to check a specific-certain Boolean Attribute.

Anonynn


Try this:
gh_guest_bedroom_curtains.isopen=true
gh_guest_bedroom_curtains.isopen=false



When I tried that and...

gh_guest_bedroom_curtains.isopen=True
gh_guest_bedroom_curtains.isopen=False

It came up with this error.

Error running script: Error compiling expression 'gh_guest_bedroom_curtains': RootExpressionElement: Cannot convert type 'Boolean' to expression result of 'Element'

I'm going to try rebuilding the whole curtain "event" from scratch. If that doesn't work, I don't know what the problem is. I know for a fact right now, that when the curtains are "opened" like "open curtains" ...the event is running but the game isn't registering that the curtains have been opened. So it keeps repeating the "otherwise" script. Then when I try "close curtains" it says "It's already closed." So I'm sure the problem is that the curtains just aren't "opening"

HegemonKhan
not sure if it matters, but you could try lower case of true/false, as maybe capitolized 'True/False' isn't recognized as boolean (constant-special) values.

and here's some links:

http://docs.textadventures.co.uk/quest/ ... bject.html (the links below, are found in this link, this is a good link to see everything about/on/usage-of Objects)

(the underlying/built-in coding is a bit confusing/complex)

http://docs.textadventures.co.uk/quest/ ... nable.html
http://docs.textadventures.co.uk/quest/ ... /open.html
http://docs.textadventures.co.uk/quest/ ... cript.html
http://docs.textadventures.co.uk/quest/ ... close.html
http://docs.textadventures.co.uk/quest/ ... cript.html
http://docs.textadventures.co.uk/quest/ ... oopen.html
http://docs.textadventures.co.uk/quest/ ... sopen.html
http://docs.textadventures.co.uk/quest/ ... nopen.html
http://docs.textadventures.co.uk/quest/ ... close.html
http://docs.textadventures.co.uk/quest/ ... kopen.html

http://docs.textadventures.co.uk/quest/ ... _open.html
http://docs.textadventures.co.uk/quest/ ... losed.html

http://docs.textadventures.co.uk/quest/ ... bject.html (this is a good link to understand Objects' structure and functionality)

http://docs.textadventures.co.uk/quest/ ... ainer.html
http://docs.textadventures.co.uk/quest/ ... _base.html
http://docs.textadventures.co.uk/quest/ ... mited.html
http://docs.textadventures.co.uk/quest/ ... kable.html
http://docs.textadventures.co.uk/quest/ ... hable.html
http://docs.textadventures.co.uk/quest/ ... rface.html
http://docs.textadventures.co.uk/quest/ ... ocked.html
http://docs.textadventures.co.uk/quest/ ... nlock.html
http://docs.textadventures.co.uk/quest/ ... nlock.html
http://docs.textadventures.co.uk/quest/ ... nlock.html
http://docs.textadventures.co.uk/quest/ ... tchon.html
http://docs.textadventures.co.uk/quest/ ... choff.html

Anonynn

not sure if it matters, but you could try lower case of true/false, as maybe capitolized 'True/False' isn't recognized as boolean (constant-special) values.



Any Boolean I've messed with doesn't register unless they are capitalized and any Boolean in the text-processors must be capitalized as well. I can try it. I tried both capitals and lower case in Pertex's idea.

I also completely deleted and redid the curtain object but the same error is happening, which leads me to believe it must have something to do with the "First Time" script or the "Switch" script. Neither of which should be affecting the opening and closing of an object. It can't be my flags either because I delete them to see if those were the problems. I'll try deleting the "Switch" script next and see if that's causing the issue...Ugh. What a fking pain in my arse.

HegemonKhan
edit'ed in some links for you in my previous post, to better understand how Objects and their functionality works (the selection of the 'container types' Object Types/Inherited Attributes, is a user-friendly way of determining what Attributes and Scripts/Functions that the Object gets and also what those Attributes are initially set to, as well. However, you can bypass the 'container types' Object Types/Inherited Attributes, and directly choose what Attributes and setting their initial values, and what Scripts/Functions to give your Objects. Examine/study the links I've given you, I think you can understand how quest has them designed into their organizational and user-level structure that people are usually working with through the GUI~Editor's Tabs' options of what container type and etc)

-----------

P.S.

just thought of this... if you set/changed/added-scripts-to the global (I think: game->whatever tab) 'onenterroom', maybe the problem/conflict/issue lies within it... Also, try checking if you got an 'onenterroom' for that specific room too, and see if the conflict/issue is in there as well.

----------

P.S.

this is taken from the 'defaultobject' link in my previous post, but maybe it has something to do with your problem:

implementation of onopen, onclose, onlock, onunlock, onswitchon and onswitchoff by triggering a script when the values of isopen, locked and switchedon change

Anonynn

just thought of this... if you set/changed/added-scripts-to the global (I think: game->whatever tab) 'onenterroom', maybe the problem/conflict/issue lies within it... Also, try checking if you got an 'onenterroom' for that specific room too, and see if the conflict/issue is in there as well.



I don't think so. The object is just part of the room and I haven't messed with anything in the room itself aside from the description of it when you enter. And I haven't messed with or changed any global scripts that have to do with "open" or "close". I'm just at a complete loss here. I've tried manually forcing it to open, manipulating the code for it to be opened by using the attribute for open already provided, destroying and recreating the object, copying it from another openable/closable object (in the same room) that's working, deleting scripts, deleting my flags. Nothing.

I know how objects work as well so it can't be complete ignorance lol. Halp!

Anonynn
Any other suggestions?

XanMag
XanMag wrote:If you are still having problems, you can always just add a command to the room like 'open curtains; open shades; etc... And run a script that sets a flag 'curtains open' and check for curtains open in the room description.


Did you do this? Why does it have to be a switch at all?

Anonynn

Did you do this? Why does it have to be a switch at all?



Because the curtain event is different depending on the dominant personality, which the switch script chooses once the event is started.

So basically I created two Commands in the room.

open_curtains
close_curtains

Then I added my scripts to those and they solved the problem. Although, I don't know why it had to be something that complicated in the first place. Thanks for the suggestion Xan!


And I appreciate everyone who chimed in to help on this! Thank you so much for all your help. It's greatly appreciated!

Pertex
Neonayon wrote:
It came up with this error.

Error running script: Error compiling expression 'gh_guest_bedroom_curtains': RootExpressionElement: Cannot convert type 'Boolean' to expression result of 'Element'


OK, you solved the problem. But if you still want to examine the problem here is the code with the working isopen attribute:

    <object name="gh_guest_bedroom_curtains">
<inherit name="editor_object" />
<inherit name="openable" />
<alias>Curtains</alias>
<usedefaultprefix type="boolean">false</usedefaultprefix>
<alt type="stringlist">
<value>curtain</value>
<value>curtains</value>
</alt>
<displayverbs type="stringlist">
<value>Look at</value>
</displayverbs>
<feature_container />
<listchildren />
<takemsg><![CDATA[You can't take them, but you can <i>open</i> and <i>close</i> them!]]></takemsg>
<drop type="boolean">false</drop>
<hidechildren />
<close />
<visible />
<flag type="boolean">false</flag>
<look type="script"><![CDATA[
msg ("<br/>You can see a pair of curtains that are currently {if gh_guest_bedroom_curtains.flag=False:closed and are letting very little light as a result. You can <i>open</i> them if you wish.{once: Beyond them, you can clearly see a window, even if you aren't sure how you didn't notice any when approaching the tree earlier.}}{if gh_guest_bedroom_curtains.flag=True:open and flooding the room with light as a result. You can <i>close</i> them as a result.{once: Outside you can clearly see zombies still wandering the area as well.}} <br/>")
]]></look>
<openscript type="script"><![CDATA[
firsttime {
msg("open")
} otherwise {
msg ("<br/>You decide to open the curtains once more and feel the warm light from beyond the window pane bathe your {player.skin} skin in it's warmth. Behind you, the light in the room intensifies, brightening all the colors within. You also see the zombies meandering around out there as well. Just when are they going to move on!?<br/>")
gh_guest_bedroom_curtains.isopen=true
}
]]></openscript>
<closescript type="script"><![CDATA[
msg ("<br/>Feeling a little paranoid about the zombies, you decide to close the curtains. Now only a tiny beam of light penetrates between them and flows into the room. Luckily, the illumination is strong enough to shine through the material of the curtains as well, you just can't feel the warmth like this.<br/>")
gh_guest_bedroom_curtains.isopen=false
]]></closescript>
</object>

Anonynn
Thanks Pertex. I'll check it out! I appreciate it :)

This topic is now closed. Topics are closed after 60 days of inactivity.

Support

Forums