Help with setting an attribute

Leon Kitsune
So I taught myself how to set attributes but this code will not work. For whatever reason Strength is not listed as an attribute even though its listed in the attributes box clear as day.

if (player.Class = ("Swordsman")) {
set (player, Strength, 10)

HegemonKhan
can we see the rest of your game code?

make sure you're keeping the names the same, caps vs lower case matters:

Strength
strength

these are two separate attributes.

also, the 'set (player, Strength, 10)' won't happen unless the condition, 'if (player.Class = ("Swordsman")), is met.

Also, if you created the 'Strength' Attribute from the GUI~Editor's 'Object -> add attribute', make sure you have it's Attribute Type as an integer~int:

'player' (object) -> Attributes (Tab) -> Attributes -> Add ->

Attribute Name: Strength
Attribute Type: int
Attribute Value = 0

--------

ah... oops, I just noticed a mistake you made (almost completely missed it), laughs..

you also need to change this:

if (player.Class = ("Swordsman")) {

to this:

if (player.Class = "Swordsman") {

--------

if it's still not working, let me know.

Leon Kitsune
Im still having trouble. When I have the script attached to the Attribute it doesn't really do anything but it doesn't say there is an error. This time I tried it with the script in the room and it said Strength was an unknown object or variable

Error running script: Error compiling expression 'Strength': Unknown object or variable 'Strength'

this is the script under attribute. (the ) made no difference)
if (player.Class = ("Swordsman")) {
set (player, Strength, 10)
}

here is the code in the room. which is what I changed to as an experiment.
if (player.Class = ("Swordsman")) {
set (player, Strength, 10)

HegemonKhan
you also need to change this:

if (player.Class = ("Swordsman")) {

to this:

if (player.Class = "Swordsman") {

---

if it's still not working, let me know.

----

are you trying to do this by actually writing in the code yourself, or are you using the GUI~Editor (has all the buttons, tabs,drop down menus, and etc) ???

----

if you don't mind posting your entire game code, it'd make it easy to fix it for you (if you don't know how to post your game code, and you don't mind doing so, let me know)

as I can't tell what the problem is, with what you just posted, as the problem exists elsewhere in your game code (aside from the un-needed parenthesis around your Value: "Swordsman")

Leon Kitsune
1: Posted same code twice (go me -_-)
2; removing one parentheses did not work
3: THIS is the other code

I changed the code to this one when the attribute code did not work. This triggered an error saying that Strength was an unknown variable or object despite it being an established status attribute.

ShowMenu ("What is your profession?", Split ("Swordsman;Mage;Archer;Knight", ";"), false) {
player.Class = result
set (player, Strength, 10)

HegemonKhan
I'm not familiar with the 'set' code, but maybe you need to also create the attribute first, which you do by this:

player (Object) -> Attributes (Tab) -> Attributes (*NOT* status attributes) -> Add ->

Attribute Name: Strength
Attribute Type: int (integer)
Attribute Value: 0

--------

'Status Attribiutes' is merely for the displayment of that attribute on the right side, during game play. But, the 'set' code, may require that you CREATE the attribute, which is NOT what a 'status attribute' is, you CREATE with adding an attribute to the Object.

--------

otherwise, I need to see your game code, as I can't figure out what you done, to thus be able to know what is causing the problem.

HegemonKhan
here's some links to help you:

1. http://quest5.net/wiki/Character_Creation
2. http://quest5.net/wiki/Showing_a_menu

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

Support

Forums