Setting Game Stats

Hello everyone quick code question here.

show menu ("What ship do you choose?", Split ("Freight Master 091;Bubble 101C;Ifrit 91C", ";"), false) {
  player.class = result
}

Here I have my mini menu that allows the player to choose a ship but my question is how would I use the ship choice result to set the future stats for my player?
Sorry if this a repeat question, I just can`t find this on the forum and also this is a gamebook, not a text adventure.


(whatever Page Object) -> 'Page' Tab -> Page Type: [script] or [script + text] -> (see below)

add new script -> 'scripts' section/category -> 'if' Script or 'switch' Script -> (see below)

// using the 'if' Script:

if [EXPRESSION] player.class = "Freight Master 091"
-> then -> add new script -> (whatever script/s you want done)
else if [EXPRESSION] player.class = "Bubble 101C"
-> then -> add new script -> (whatever script/s you want done)
else if [EXPRESSION] player.class = "Ifrit 91C"
-> then -> add new script -> (whatever script/s you want done)

// using the 'switch' Script:
// (however it's done via the GUI/Editor)
// (I'm using in-code scripting below, as I don't know the GUI/Editor stuff for using the 'switch' Script)

switch (player.class) {
  case ("Freight Master 091") {
    // whatever scripting (script/s)
  }
  case ("Bubble 101C") {
    // whatever scripting (script/s)
  }
  case ("Ifrit 91C") {
    // whatever scripting (script/s)
  }
}

if [EXPRESSION] player.class = "Freight Master 091" Would I leave the Expression as it is or fill it in with something? Thank you for your help


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


leave it as is... it should work, but if not, let me know, and we'll track down what errors you got in your code


how 'if/switch' (conditionals) works, an example:

string comparisons

string_variable = "dragon"

if (string_variable = "dragon") {
  msg ("Match!")
} else {
  msg ("NO match")
}

// if (string_variable = "dragon") {
// if ([string_variable = "dragon"] = "dragon") {
// if (["dragon"] = "dragon") {
// if (["d"] = "d") { ---> true
// if (["r"] = "r") { ---> true
// if (["a"] = "a") { ---> true
// if (["g"] = "g") { ---> true
// if (["o"] = "o") { ---> true
// if (["n"] = "n") { ---> true
// if (["dragon"] = "dragon") { ---> TRUE ---> msg ("Match!") 

// --------------------------

string_variable = "dragoN"

if (string_variable = "dragon") {
  msg ("Match!")
} else {
  msg ("NO match")
}

// if (string_variable = "dragon") {
// if ([string_variable = "dragoN"] = "dragon") {
// if (["dragoN"] = "dragon") {
// if (["d"] = "d") { ---> true
// if (["r"] = "r") { ---> true
// if (["a"] = "a") { ---> true
// if (["g"] = "g") { ---> true
// if (["o"] = "o") { ---> true
// if (["N"] = "n") { ---> false
// if (["dragoN"] = "dragon") { ---> FALSE ---> msg ("NO match") 

// ---------------------

string_variable = "dragon"

if (string_variable = "dragoN") {
  msg ("Match!")
} else {
  msg ("NO match")
}

// if (string_variable = "dragoN") {
// if ([string_variable = "dragon"] = "dragoN") {
// if (["dragon"] = "dragoN") {
// if (["d"] = "d") { ---> true
// if (["r"] = "r") { ---> true
// if (["a"] = "a") { ---> true
// if (["g"] = "g") { ---> true
// if (["o"] = "o") { ---> true
// if (["n"] = "N") { ---> false
// if (["dragon"] = "dragoN") { ---> FALSE ---> msg ("NO match") 

it's the same as algebra, but unfortunately, rarely does a math teacher explain that what you're doing is (amount/number) comparison (the "=" operation/symbol is: "is A equal-to/same-as B")

algebra as programming logic:

// N = 10
// is (N = 10) ?

(N + 10) = (20)
is (N + 10) the same as (20) ?

// ([N = 10] + 10) = (20)
// ([10] + 10) = (20)
// (20) = (20) ---> true
// (N + 10) = (20) ---> TRUE: N=10

algebra:

// (N + 10) = (20)
// (N + 10 -10) = (20 - 10)
// (N) = (10)


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

Support

Forums