Function Help (Urgh!!!!! >.< )

Okay, I have tried a MILLION different ways to do this and about 4 hours of straight failure, plus another three hours last night.

I can't seem to get this fking function to work properly.

Here is the Player Object code for it.

SetSexuality
if (player.sexualityscale<1) {
  if (player.orientation="asexual") {
    player.sexualityscale = 0
  }
  else {
    player.sexualityscale = 1
  }
}
if (player.sexualityscale>25) {
  player.sexualityscale = 25
}

which activates THIS function.

 <function name="SetSexuality">
    player.orientation = GetSexuality()
  </function>

which activates THIS function.

 <function name="GetSexuality" type="string"><![CDATA[
	if (player.sexualityscale = 0) {
	      return ("asexual")
	}
	 else if (player.sexualityscale = 1) {
      return ("straight")
    }
    else if (player.sexualityscale = 2) {
      return ("straight")
    }
    else if (player.sexualityscale = 3) {
      return ("straight")
    }
    else if (player.sexualityscale = 4) {
      return ("straight")
    }
    else if (player.sexualityscale = 5) {
      return ("straight")
    }
    if (player.sexualityscale = 6) {
      return ("bi-curious")
    }
    else if (player.sexualityscale = 7) {
      return ("bi-curious")
    }
    else if (player.sexualityscale = 8) {
      return ("bi-curious")
    }
    if (player.sexualityscale = 9) {
      return ("bi-curious")
    }
    else if (player.sexualityscale = 10) {
      return ("bi-curious")
    }
    if (player.sexualityscale = 11) {
      return ("bisexual")
    }
    else if (player.sexualityscale = 12) {
      return ("bisexual")
    }
    if (player.sexualityscale = 13) {
      return ("bisexual")
    }
    else if (player.sexualityscale = 14) {
      return ("bisexual")
    }
    else if (player.sexualityscale = 15) {
      return ("bisexual")
    }
    if (player.sexualityscale = 16) {
      return ("bisexual homosexual lean")
    }
    if (player.sexualityscale = 17) {
      return ("bisexual homosexual lean")
    }
    else if (player.sexualityscale = 18) {
      return ("bisexual homosexual lean")
    }
    else if (player.sexualityscale = 19) {
      return ("bisexual homosexual lean")
    }
    else if (player.sexualityscale = 20) {
      return ("bisexual homosexual lean")
    }
    if (player.sexualityscale = 21) {
      return ("homosexual")
    }
    else if (player.sexualityscale = 22) {
      return ("homosexual")
    }
    else if (player.sexualityscale = 23) {
      return ("homosexual")
    }
    else if (player.sexualityscale = 24) {
      return ("homosexual")
    }
	 else if (player.sexualityscale = 25) {
      return ("homosexual")
    }
  ]]></function>

Everything works except for the "asexual" orientation return. It comes back as unknown every single time. I can even switch sexualities to everything except "asexual". The only difference between them is this...

 player.asexuallock=True

Does anyone know if I'm doing something wrong with this?

Anonynn.


I can read through that code and see what those functions will do. But it's not so clear what you want them to do.

Can you provide an example use-case? An example you've tested, telling us what the sexualityscale and orientation attributes were before that function is called; what they should be afterwards, and what they are afterwards.

Thanks; hope I can provide some help.


I hope you can too cause I'm losing my mind lol.

This is how they are set in the Character Creator.

SetTo ("orientation", "straight")
player.asexuallock = False

and asexual is set this way...

SetTo ("orientation", "asexual")
player.asexuallock = True

player.asexuallock is a boolean attribute on the player object (obviously lol).

The Sexuality Scale are those numbers from 1-25 in the Function. So if player set's their Orientation as let's say, "Straight" but in the game they have a lot of "Homosexual" experiences, the scale can potentially rise and fall and make them "Bi-Curious" or "Bisexual" etc.

When the player is asexual, they can set their own Orientation later via Command (which works the same way the character creator does). As asexual the scale should be permanently set to "0" and return "asexual" --- otherwise, it should have one of the assigned numbers 1-25 to determine Orientation.

BTW thank you so much mrangel @[email protected]

Anonynn.


Is the first script piece you posted the player object's changedsexualityscale script?

If so (and if I'm understanding you correctly), then I think it should be:

  if (player.asexuallock) {
    player.sexualityscale = 0
  }
  else if (player.sexualityscale < 1) {
    player.sexualityscale = 1
  }
  else if (player.sexualityscale > 25) {
    player.sexualityscale = 25
  }
  else {
    SetSexuality()
  }

Yes, it's the changedsexualityscale on the player.object.

I'll test that but before I had this and that wasn't working...

  if (player.asexuallock=True) {
    player.sexualityscale = 0
  }
  if (player.sexualityscale < 1) {
    player.sexualityscale = 1
  }
  if (player.sexualityscale > 25) {
    player.sexualityscale = 25
  }
    SetSexuality()

UPDATED: Yeah, it's still throwing "unknown" for player.orientation="asexual"

rolls on the ground crying

Anonynn.


Any other ideas? I mean, it technically isn't breaking anything since I go by the asexuallock in scripts but it still aesthetically bugs the crap out of me, especially since if I did try to use if (player.orientation="asexual") { the game would have a seizure about it.

Anonynn.


I'll test that but before I had this and that wasn't working...

You're missing the else there.
I'm not sure where "unknown" could be coming from, as I don't see it anywhere in the code.

(As a side note, I still find it a little odd that many games have a linear scale from straight to gay. Especially with a choice of gender, because in most cases a straight woman and a gay man would need to be treated equivalently by the code, meaning you're making your orientation code quite complex. It might be simpler to have two attributes for "interest in males" and "interest in females", then you probably only need to look at one of those depending on the NPC you're currently interacting with)


if you still got a problem after mrangel's help...

you could try changing this:

SetTo ("orientation", "asexual")
player.asexuallock = True

to this:

SetTo ("orientation", "asexual")
player.asexuallock = false // or: player.asexuallock = False

as you could be using the 'player.asexuallock' boolean as a check for: setting your 'player.orientation' to 'asexual' or not (no change: player.orientation = "unknown", or: player.orientation= "WHATEVER") somewhere in your code...

check all of you various scripting logic involving the 'player.asexuallock' boolean, in your entire game code: making sure it's not blocking any set'ting of: player.orientation = "asexual"


or vice versa:

as in, you go check if the 'player.asexuallock = False' is blocking you from setting: player.orientation = "asexual"


I have to think that the problem isn't in this code.

Can you show the line where you're setting player.sexualityscale? I'm assuming that it looks something like:

if (some condition) {
  player.asexuallock = true
  player.sexualityscale = 0
}

?


I can't see a bug but you could shorten your function:

 <function name="GetSexuality" type="string"><![CDATA[
    if (player.sexualityscale <1) {
	 return ("asexual")
    }
    else if (player.sexualityscale <6) {
      return ("straight")
    }
    else if (player.sexualityscale <11) {
      return ("bi-curious")
    }
     else if (player.sexualityscale <16) {
      return ("bisexual")
    }
    else if (player.sexualityscale <21) {
      return ("bisexual homosexual lean")
    }
   return ("homosexual")

  ]]></function>

just to add a bit to pertex' code (HK edit: the 'returns' are hard breaks, so pertex' code works fine --- thanks for correct me pertex --- sorry about that everyone), and alter your design entirely, for an idea into a more advanced design system:

<delegate name="SetOrientation_delegate" parameters="object_parameter,string_name_parameter" />

<delegate name="GetSexuality_delegate" parameters="object_parameter,string_name_parameter,integer_name_parameter" />

<game name="NAME_OF_GAME">

  <attr name="start" type="script">

    invoke (character_object.character_creation_script)

  </attr>

</game>

<object name="character_object">

  <attr name="sexualityscale_minimum" type="int">0</attr>
  <attr name="sexualityscale_maximum" type="int">25</attr>

  <attr name="asexual_minimum" type="int">0</attr>
  <attr name="asexual_maximum" type="int">0</attr>

  <attr name="straight_minimum" type="int">1</attr>
  <attr name="straight_maximum" type="int">5</attr>

  <attr name="bi_curious_minimum" type="int">6</attr>
  <attr name="bi_curious_maximum" type="int">10</attr>

  <attr name="bisexual_minimum" type="int">11</attr>
  <attr name="bisexual_maximum" type="int">15</attr>

  <attr name="bisexual_homosexual_lean_minimum" type="int">16</attr>
  <attr name="bisexual_homosexual_lean_maximum" type="int">20</attr>

  <attr name="homosexual_minimum" type="int">21</attr>
  <attr name="homosexual_maximum" type="int">25</attr>

  <attr name="orientation_menu_prompt_string" type="string">Orientation Menu Selection</attr>

  <orientation_stringlist type="stringlist">

    <value>asexual</value>
    <value>straight</value>
    <value>bi-curious</value>
    <value>bisexual</value>
    <value>bisexual homosexual lean</value>
    <value>homosexual</value>

  </orientation_stringlist>

  <attr name="character_creation_script" type="script">

    rundelegate (this,"SetOrientation",player,"orientation")

  </attr>

  <attr name="SetOrientation" type="SetOrientation_delegate">

    show menu (this.orientation_menu_prompt_string,this.orientation_stringlist,false) {
      set (object_parameter,string_name_parameter,result)
    }

  </attr>

  <attr name="GetOrientation" type="GetSexuality_delegate">

    <![CDATA[

      integer_variable = GetInt (object_parameter,integer_name_parameter)

      if (integer_variable < character_object.sexualityscale_minimum) {
        set (object_parameter,integer_name_parameter,character_object.sexualityscale_minimum)
      } else if (integer_variable > character_object.sexualityscale_maximum) {
        set (object_parameter,integer_name_parameter,character_object.sexualityscale_maximum)
      }

      if (integer_variable < character_object.straight_minimum) {
        set (object_parameter,string_name_parameter,"asexual")
      } else if (integer_variable < character_object.bi_curious_minimum) {
        set (object_parameter,string_name_parameter,"straight")
      } else if (integer_variable < character_object.bisexual_minimum) {
        set (object_parameter,string_name_parameter,"bi-curious")
      } else if (integer_variable < character_object.bisexual_homosexual_lean_minimum) {
        set (object_parameter,string_name_parameter,"bisexual")
      } else if (integer_variable < character_object.homosexual_minimum) {
        set (object_parameter,string_name_parameter,"bisexual homosexual lean")
      } else {
        set (object_parameter,string_name_parameter,"homosexual")
      }

    ]]>

  </attr>

  <attr name="GetSexualityScale" type="GetSexuality_delegate">

    string_variable = GetString (object_parameter,string_name_parameter)

    switch (string_variable) {
      case ("asexual") {
        integer_variable = (character_object.asexual_minimum + character_object.asexual_maximum) / 2
        set (object_parameter,integer_name_parameter,integer_variable)
      }
      case ("straight") {
        integer_variable = (character_object.straight_minimum + character_object.straight_maximum) / 2
        set (object_parameter,integer_name_parameter,integer_variable)
      }
      case ("bi-curious") {
        integer_variable = (character_object.bi_curious_minimum + character_object.bi_curious_maximum) / 2
        set (object_parameter,integer_name_parameter,integer_variable)
      }
      case ("bisexual") {
        integer_variable = (character_object.bisexual_minimum + character_object.bisexual_maximum) / 2
        set (object_parameter,integer_name_parameter,integer_variable)
      }
      case ("bisexual homosexual lean") {
        integer_variable = (character_object.bisexual_homosexual_lean_minimum + character_object.bisexual_homosexual_lean_maximum) / 2
        set (object_parameter,integer_name_parameter,integer_variable)
      }
      case ("homosexual") {
        integer_variable = (character_object.homosexual_minimum + character_object.homosexual_maximum) / 2
        set (object_parameter,integer_name_parameter,integer_variable)
      }
    }

  </attr>

</object>

<object name="room">

  <inherit name="editor_room" />

</object>

<object name="player">

  <inherit name="editor_object" />
  <inherit name="editor_player" />

  <inherit name="character_type" />

  <attr name="parent" type="object">room</attr>

</object>

<type name="character_type">

  <attr name="sexualityscale" type="int">0</attr>

  <attr name="orientation" type="string">unknown</attr>

  <attr name="changedsexualityscale" type="script">

    rundelegate (character_object,"GetOrientation",this,"orientation","sexualityscale")

  </attr>

  <attr name="changedorientation" type="script">

    rundelegate (character_object,"GetSexualityScale",this,"orientation","sexualityscale")

  </attr>

</type>

(and fix it slightly - pertex quickly wrote the code and left off the 'else' for the final return value

Nope, I did not forget that 'else', you don't need it there.


oops, totally forgot the 'returns' are hard breaks out of a Function, sorry about that! (HK posted too quickly without thinking first)

thank you for correcting me and my post, again, sorry about that to Pertex and everyone else!

(though I hope my code design works... hadn't been able to test it... but I think most of it should, I hope, but there might be some issues that can be easily fixed up, I hope anyways. I hate how after my code is done, it looks so simple, but it took me awhile to do it, sighs. More advanced structural scalable/editable design is still very difficult for my stupid brain to wrap its head around, sighs)


Log in to post a reply.

Support

Forums