{DONE AND DONE} How to set an object's attributes according to what the player picked?

Hello! How do you set an object's attributes according to what the player picked? I was about to put it into code, but then realized I didn't know how to.

In my case, the player will pick a stereotype they can set for themselves. What I did first was show menu and put the result into player.type. Then, the player has these attributes called strength, beauty, intelligence, etc. The stereotype the player picks will determine what the value each of these attributes have.

I use the online version, by the way.


K.V.

Where is Anonynn?


Hello, Galactic_Comet!

(I just called out one of our resident experts for you.)


While we wait, you can peruse The Pixie's pertaining posts:

Let's see...

Seems like you've already read this one: http://docs.textadventures.co.uk/quest/guides/character_creation.html

Here's something that probably won't help, but you never know: https://textadventures.co.uk/forum/quest/topic/4035/making-a-character-creation-level-up-menu

This DOES look useful: https://textadventures.co.uk/forum/quest/topic/5089/solved-level-library-pixies

Ooh! This one looks pretty informative too: https://textadventures.co.uk/forum/samples/topic/5492/character-creation-questions-again


There are many other forum members who are well-versed in this area. I just called Anonynn out for fun. (And because I've witnessed her system in action, which I believe is built upon Pixie's.)


K.V.

It should be something along the lines of this though:

image

In Code View

if (player.stereotype) {
  player.strength + 10
  player.intelligence - 20
}
else if (player.other_stereotype) {
  player.strength - 20
  player.intelligence + 10
}

(Just using random attribute names and values, there. If you can post an example of your code, I can be more specific, if need be.)


I would have thought something more like…

switch (player.type) {
  case ("some stereotype") {
    player.strength = 10
    player.intelligence = 25
    player.beauty = 99
  }
  case ("another stereotype") {
    player.strength = 30
    player.intelligence = 30
    player.beauty = 30
  }
}

and so on.

Or an alternative method, which is more like how I'd probably end up doing it. You could put them in a list, though, so the data's all in one place. Something like:

// statistics for types: strength, intelligence, beauty, age, favourite colour
//    (I have no idea what kind of stereotypes you're using, so silly examples)
game.stats_for_brawler  = "60,15,20,18,red"
game.stats_for_nerd     = "10,99,12,16,orange"
game.stats_for_princess = "28,30,60,13,white"
game.stats_for_baby     = "3,2,4,1,pink"

// And then once you've chosen your type
stats = Split (GetString (game, "stats_for_"+player.type), ",")
player.strength     = ListItem(stats, 0)
player.intelligence = ListItem(stats, 1)
player.beauty       = ListItem(stats, 2)
player.age          = ListItem(stats, 3)
player.eyecolour    = ListItem(stats, 4)

I fixed it now. Thanks a lot for the stuff I needed.


K.V.

mrangel,

I aspire to one day be on your level.

I tried to set it up in a switch script, but no dice.

I wasn't feeding switch the correct parameter...


I learn at least one thing with each question posted on this forum, even when the question isn't mine!

It's so cool!


Sorry! I've been knee deep in busy-work this semester since I'm student teaching and when I'm not doing that I'm full-time with the family and the game @_@

As for the online version, I'm not sure if it's the same as the downloaded one, but I would do something like this. ((I hope this helps)).

switch (GetHighestAtt()) {
  case ("strength") {
  player.strength = player.strength + 1
  }
  case ("agility") {
player.agility = player.agility + 1
  }
  case ("intelligence") {
player.intelligence = player.intelligence + 1
  }
  case ("defense") {
player.defense = player.defense + 1
  }
}

That would be the way to do it if you're using a "Switch Script" but I recommend a menu for something like this or just a simple "If-Script".

Sorry I was late in the response!

Anonynn.


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

Support

Forums