Dilemma! Dun dun duuun! [SOLVED]

Anonynn
16 Jun 2016, 00:12
I might need a solution to a very minor problem I am experiencing. Suggestions are welcome!

So here's what is supposed to happen.

player turns on sink
move fresh water into room.

player takes fresh water, fresh water moves into waterskin to be held.

player turns off sink
remove fresh water.


Naturally, you can already guess the problem! The code also removes the fresh water from the water skin if it's taken!

So I tried.

player turns on sink
clone object fresh water and move into room

player takes fresh water, fresh water moves into the waterskin to be held.

player turns off sink...
but the fresh water remains. Hm.



So basically, I need to figure out how to remove the cloned object or the object from the room without removing it from the waterskin once it's taken.

Any solutions? :)

XanMag
16 Jun 2016, 01:45
Just make a new object and give it alias fresh water. Don't clone.

Anonynn
16 Jun 2016, 01:58

Just make a new object and give it alias fresh water. Don't clone.



Whatcha mean?

Er, maybe I didn't make it clear ^_^;;

I meant how do I remove the fresh water item from the sink without also removing it from the waterskin if the player is carrying it. It happens because turning on the sink moves the object into the room, and turning off the sink removes the fresh water item but it removes it from the waterskin as well, not just the room.

XanMag
16 Jun 2016, 02:08
have freshwater1 a separate item from freshwater. When you turn on the sink, move freshwater to sink. When you fill the water skin, move freshwater1 to water skin. When you turn off the sink, move freshwater to wherever you want to move it to (I have item warehouses where I store things like that). Freshwater1 stays in water skin, freshwater moves back to an item room. Or, you could make it invisible.

Of course, make freshwater an alias for freshwater1.

You'll need an If statement to make sure player isn't already carrying the freshwater1 so things don't get goofy there. But, should be easy enough. I did that in both X1 and X2.

HegemonKhan
16 Jun 2016, 02:35
Also, I don't know how you've got this stuff setup, but you shouldn't need to remove the 'freshwater' if you're just moving it around (and if you also don't have/need more/clones of them).

Father thyme
16 Jun 2016, 04:59
Perhaps you could give the water skin a flag, flagname ' full' when you fill it up. You would need ifs on the item description. Probably not the most technical answer , but then I am not technical.
Or
You could even create an item at start of game ' full water skin' , put it in your player's inventory ( invisible) then swap the two waterskins when filling up. ( hide empty , show full)

The Pixie
16 Jun 2016, 09:47
I am with Father thyme; do it with flags. As he says, the description would need ifs, but you could use text processor commands to keep it simple. You would need a flag on the sink to note if the tap is running, and another on the waterskin to note if it was full (or an integer recording what percentage full it is even).

Anonynn
17 Jun 2016, 17:39
Well, I'm not really too worried about the waterskin, it works just fine, although using flags is a really good idea. I might fanagle the code later and make it more simple.

My problem is when the player turns on the sink...the fresh water is moved into the room for them to take.

When they turn off the sink the fresh water (if they didn't take it) remains in the room. Originally I had it removed, but if the player is carrying fresh water in the waterskin it also removes it from there as well.

The problem is more how do I make an item reappear and disappear without applying to the players inventory as well.

HegemonKhan
17 Jun 2016, 18:08
there's a few (or some/many, lol) different designs/methods that you can do...

-------------

every Object is unique (via its 'name' ID Attribute), so the original Object is an Object, and each Clone, is another/separate Object (as when quest creates a clone, it gives that new Object a different name, using numbers at the end, so you can check it's name, to remove the clones, or you can give the original Object an indicator/flag Attribute, which you can check for, to remove the clone). see code box below for an example.

http://docs.textadventures.co.uk/quest/functions/ (scroll down to the very bottom, the 'String Functions' category/section)
http://docs.textadventures.co.uk/quest/ ... swith.html
http://docs.textadventures.co.uk/quest/ ... swith.html
etc etc etc String Checking/Manipulation Scripts/Functions, take a look at all of them, and be creative on how you can use them!

<object name="potion">
</object>

// turning on your... sink (lol), has scripting that creates clones of 'potion' Object, lol. It's a magical potion sink in this example, lol.

foreach (object_variable, AllObjects()) {
if (StartsWith (object_variable.name, "potion") and not EndsWith (object_variable.name, "potion")) {
destroy (object_variable) // only your clones will be destroyed due to the if code line above
}
}


-------------------------

probably the easiest/simpliest would be to create Clones upon turning on the sink, and then remove/destroy the Clones (this will involve a bit of code/scripting + Attribute work to accomplish this though ~ ask me or whoever about how to do this stuff if interested in using this method) them as needed and where/when to do so.

------------------------

however, creating clones whenever you to turn on the sink, is probably a bad idea possibly in terms of code efficiency/file size/performance, as you don't want a ton of clones to be dealing with, even if you're removing/destroying them. A better way would be to just have a single Object somewhere by itself and hidden (not a Object the person playing would know about), and then you can use 'Object Attributes/Stringlists Attributes/Objectlists Attributes' to do whatever actions you want upon that Object.

and there's probably many other ways as well...

The Pixie
17 Jun 2016, 19:43
If you use flags, there is no water object. When the tap (facet) is turned, the "waterflowing" sink is set to true, turn it again, and the flag goes to false. Also have a "full" flag on the waterskin.

Here, read this tutorial:
viewtopic.php?f=18&t=6430

Anonynn
17 Jun 2016, 20:45
Oh! I see what you're saying. Remove the fresh water object from the room and waterskin entirely and just do like a flag for full. I already have a flag for when the sink is turned on. But I'll see what I can do with it. :)

Thanks! I'll keep this open unless it works!


Thanks for all the responses everyone :D :D !

Anonynn
18 Jun 2016, 02:05
Just curious! Is there a way to say for example

if (room.contains=freshwater) {
}
if (room.contains=dirtywater) {
}



HegemonKhan
18 Jun 2016, 16:17
here are the Functions/Scripts:

http://docs.textadventures.co.uk/quest/ ... y/got.html
http://docs.textadventures.co.uk/quest/ ... tains.html
http://docs.textadventures.co.uk/quest/ ... tains.html
http://docs.textadventures.co.uk/quest/ ... tains.html

examples:

(you can add in more 'else ifs' to the below, I just showed examples of 'if~else', instead of 'if~else if~else')

if (Got (freshwater)) { /* scripts */ } else { /* scripts */ }
// the above is a shortcut for checking if an Object item is in the 'inventory' Objectlist Attribute of the default 'player' Player Object, instead of using:
if (ListContains (ScopeInventory(), freshwater)) { /* scripts */ } else { /* scripts */ }

if (Contains (room, freshwater)) { /* scripts */ } else { /* scripts */ }

if (ListContains (room.my_list, freshwater)) { /* scripts */ } else { /* scripts */ }

if (DictionaryContains (room.my_dictionary, freshwater)) { /* scripts */ } else { /* scripts */ }