More than one status attributes

Bttflover5566
27 Mar 2019, 10:56

Ok, so I want to add six status attributes, but when I try only the last one shows up. This is how I coded it:

set (player, "Agility", 10)
set (player, "statusattributes", NewStringDictionary())
dictionary add (player.statusattributes, "Agility", "Agility: !")
set (player, "Strength", 10)
set (player, "statusattributes", NewStringDictionary())
dictionary add (player.statusattributes, "Strength", "Strength: !")
set (player, "Speed", 10)
set (player, "statusattributes", NewStringDictionary())
dictionary add (player.statusattributes, "Speed", "Speed: !")
set (player, "Intelligence", 10)
set (player, "statusattributes", NewStringDictionary())
dictionary add (player.statusattributes, "Intelligence", "Intelligence: !")
set (player, "Thirst", 100)
set (player, "statusattributes", NewStringDictionary())
dictionary add (player.statusattributes, "Thirst", "Thirst: !")
set (player, "Hunger", 100)
set (player, "statusattributes", NewStringDictionary())
dictionary add (player.statusattributes, "Hunger", "Hunger: !")
}


mrangel
27 Mar 2019, 12:21

Going line-by-line through that code, here's what you're doing:

  • set (player, "Agility", 10) - Create a stat called 'Agility' and set it to 10
  • set (player, "statusattributes", NewStringDictionary()) - Make a blank dictionary to hold the status attributes
  • dictionary add (player.statusattributes, "Agility", "Agility: !") - Add Agility to that dictionary
  • set (player, "Strength", 10) - Create a stat called 'Strength' and set it to 10
  • set (player, "statusattributes", NewStringDictionary()) - Make a blank dictionary to hold the status attributes
  • dictionary add (player.statusattributes, "Strength", "Strength: !") - Add Strength to that dictionary
  • set (player, "Speed", 10) - Create a stat called 'Speed' and set it to 10
  • set (player, "statusattributes", NewStringDictionary()) - Make a blank dictionary to hold the status attributes
  • dictionary add (player.statusattributes, "Speed", "Speed: !") - Add Speed to that dictionary
  • set (player, "Intelligence", 10) - Create a stat called 'Intelligence' and set it to 10
  • set (player, "statusattributes", NewStringDictionary()) - Make a blank dictionary to hold the status attributes
  • dictionary add (player.statusattributes, "Intelligence", "Intelligence: !") - Add Intelligence to that dictionary
  • set (player, "Thirst", 100) - Create a stat called 'Thirst' and set it to 100
  • set (player, "statusattributes", NewStringDictionary()) - Make a blank dictionary to hold the status attributes
  • dictionary add (player.statusattributes, "Thirst", "Thirst: !") - Add Thirst to that dictionary
  • set (player, "Hunger", 100) - Create a stat called 'Hunger' and set it to 100
  • set (player, "statusattributes", NewStringDictionary()) - Make a blank dictionary to hold the status attributes
  • dictionary add (player.statusattributes, "Hunger", "Hunger: !") - Add Hunger to that dictionary

If you're copying and pasting code that you've been given, it's a good idea to try to understand what each line does. In this case, you just need to make sure that the NewStringDictionary line only occurs once. But hopefully if you can understand how the code works, you won't run into similar probalems so often in future.


Bttflover5566
27 Mar 2019, 19:49

Thank you! This helps me understand a lot better