Is Flag the same thing as string? (solved)

I'd like to put a string skinnable on a creature so i can skin it, does it mean flag in the code? If not im a bit confused... I'm not advanced yet for coding much so i like to use the events system thank you ;)


(filler for getting my edited post, updated/posted)


difference between using Strings, Booleans ("flags"), and Lists/Dictionaries

(using the common conditions / status effects within rpgs for the conceptual example of the differences between the Attribute Types)


Strings:

(Only able to have a single Value/Effect at a time, but able to have multiple effects to select from, per String Attribute, but don't need a lot of Attributes, like you do if using Boolean Attributes)

(err, maybe this is more clear way of describing Strings: a single String Attribute can have multiple different effects/Values, but only one effect/Value of them at a time)

player.condition_string_attribute = "normal"
// or:
// player.condition_string_attribute = "dead"
// player.condition_string_attribute = "poisoned"
// player.condition_string_attribute = "paralyzed"
// player.condition_string_attribute = "asleep"

if (player.condition_string_attribute = "normal") {
  msg ("NORMAL")
} else if (player.condition_string_attribute = "dead") {
  msg ("DEAD")
} else if (player.condition_string_attribute = "asleep") {
  msg ("ASLEEP")
} else if (player.condition_string_attribute = "poisoned") {
  msg ("POISONED")
} else if (player.condition_string_attribute = "paralyzed") {
  msg ("PARALYZED")
}

Booleans ("flags"):

think of them as "light switches" which you can "flip/flag/toggle" on/off, but they use the special/reserved values of 'true' and 'false'

easiest to understand their usage, able to have multiple effects at the same time, but very cumbersome (need lots of Boolean Attributes, as you need a Boolean Attribute for each desired effect, and have to adjust some/all of them every time, you want to change the effect):

// player is 'normal' conditioned:

player.normal_boolean_attribute = true
player.dead_boolean_attribute = false
player.poisoned_boolean_attribute = false
player.asleep_boolean_attribute = false
player.paralyzed_boolean_attribute = false

// player is 'dead' conditioned:

player.normal_boolean_attribute = false
player.dead_boolean_attribute = true
player.poisoned_boolean_attribute = false
player.asleep_boolean_attribute = false
player.paralyzed_boolean_attribute = false

// player is 'poisoned' conditioned:

player.normal_boolean_attribute = false
player.dead_boolean_attribute = false
player.poisoned_boolean_attribute = true
player.asleep_boolean_attribute = false
player.paralyzed_boolean_attribute = false

// player is 'asleep' conditioned:

player.normal_boolean_attribute = false
player.dead_boolean_attribute = false
player.poisoned_boolean_attribute = false
player.asleep_boolean_attribute = true
player.paralyzed_boolean_attribute = false

// player is 'paralyzed' conditioned:

player.normal_boolean_attribute = false
player.dead_boolean_attribute = false
player.poisoned_boolean_attribute = false
player.asleep_boolean_attribute = false
player.paralyzed_boolean_attribute = true

// player is both 'poisoned' and 'paralyzed' conditioned:

player.normal_boolean_attribute = false
player.dead_boolean_attribute = false
player.poisoned_boolean_attribute = true
player.asleep_boolean_attribute = false
player.paralyzed_boolean_attribute = true

// player is "all of them" conditioned (doesn't make logical sense for this case/example I'm using, but this is just an example for you, lol):

player.normal_boolean_attribute = true
player.dead_boolean_attribute = true
player.poisoned_boolean_attribute = true
player.asleep_boolean_attribute = true
player.paralyzed_boolean_attribute = true

// player is "none of them" conditioned (doesn't make logical sense for this case/example I'm using, but this is just an example for you, lol):

player.normal_boolean_attribute = false
player.dead_boolean_attribute = false
player.poisoned_boolean_attribute = false
player.asleep_boolean_attribute = false
player.paralyzed_boolean_attribute = false

if (player.normal_boolean_attribute) {
  msg ("NORMAL")
} else {
  msg ("NOT NORMAL")
}

if (player.dead_boolean_attribute) {
  msg ("DEAD")
} else {
  msg ("NOT DEAD")
}

if (player.asleep_boolean_attribute) {
  msg ("ASLEEP")
} else {
  msg ("NOT ASLEEP")
}

if (player.poisoned_boolean_attribute) {
  msg ("POISONED")
} else {
  msg ("NOT POISONED")
}

if (player.paralyzed_boolean_attribute) {
  msg ("PARALYZED")
} else {
  msg ("NOT PARALYZED")
}

Lists/Dictionaries:

(too tired/lazy, so no Dictionary examples)

pretty much the same as Strings, except can hold multiple values at the same time unlike a String

(a bit more code work and more code complexity, but is more efficient than using Strings and Booleans, for larger/greater scale/complexity of game design/mechanics/systems)

player.condition_stringlist_attribute = NewStringList ()

list add (player.condition_stringlist_attribute, "normal")
// player is only 'normal' conditioned

// (continuing from the above state)
list remove (player.condition_stringlist_attribute, "normal")
list add (player.condition_stringlist_attribute, "dead")
// player is only 'dead' conditioned

// (continuing from the above state)
list remove (player.condition_stringlist_attribute, "dead")
list add (player.condition_stringlist_attribute, "poisoned")
list add (player.condition_stringlist_attribute, "paralyzed")
// player is both 'poisoned' and 'paralyzed' conditioned

// (continuing from the above state)
list remove (player.condition_stringlist_attribute, "poisoned")
list remove (player.condition_stringlist_attribute, "paralyzed")
list add (player.condition_stringlist_attribute, "asleep")
// player is only 'asleep' conditioned

// (continuing from the above state)
list add (player.condition_stringlist_attribute, "normal")
list add (player.condition_stringlist_attribute, "dead")
list add (player.condition_stringlist_attribute, "paralyzed")
list add (player.condition_stringlist_attribute, "poisoned")
// player is "all of them" (normal, asleep, dead, paralyzed, poisoned) conditioned

// (continuing from the above state)
list remove (player.condition_stringlist_attribute, "normal")
list remove (player.condition_stringlist_attribute, "dead")
list remove (player.condition_stringlist_attribute, "paralyzed")
list remove (player.condition_stringlist_attribute, "poisoned")
list remove (player.condition_stringlist_attribute, "asleep")
// player is "none of them" conditioned

// for a numbered/ordered list:

DisplayList (player.condition_stringlist_attribute, 1)
// or (not sure on the 2nd argument/parameter type):
DisplayList (player.condition_stringlist_attribute, true)

1 <===> true <===> yes <===> on <===> + (for example positive polarity/electrical charges in chemistry/physics)

// for a NOT numbered/ordered list:

DisplayList (player.condition_stringlist_attribute, 0)
// or (not sure on the 2nd argument/parameter type):
DisplayList (player.condition_stringlist_attribute, false)

0 <===> false <===> no <===> off <===> - (for example negative polarity/electrical charges in chemistry/physics)

and/or:

if (ListContains (player.condition_stringlist_attribute, "normal")) {
  msg ("NORMAL")
} else {
  msg ("NOT NORMAL")
}

if (ListContains (player.condition_stringlist_attribute, "dead")) {
  msg ("DEAD")
} else {
  msg ("NOT DEAD")
}

if (ListContains (player.condition_stringlist_attribute, "asleep")) {
  msg ("ASLEEP")
} else {
  msg ("NOT ASLEEP")
}

if (ListContains (player.condition_stringlist_attribute, "poisoned")) {
  msg ("POISONED")
} else {
  msg ("NOT POISONED")
}

if (ListContains (player.condition_stringlist_attribute, "paralyzed")) {
  msg ("PARALYZED")
} else {
  msg ("NOT PARALYZED")
}

Easiest for me is...

If you need to kill this thing first to skin it, just add flag (flagname ‘skin1’ (or something like that)) upon the things death. Then add a verb ‘skin’ to the thing. Finally, if thing has flag ‘skin1’, then add whatever scripts you want to happen while skinning. Also, add an else script here to print a message like “You can’t skin that thing. It’s still alive!”

I’ve also had luck with removing the “living object” from the game once it is dead and replacing it with a “carcass” once it’s killed. That way it keeps your scripts totally separate and the player will never know a difference!

Or... if skinning it is killing it, then just add a flag to the critter right off the bat and add your skin scripts to the verb.

If you’d like a simple example, I’ll be glad to provide.


Yes that works great ty ;)!!!


Log in to post a reply.

Support

Forums