I still need help increasing weight attribute based on food consumption

finnthefeeder
29 May 2017, 01:38

Can anybody help me I already have the attribute set to weight and the players weight starts at 110 lbs however i cant find a way to increase or decrease it by interacting with objects in the game please help soon


DarkLizerd
29 May 2017, 03:10

You have a apple.
you use the verb "eat"
add a script:
msg ("You eat the apple and it tasted great!")
player.weight = player.weight+3
(should work.)


finnthefeeder
29 May 2017, 03:26

@DarkLizerd
tried doesn't work for me can u post code if u can get that to work for you i might just be misinterpreting it


DarkLizerd
29 May 2017, 03:47

Did you add an attribute "weight" with a value " " (no value)
then, when you play, Status would show "Weight: 110"
then, eat the apple, Weight: 113
(I used an apple to eat.)


finnthefeeder
29 May 2017, 03:49

add attribute weight to player or food or both?


finnthefeeder
29 May 2017, 03:53

in "status attribute" i had the "key" set to "weight" and the "value" set to "weight: ! lbs"
while in attribute i set key to "weight" I set integer to "110" which translates to her status reading "weight 110 lbs" but as you know i want it to increase


finnthefeeder
29 May 2017, 03:54

thank you for your help by the way


hegemonkhan
29 May 2017, 04:22

which Object did you add 'weight' to? the 'player' Player Object or the 'game' Game Settings Object ???

// if the 'game' Game Settings Object:

<game name="NAME_OF_YOUR_GAME">
  <attr name="weight" type="int">0</attr>
  <attr name="statusattributes" type="simplestringdictionary">weight = Weight: ! Lbs</attr>
</game>

example scripting:

game.weight = game.weight + 5

// ------------------------------------------------------

// if the 'player' Player object:

<object name="player">
  <attr name="weight" type="int">0</attr>
  <attr name="statusattributes" type="simplestringdictionary">weight = Weight: ! Lbs</attr>
</object>

example scripting:

player.weight = player.weight + 5

Also, is your 'weight' an Integer Attribute or a String Attribute? if it's a string, that's why it's not doing the addition arithmetic operation... arithemetic addition operations require numbers (integers: non-decimal numbers, or doubles: decimal numbers).

game.integer_attribute = 47
game.string_attribute = "47"

anything in double quotes, is a String Data Type

addition (math-arithmetic) operation:

game.sum = 5 + 5
// game.sum = 10

game.sum = 55 + 55
// game.sum = 110

concatenation (non-arithemetic/non-math: literally putting things together: aka using strings, not numbers) operation:

game.concatenation = "5" + "5"
// game.concatenation = "55"

game.concatenation = "55" + "55"
// game.concatenation = "5555"

game.concatenation = "mama" + "mia"
// game.concatenation = "mamamia"

game.concatenation = "mama" + " " + "mia"
// game.concatenation = "mama mia"

game.concatenation = "mama" + " mia"
// game.concatenation = "mama mia"

game.concatenation = "mama " + "mia"
// game.concatenation = "mama mia"

game.concatenation = "mama" + "5"
// game.concatenation = "mama5"

game.concatenation = "mama" + "5" + "mia"
// game.concatenation = "mama5mia"


here's some links/guides on this stuff:

http://textadventures.co.uk/forum/samples/topic/5559/attributes-and-if-script-guide-by-hk (scripting: Attributes and the 'if' Script usage)

http://textadventures.co.uk/forum/quest/topic/5387/i-really-need-help#37375 (a step by step guide/walkthrough demo game on the basics of Attribute usage, including statusattributes)


DarkLizerd
29 May 2017, 04:28

My code worked...
This is my test program for ideas...
go south, fight the dummy, get hurt, and eat the apple.
(and no, the apple does not go away...)


DarkLizerd
29 May 2017, 04:28

finnthefeeder
29 May 2017, 04:38

im adding weight to the player but i want what she eats to determine how much weight that will be


DarkLizerd
29 May 2017, 04:39

I got a test code that I gota wait to post that works.


DarkLizerd
29 May 2017, 04:42
     <inherit name="editor_object" />
     <inherit name="edible" />
     <displayverbs type="stringlist">
       <value>Look at</value>
       <value>Take</value>
     </displayverbs>
     <eat type="script">
       msg ("You eat the apple and it tasted great!")
       player.weight = player.weight+3
       IncreaseHealth (3)
     </eat>
     <take />
     <feature_edible />
     <eathealth type="int">2</eathealth>
     <eatmsg>You feal better</eatmsg>
     <inventoryverbs type="stringlist">
       <value>Look at</value>
       <value>Use</value>
       <value>Drop</value>
     </inventoryverbs>
   </object>
 </object>

hegemonkhan
29 May 2017, 04:49

edited more into my previous post just now, sorry about that, but you may want to refresh and re-look at it, as it might help you.


"I want what she eats to determine how much weight that will be (finnthefeeder)"

an example:

<object name="player">
  <attr name="my_weight" type="int">0</attr>
  <attr name="statusattributes" type="simplestringdictionary">my_weight = Weight: ! Lbs</attr>
</object>

<object name="hamburger">
  <attr name="displayverbs" type="listextend">consume_verb</attr>
  <attr name="inventoryverbs" type="listextend">consume_verb</attr>
  <attr name="consume_verb" type="script">
    player.my_weight = player.my_weight + 50
  </attr>
</object>

<object name="salad">
  <attr name="displayverbs" type="listextend">consume_verb</attr>
  <attr name="inventoryverbs" type="listextend">consume_verb</attr>
  <attr name="consume_verb" type="script">
    player.my_weight = player.my_weight + 1
  </attr>
</object>

<verb name="consume_verb">
  <property>consume</property>
  <pattern>consume</pattern>
  <defaultexpression>You can't consume that!</defaultexpression>
</verb>

<command name="consume_command"> // using 'consume' as there's already a built-in 'eat' Command/Verb... though you can  alter the 'eat' Verb for a specific Object only, so that means, you can keep it unchanged for all the other Objects that you want to have the default 'eat' scripting.
  <pattern>consume #object_parameter#</pattern>
  <script>
    switch (object_parameter) {
      case (hamburger) {
        player.my_weight = player.my_weight + 50
      }
      case (salad) {
        player.my_weight = player.my_weight + 1
      }
      default {
        msg ("You can't consume that! (Wrong Object, try again)")
      }
    }
  </script>
</command>

@ Dark Lizard:

Thank you for/to your post! (as I forgot to add in the 'displayverbs' and 'inventoryverbs', lol)


edited: changed 'weight' to 'my_weight', as 'weight' is already a built-in Attribute


Anonynn
03 Jun 2017, 20:37

Player Object, Attributes

Make an int attribute.

player.weight (int) (110)

Food Object
CONSUME VERB
Script
msg("You eat da food, man.")
player.weight = player.weight + 20 (or whatever number you want)
or
player.weight = player.weight - 20.


finnthefeeder
14 Jun 2017, 02:39

SOLVED thank you all especially @Anonynn