[SOLVED] Syntax help :)

Anonynn
I'm having trouble wording one of my scripts. Here it is...

if (this.cursecount = 105) {
("")
if (not player.hairlength = "long") {
}
else {
SetTo("hairlength", "long")
}
}


Now this is okay of itself, but my question is....er...okay. Here's a better way of stating this...

player.hairlength: buzzed 0, short 1, shoulder length 2, long 3, very long 4, extremely long 5, dragging on the ground long 6.

Here are the variables (listed above). The script will make any hairlength turn into the one marked in bold. So I was wondering, how would I put that in a msg(""). Like if the player's hair is longer than "long", I would want to describe it shrinking in a message and if it's shorter, than I want to describe it in a message as growing.

I thought of doing...

if (player.hairlength_as_int >3) {
msg("your hair shrinks in length! Argh!")
SetTo("hairlength", "long")
}
else if (player.hairlength_as_int <3) {
msg("your hair is growing, egads!")
SetTo("hairlength", "long")
}
else {
if player.hairlength_as_int = 3) {
msg ("You feel something happening to your hair, but it turns out to be nothing.")
}
}


But for some reason (haven't tested it) I was thinking this wouldn't work. Any suggestions? I might not be focusing clearly though because I'm tired.

HegemonKhan
most of quest's commands (scripts/functions/attributes/etc):

(look through these, to try to find the command for what you want to do)

http://docs.textadventures.co.uk/quest/scripts/
http://docs.textadventures.co.uk/quest/functions/ (categorical order)
http://docs.textadventures.co.uk/quest/ ... tions.html (alphabetical order)
http://docs.textadventures.co.uk/quest/scopes.html

http://docs.textadventures.co.uk/quest/ ... /game.html
http://docs.textadventures.co.uk/quest/ ... bject.html

the 'set' Script~Function (in/under the 'scripts' link in quest doc site):

http://docs.textadventures.co.uk/quest/scripts/set.html

examples:

(the first parameter, Object Name, must NOT be in double quotes)
(the middle/second parameter, Attribute Name, MUST BE IN double quotes)
(the third/last paramter, Attribute Value/Expression, depends on its attribute type)

set (player, "hair_length_as_string", "long") // or: player.hair_length_as_string = "long"
set (player, "hair_length_as_integer", 3) // or: player.hair_length_as_integer = 3
set (orc, "dead", false) // or: orc.dead = false
set (game.pov, "alias", "Neonayon") // or: game.pov.alias = "Neonayon"
set (hegemonkhan, "strength_as_string", "strong") // or: hegemonkhan.strength_as_string = "strong"
set (hegemonkhan, "strength_as_integer", 100) // or: hegemonkhan.strength_as_integer = 100
set (game, "pov", Neonayon) // or: game.pov = Neonayon
set (game, "pov", player) // or: game.pov = player
set (game, "pov", HegemonKhan) // or: game.pov = Hegemonkhan
set (game, "greeting", "hello, new player...") // or: game.greeting = "hello, new player..."

--------------

the 'greater than', 'lesser than', and etc operators:

obviously, you need numbers for this comparison, some examples

if (player.hair_length_as_integer = 3 and not player.hair_length_as_string = "long") {
player.hair_length_as_string = "long"
msg ("Your hair is now long.")
}

if (player.hair_length_as_integer > 3) {
msg ("Sorry, but for some reason, your hair currently is blocked from growing longer than length 3:"long", so it shrinks back to 3:long")
player.hair_length_as _integer = 3
player.hair_length_as_string = "long"
}

if (player.hair_length_as_integer < 3) {
msg ("Sorry, but for some reason, your hair currently is blocked from shrinking shorter than length 3:"long", so it grows back to 3:long")
player.hair_length_as _integer = 3
player.hair_length_as_string = "long"
}

// combing the two blocks above:

if (player.hair_length_as_integer < 3 and player.hair_length_as_integer > 3) {
msg ("Sorry, but for some reason, your hair currently is blocked from, shrinking shorter or growing longer, than length 3:"long", so it, shrinkgs or grows, back to 3:long")
player.hair_length_as _integer = 3
player.hair_length_as_string = "long"
}

// combining the top 3 blocks of this code box together (and extra stuff for completeness):

if (player.hair_length_as_integer = 3 and not player.hair_length_as_string = "long") {
player.hair_length_as_string = "long"
msg ("Your hair is now long.")
} else if (player.hair_length_as_string = "long" and not player.hair_length_as_integer = 3) {
player.hair_length_as_integer = 3
} else if (player.hair_length_as_string = "long") {
msg ("Your hair is already long")
} else {
msg ("Sorry, but for some reason, your hair currently is blocked from, shrinking shorter or growing longer, than length 3:"long", so it, shrinkgs or grows, back to 3:long")
player.hair_length_as _integer = 3
player.hair_length_as_string = "long"
}


actually, ALL SYMBOLS~CHARACTERS (the 'char' data/attribute type: uses single quotes, as opposed to the double quotes for string data/attribute types, haven't tested if/how quest uses 'char' or not) have a numeric value:

http://www.asciitable.com/ (U.S.)
https://en.wikipedia.org/wiki/List_of_U ... characters (international)

for example:

ASCII:

'A' (char data/attribute type) = 65
'a' (char data/attribute type) = 97

thus:

if ('A' < 'a') -> TRUE
if ('A' > 'a') -> FALSE

this is how:

my_variable = "HK"
if (my_variable = "HK") -> TRUE
// if ("HK" = "HK") -> TRUE

my_variable = "Neonayon"
if (my_variable = "HK") -> FALSE
// if ("Neonayon" = "HK") -> TRUE

works, it compares char by char, as seen below:

if ("ab" < "az") -> ???

if (a:97 < a:97) -> (so far it's) FALSE (but we're not done, there's more chars to compare)
if (b:98 < z:122) -> TRUE

--

if ("ab" = "az") -> ???

if (a:97 = a:97) -> (so far it's) TRUE (but we're not done, there's more chars to compare)
if (b:98 = z:122) -> FALSE

--

if ("ab" > "az") -> ???

if (a:97 > a:97) -> (so far it's) FALSE (but we're not done, there's more chars to compare)
if (b:98 > z:122) -> FALSE

XanMag
Is length of hair set to grow with turns taken and set to change with events like haircuts or potions?

If so, I'll share I useful script Jay helped me with (which seems to have a similar format).

Anonynn
if (player.hairlength_as_int >3) {
msg ("your hair shrinks in length! Argh!")
SetTo ("hairlength", "long")
}
else if (player.hairlength_as_int <3) {
msg ("your hair is growing, egads!")
SetTo ("hairlength", "long")
}
else if (player.hairlength = "long") {
msg ("You feel something happening to your hair, but it turns out to be nothing.")
}

This actually this worked when I tried it in the morning! Sorry about that everyone! I appreciate the help though HK and Xan!

If it's okay though Xan, I would still like to see the script anyway ^_^

XanMag
  <object name="twentyfourhours">
<inherit name="editor_object" />
<HoursCount type="int">0</HoursCount>
<currenttime type="object">morning</currenttime>
<changedcurrenttime type="script">
Setcurrentbats (this.currenttime.bats)
if (XanaduIsInside()) {
do (this.currenttime, "startinside")
}
else {
do (this.currenttime, "startoutside")
}
</changedcurrenttime>
<changedHoursCount type="script">
if (twentyfourhours.HoursCount = 1) {
twentyfourhours.currenttime = dawn
MoveObject (children, hut)
MoveObject (children1, village outskirts)
MoveObject (fisherman, north shore)
MoveObject (juju man, Item WH2)
MoveObject (woman1, hut)
}
else if (twentyfourhours.HoursCount = 15) {
twentyfourhours.currenttime = morning
MoveObject (children, hut)
MoveObject (children1, village outskirts)
MoveObject (fisherman, north shore)
MoveObject (juju man, shack)
MoveObject (woman1, hut)
}
else if (twentyfourhours.HoursCount = 30) {
twentyfourhours.currenttime = noon
MoveObject (children, hut)
MoveObject (children1, village outskirts)
MoveObject (fisherman, north shore)
MoveObject (juju man, shack)
MoveObject (woman1, hut)
}
else if (twentyfourhours.HoursCount = 45) {
twentyfourhours.currenttime = afternoon
MoveObject (children, hut)
MoveObject (children1, village outskirts)
MoveObject (fisherman, north shore)
MoveObject (juju man, shack)
MoveObject (woman1, hut)
}
else if (twentyfourhours.HoursCount = 60) {
twentyfourhours.currenttime = dusk
MoveObject (children, hut)
MoveObject (children1, village outskirts)
MoveObject (fisherman, north shore)
MoveObject (juju man, shack)
MoveObject (woman1, hut)
}
else if (twentyfourhours.HoursCount = 75) {
twentyfourhours.currenttime = evening
MoveObject (children, hut)
MoveObject (children1, village outskirts)
MoveObject (fisherman, Item WH2)
MoveObject (woman1, hut)
MoveObject (juju man, Item WH2)
}
else if (twentyfourhours.HoursCount = 90) {
twentyfourhours.currenttime = midnight
MoveObject (children, Item WH2)
MoveObject (children1, Item WH2)
MoveObject (juju man, cemetery)
MoveObject (fisherman, Item WH2)
MoveObject (woman1, Item WH2)
}
else if (twentyfourhours.HoursCount = 105) {
twentyfourhours.currenttime = dawn2
}
else if (twentyfourhours.HoursCount = 120) {
twentyfourhours.HoursCount = 1
}
</changedHoursCount>


There's much more to it than that, but this is what I think is applicable in your case.

Obviously, you would use If (player.hairlength = 10) in place of my twentyfourhours.HoursCount
Then, you could refer to If (player.hairlength = 10) when you look at the character or whatever.

You could also set player.hairlength = 10 (or 20, or 0, or 30, or whatever) when you get a haircut or drink a potion. I have that equivalent set up as a command. For example, "wait for midnight" runs this --> set (twentyfourhours, "HoursCount", 89)

Now that I look at it, what we have is fairly similar, right?

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

Support

Forums