Object 'Self' for the purposes of identification in scripts?

Pykrete
Not had much luck finding what i'm looking for, though i'm almost certain it exists.

The problem is simple; here's an example. In the game, the player can find food. When they bring that food to their home, they can add it to their pantry; where it stops being an object and becomes a variable instead. (You have x days worth of food, with each item equalling one increase.)

So, I just made an object for food to find, which is then cloned. There's then a verb on it which, when used in the right room back home, removes the item and increases the food count. But there's the problem; I can't just have it say 'RemoveObject (Food)', because the item created isn't Food, it's Food1, then Food2 and so on and so forth for every new piece of food the player finds.

Is there something I can slip into the brackets of RemoveObject (Object) that just makes it automatically apply to the item the verb is being used on? In essence, RemoveObject (Self) or whatever. I'm pretty sure i've seen something like that mentioned but can't for the live of me remember what it is; i'm assuming that when you create take/drop on an object, it must use this. Hopefully i'm not wrong, I can work around this but it'd be a bit of a pain. Any ideas?

The Pixie
It is "this" in Quest.

HegemonKhan
'this' is used in Java and Quest, and 'self' is used in Python (Python also requires that you put the 'self' as the first parameter for a function, it doesn't do it behind the scenes for you).

example of 'this' used in quest:

<type name="character">
<attr name="display_alias_and_strength" type="script">
msg(this.alias + " Strength: " + this.strength)
</attr>
</type>

<object name="player">
<inherit name="character" />
<attr name="alias" type="string">HK</attr>
<attr name="strength" type="int">100</attr>
</object>

<object name="orc_1">
<inherit name="character" />
<attr name="alias" type="string">orc</attr>
<attr name="strength" type="int">25</attr>
</object>

Pykrete
Ah, I knew I was getting Self from somewhere! Just tested it and ' this ' works just great. Cheers for the speedy responses! No doubt i'll hit another wall soon enough, haha. I'm to understand it's preferred that you make another topic for new questions, right?

Having said that, this is only a small one; the Health variable produced when you select it in the game menu... where on earth is it? Can I display it like other variables/atts? I assume yes, but can't for the life of me work out where it is/what it's called when it's created. It'd also be nice to manipulate it directly like other variables rather than using the Increase/Decrease Health scripts.

HegemonKhan
I tried using the built-in health, but it confused me with the percent stuff, so I just add my own 'current_life' and 'maximum_life' Integer Attributes. I believe that you should be able to find the built-in 'health' on~in the 'player' Player Object:

(after you toggle on the 'health' feature) -> 'player' Player Object -> 'Attributes' Tab -> (look in the right side's list of Attributes already added to the Object, for the 'health' Attribute, it should be there...)

OR.... maybe it's on the special 'game' Game Object:

(after you toggle on the 'health' feature) -> 'game' Game Object -> 'Attributes' Tab -> (look in the right side's list of Attributes already added to the Object, for the 'health' Attribute, it should be there...)

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

as I said, I ran away from the built-in 'health' due to not understanding it, but it can definately be displayed on the right side's 'status' pane during game play, via using the STATUS ATTRIBUTES, and it should work like any other Attribute, as it is an Attribute, so it should have all the same functionality, for example:

player.health = player.health - orc.damage
msg ("The orc attacks and damages you.")

but, maybe there's some differences due to its usage of its percent... remember, I got confused, so I don't really understand at all about the built-in 'health' Attribute, lol.

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

in general, the site prefers you to make new threads for questions, as they do make a good point that no one wants to dig through tons of pages in a thread, looking for the post-content that they're looking for. I myself didn't know this, when I jsut joined as well, thinking that they wouldn't want me spamming the forum with my questions, as can be seen by my "noobie help me thread". Now, I know better, laughs.

Pykrete
Yeah, current/max hp variables are a bit of a pain but they work, at least. I know score shows up as an attribute for the game object, it's just game/score. But the only mention of HP I can find is 'showhealth' as a boolean and then health mentioned in the status bar dictionary, where it's just referred to as Health rather than the usual x.Health you'd expect of an attribute.

HegemonKhan
ah, that sounds like where I ran away from it, laughs, being stuck and confused on it, as you are, laughs. I tried using the 'health' like 3 years ago when I found quest, and that sounds like what happened to me, I couldn't figure out how the 'health' worked, lol. I'm sure lots of people can easily help you (and me) with understanding it, hopefully they'll look at this thread and help out with how to use the 'health' attribute.

You can try reading some of Pixie's libraries~guides, as I'm sure one of them discusses using the 'health', in the meantime.

some links (if you don't already know about them):

http://docs.textadventures.co.uk/quest/

viewforum.php?f=18 (more guides: libraries and code samples)
http://docs.textadventures.co.uk/quest/tutorial/
http://docs.textadventures.co.uk/quest/guides/
http://docs.textadventures.co.uk/quest/ ... ation.html

The Pixie
I have never used the in-built health. I do not think it was there when I started CombatLib.

Just had a quick look. So you tick the features box on the game object, then you can call IncreaseHealth and DecreaseHealth. Quest seems to add attributes "health" and "changedhealth" to the player object when the game starts, and the "changedhealth" script caps the health at 100 and 0. Nothing seems to happen when it gets to zero, which was disappointing (though I might have missed it), especially as there is no way to modify the changescript (if you add your own it will get overwritten).

Pykrete
Yeah, all seems a bit dodgy. Just sticking with the good old hp/hp max approach. Cheers for the responses!

HegemonKhan
my bad, maybe I saw health being used in someone else's library~code, hmm... I am pretty sure that there is ...somewhere (lol)... that I've seen it being used. Pixie's got some many libraries, I just (wrongly) assumed he~she used 'health' in one of them.

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

Support

Forums