Few simple questions - eat / exit name changing

Novirtue
For now I have two questions which I hope are simple questions.

I am trying to make a zombie game, where the player is a zombie, I have a hunger counter that increases over time.

1) Is there a way that after I eat a person to reduce hunger as well as restore health? On the browser version the edible tab only allows me to make a change to the health, is it possible to customize it to change a different variable in the game, such as the hunger stat?

2) Also, another quick question when it comes to naming exits, I want to have a hallway with multiple west exits, I can't figure out when someone tries to go west, how to make them read different from the game interface, I've tried changing suffix/prefix/alias, but when I write: "West" it says:

1. west
2. west
3. west

HegemonKhan
there's only the "score" and "health" built-in functions which use a percentile (which I still have trouble in understanding, lol).

so, you simply have to create your own (custom) attributes yourself.

I'm not familiar with the browser~on-line version, but I think you got to use the "game" Object's "start" script to create attributes.

In the GUI~Editor (off-line~desktop) version:

"game" -> Scripts (Tab) -> Start -> Add a script -> Variables -> Set a variable or an attribute -> (see examples below)

Object.Attribute = Value_or_Expression
game.Attribute = Value_or_Expression

game.player_health = 999
game.player_hunger = 99
game.player_damage = 100
game.player_agility = 75
game.zombie_dead = false
game.zombie_health = 500
game.zombie_dexterity = 25
game.zombie_damage = 50

(if you can use~have other Objects, then you can use them instead of the "game" object, again I never used the browser version before. for example, it would look like this: player.agility = 75)

and then to change it, you use the same syntax in a script, an example (in code, as I'm lazy) of a bit more advanced scripting:

"fight" Verb Scripting (not sure how this is done in the browser version):

(my arrows ' -> ' on the far left, merely indicate the indenting~nesting required, so you don't actually write them into the code)

if (game.zombie_dead = false) {
-> if (game.zombie_dexterity > game.player_agility) {
->-> game.player_health = game.player_health - game.zombie_damage
->-> msg ("The zombie hits you for " + game.zombie_damage + " damage, and you now have only " + game.player_health + " health left.")
->-> if (game.player_health <= 0) {
->->-> msg ("You were killed by the zombie.")
->->-> msg ("GAME OVER")
->->-> finish
->-> }
-> } else if (game.zombie_dexterity <= game.player_agility) {
->-> game.zombie_health = game.zombie_health - game.player_damage
->-> msg ("You damage the zombie for " + game.player_damage + " health, and now it only has " + game.zombie_health + " health left.")
->-> if (game.zombie_health <= 0) {
->->-> game.zombie_dead = true
->->-> msg ("You killed the zombie.")
->-> }
-> }
} else if (game.zombie_dead = true) {
-> msg ("The zombie is already dead, silly.")
}

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

in the desktop~offline version, you can type in (change) the name that is given to the direction in one of the Editor's boxes (I don't have the editor up, so I don't know exactly what the text box is called for it), while still maintaining the same assigned direction. So, maybe if you can't see~find it, then the browser~on-line version doesn't have that option... (though you may be able to still change it, via the "start" script possibly, though you'd need to know the coding to do so, if it is possible).

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

for the desktop~off-line version:

in code:

Object.Attribute = Value_or_Expression

examples of 'as Values':

player.current_hit_points = 999
player.maximum_hit_points = 999

examples of 'as Expressions' (for these examples, computational Expressions):

Addition:

player.current_hit_points = player.current_hit_points + 100
// conceptually: player.current_hit_points (new) = 999 (old) + 100 (Value)
// new 'cur hp': 1099

Subtraction:

player.current_hit_points = player.current_hit_points - 500
// conceptually: player.current_hit_points (new) = 999 (old) - 500 (Value)
// new 'cur hp': 499

Multiplication:

player.current_hit_points = player.current_hit_points * 2
// conceptually: player.current_hit_points (new) = 999 (old) * 2 (Value)
// new 'cur hp': ~ 2000

Division:

player.current_hit_points = player.current_hit_points / 10
// conceptually: player.current_hit_points (new) = 999 (old) / 10 (Value)
// new 'cur hp': ~ 100

---------

if (player.current_hit_points > 999) {
-> player.current_hit_points = 999
}

if (player.current_hit_points > player.maximum_hit_points) {
-> player.current_hit_points = player.maximum_hit_points
}

using a '50 hp potion', it's "drink" Verb scripting:

player.current_hit_points = player.current_hit_points + 50
msg ("You drank the potion, restoring 50 of your hp.")

"eating" Verb (of a "zombie" Object):

(remember that you have to create~add~set the Object.Attribute, ie "player.hunger = 99", before the below script can work)

player.hunger = player.hunger + 50
msg ("You ate the zombie, restoring 50 points back to your hunger level.")

in the GUI~Editor (again for the desktop~off-line version), to create~add~set Attributes:

"whatever" Object -> Attributes (Tab) -> Attributes -> Add -> (some examples below)

Object: "player" (the default Player Object)
Attribute Name: health_x (this, the added "_x", is so that I don't over-write the built-in "health" functioning, in case I want to still use it too)
Attribute Type: int (integer)
Value: 999

Object: "game" (the Game Object)
Attribute Name: hunger
Attribute Type: int
Attribute Value: 99

Object: "zombie"
Attribute Name: dead
Attribute Type: boolean
Attribute Value: false

Object: "HK"
Attribute Name: favorite_color_string
Attribute Type: string
Attribute Value: black

Object: "HK"
Attribute Name: favorite_colors_string_list
Attribute Type: stringlist
Attribute Value: black; red

Novirtue
This helps, thanks a lot.

HegemonKhan
let me know if you got any questions, or need any help with anything. I don't explain things clearly, so if you're confused by anything, feel free to say so, and I'll try to make it more clear for you so you can understand it.

because the ">" and "<" characters are used for the 'tagging' in coding, when you want to use these characters for their computational meaning (greater than and lesser than), you need to add this (only when typing in your code directly):

<![CDATA[ (your scriptings) ]]>

(an example)

<object name="zombie_1">
<inherit name="editor_object" />
<alias>zombie</alias>
<attr name="dead" type="boolean">false</attr>
<attr name="hit_points" type="int">100</attr>
<attr name="fight" type="script"><![CDATA[
if (this.dead = true) {
msg ("The zombie is already dead, silly.")
} else if (this.dead = false) {
if (player.speed > this.speed) {
this.hit_points = this.hit_points - player.damage
msg ("You damage the " + this.alias + " for " + player.damage + " points, and this.article now has only " + this.hit_points + " HPs left.")
if (this.hit_points <= 0) {
this.dead = true
}
} else {
player.hit_points = player.hit_points - this.damage
msg ("You're damaged for " + this.damage + " points, and you now have only " + player.hit_points + " HPs left.")
if (player.hit_points <= 0) {
msg ("GAME OVER")
}
}
}
]]></attr>
<attr name="ingest" type="script">
if (this.dead = true) {
player.hit_points = player.hit_points + 50
player.hunger = player.hunger + 10
msg ("You eat the zombie, restoring 50 of your HPs and 10 of your hunger level.")
} else if (this.dead = false) {
msg ("The zombie is still alive, you'll have to kill it first, before you can eat it.")
}
</attr>
<attr name="displayverbs" type="listextend">Fight;Eat</attr>
</object>

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

Support

Forums