HeroEngine Forums
Welcome, Guest. Please login or Register for HeroCloud Account.

Author Topic: [Resolved] Lists vs LookupLists  (Read 852 times)

cloudnine

  • General Accounts
  • *
  • Posts: 80
    • View Profile
    • Youtube
[Resolved] Lists vs LookupLists
« on: Jan 08, 13, 04:57:02 PM »

Still working on an ability system which is like a TalentTree


Say I have Talents 1,2,3,4
1, 2, and 3 adds a stat bonus to the character, 4 adds a new ability
The character
has to have trait 1 to get trait 2 and so on.

So I tried adding a new replicated field to the character
TrainedJobSkills - list of string

I want to check if the list has the string
if it doesn't and the character can learn it
add the string to the list

Well I can use HAS because its not a lookuplist.
So I change the field to
TrainedJobSkills - lookuplist indexed by string of string
Has works but trying to "Add back" a string says it must be a list.

SoloTrainingClassMethods on the server
Code: [Select]
function CheckTrainedJobSkills (myclass as Enum Classes,myskill as Enum JobSkillLevels)as Boolean
  println("Checktheskills")
  account as NodeRef of Class _PlayerAccount = SYSTEM.REMOTE.CLIENT
  player as NodeRef of Class _PlayerCharacter = account.GetMyChar()
  char as NodeRef of Class E_playerCharacter = player
  text1 as String = myclass
  text2 as String = myskill
  textstring as String = text1 +text2
  println( textstring )
 
 
  when myclass
    is WARRIOR
      when myskill
        is t1_I_I
          if char.TrainedJobSkills has textstring
            println("You have already trained this skill")
            return false
          .
          add back textstring to char.TrainedJobSkills
          println("Adding this Job Skill Traing to the list")
          return true
        .
        is t1_I_II
          if char.TrainedJobSkills has WARRIORt1_I_I
            println("Char has first ability checking for second")
            if char.TrainedJobSkills has textstring
               println("You have already trained this skill")
               return false
            .
            add back textstring to char.TrainedJobSkills
            println("Adding this Job Skill Traing to the list")
            return true
          .
          println("Didnt have the first ability to train the second")
          return false
Or should I look at the HJ Token stuff?
Also at some point I want to copy some character info like level and equipped items
And change level and equipped items based on the CLASS(warrior,cleric) the character currently has.
« Last Edit: Jan 11, 13, 11:32:06 AM by HE-Cooper »
Logged

FI-ScottZ

  • General Accounts
  • *
  • Posts: 1407
    • View Profile
    • Forever Interactive, Inc.
Re: Lists vs LookupLists
« Reply #1 on: Jan 08, 13, 05:30:12 PM »

Right, add is only for lists.  For lookupLists, you simply specify a key for the list and assign some value to it.  So, it would be something like this:

Code: (hsl) [Select]
char.TrainedJobSkills[textstring] = ""
In that code, the skill string is the key and the value mapped to it could be something meaningful if you have something to map to it, or just any value, in this case an empty string.  When you first assign a value to a key is when that slot in the lookup is created.

You can search a regular list for something, you just need to iterate through the list manually, checking each value.  There is a function in the script "listutils" which does that.

In fact, if you open the script picker in the script editor and type "utils" into the filter bar, you will see there are a number of different utility scripts already written with some handy functions in them.  That is both on the client and server side.
Logged
Scott Zarnke
Lead Programmer, Visions of Zosimos
CTO, Forever Interactive, Inc.

cloudnine

  • General Accounts
  • *
  • Posts: 80
    • View Profile
    • Youtube
Re: Lists vs LookupLists
« Reply #2 on: Jan 08, 13, 10:04:44 PM »

Thanks Scott, the listutils helped.
I changed back to using just a List
Now I can add
Code: [Select]
function CheckTrainedJobSkills (myskill as Enum JobSkillLevels)as Boolean
  println("Checktheskills")
  account as NodeRef of Class _PlayerAccount = SYSTEM.REMOTE.CLIENT
  player as NodeRef of Class _PlayerCharacter = account.GetMyChar()
  char as NodeRef of Class E_playerCharacter = player
  text1 as String = myskill
  println( text1 )
 
  A1 as String = "A1"
  A2 as String = "A2"
  A3 as String = "A3"
  A4 as String = "A4"
  when myskill
    is t1_I_I
        if listutils:ListOfStringHasString(char.TrainedJobSkills, A1)
        println("You have already trained this skill")
        return false
      .
      add back A1 to char.TrainedJobSkills
      println("Adding this Job Skill Training to the list")
      return true
    .
    is t1_I_II
      if listutils:ListOfStringHasString(char.TrainedJobSkills, A1)
        println("Char has first ability checking for second")
        if listutils:ListOfStringHasString(char.TrainedJobSkills, A2)
           println("You have already trained this skill")
           return false
        .
        add back A2 to char.TrainedJobSkills
        println("Adding this Job Skill Training to the list")
        return true
      .
      println("Didnt have the first ability to train the second")
      return false
    .
And Remove Talents
Code: [Select]
function CheckUnTrainedJobSkills (myskill as Enum JobSkillLevels)as Boolean
  println("Checktheuntrainskills")
  account as NodeRef of Class _PlayerAccount = SYSTEM.REMOTE.CLIENT
  player as NodeRef of Class _PlayerCharacter = account.GetMyChar()
  char as NodeRef of Class E_playerCharacter = player
  text1 as String = myskill
  println( text1 )
 
  A1 as String = "A1"
  A2 as String = "A2"
  A3 as String = "A3"
  A4 as String = "A4"
  T2 as String = "T2"
  when myskill
    is t1_I_I
        if listutils:ListOfStringHasString(char.TrainedJobSkills, A1)
        println("You have already trained this skill checking next skill")
        println( "List length is (" +char.TrainedJobSkills.length +")")
          if listutils:ListOfStringHasString(char.TrainedJobSkills, A2)
             println("You must remove the next skill first")
            return false
          .
        remove char.TrainedJobSkills at listutils:FindUniqueValuePositionInListOfString(char.TrainedJobSkills, A1)
        println("Removing this Job Skill Training from the list")
        return true
        .
        println("You dont have that ability to untrain!")
        return false
    .
    is t1_I_II
        if listutils:ListOfStringHasString(char.TrainedJobSkills, A2)
        println("You have already trained this skill checking next skill")
          if listutils:ListOfStringHasString(char.TrainedJobSkills, A3)
             println("You must remove the next skill first")
             return false
          .
        remove char.TrainedJobSkills at listutils:FindUniqueValuePositionInListOfString(char.TrainedJobSkills, A2)
        println("Removing this Job Skill Training from the list")
        return true
        .
        println("You dont have that ability to untrain!")
        return false
    .
Logged