Post new topic    
Liquid Metal Slime
Send private message
Skill Tree Menu 
 PostWed Dec 24, 2014 8:15 am
Send private message Reply with quote
I'm trying to make a menu to act as a skill tree for the player to spend points on new abilities and passive bonuses, etc.

So to do this I've set up some slices with pictures for each ability, and a menu that opens up along with the slice collection. Now each menu item is supposed to correspond to an ability on the tree using "menu item true slot(selected menu item)" just like the script I was making earlier in this thread (which works). A loop checks which slot the cursor is on, then makes a description box visible and attaches the appropriate string(s) to it, or makes the box invisible if no ability is selected.

Here's the whole script for it:

Code:
plotscript, open skill tree, begin
   variable(menuopen,mi)
   
   open menu(3)
   box := load slice collection(1)
   open := true
   
   $5= ""
   $6= ""
   $7= ""
   
   while(menuopen) do, begin
      mi := menu item true slot(selected menu item)
      switch(mi) do(
         case(0) select skill(0)
         case(1) select skill(1)
         case(2) select skill(2)
         case(3) select skill(3)
         case(4) select skill(4)
      )
      if(menu is open(3) == false) then(
         menuopen := false
      )
      wait(1)
   end
end

plotscript, close skill tree, begin
   free slice(box)
   open menu(0)
end

script, select skill, which, begin
   if(which == 0) then(
      set slice visible(lookup slice(sli:desright),off)
      set rect fgcol(lookup slice(sli:smithing),0)
      set rect fgcol(lookup slice(sli:mining),0)
   )
   else if(which == 1) then(
      clear string(5)
      clear string(6)
      $5= "As a miner, one of your most essential skills is mining. With this first level, mining, you can mine some basic minerals and use low-level pickaxes."
      $6= "Mining I"
      set slice text(lookup slice(sli:descriptiontxt1),5)
      set slice text(lookup slice(sli:skillname),6)
      set slice visible(lookup slice(sli:desright),on)
      set rect fgcol(lookup slice(sli:mining),109)
      set rect fgcol(lookup slice(sli:prospecting),0)
   )
   else if(which == 2) then(
      clear string(5)
      clear string(6)
      $5= "Aside from mining, miners must also be able to identify the minerals they receive."
      $6= "Prospecting I"
      set slice text(lookup slice(sli:descriptiontxt1),5)
      set slice text(lookup slice(sli:skillname),6)
      set slice visible(lookup slice(sli:desright),on)
      set rect fgcol(lookup slice(sli:prospecting),109)
      set rect fgcol(lookup slice(sli:mining),0)
      set rect fgcol(lookup slice(sli:defender),0)
   )
   else if(which == 3) then(
      clear string(5)
      clear string(6)
      $5= "Miners take pride in their exceptional defensive abilities. Each point increases your defense bonus."
      $6= "Defender I"
      set slice text(lookup slice(sli:descriptiontxt1),5)
      set slice text(lookup slice(sli:skillname),6)
      set slice visible(lookup slice(sli:desright),on)
      set rect fgcol(lookup slice(sli:defender),109)
      set rect fgcol(lookup slice(sli:prospecting),0)
      set rect fgcol(lookup slice(sli:smithing),0)
   )
   else if(which == 4) then(
      clear string(5)
      clear string(6)
      $5= "Miners use the ores they mine to forge useful armor and weapons. As your level increases, you will be able to create more items with better materials."
      $6= "Smithing I"
      set slice text(lookup slice(sli:descriptiontxt1),5)
      set slice text(lookup slice(sli:skillname),6)
      set slice visible(lookup slice(sli:desright),on)
      set rect fgcol(lookup slice(sli:smithing),109)
      set rect fgcol(lookup slice(sli:defender),0)
   )
end



I attached a picture of what it looks like as well. I only came here as a last result, because I absolutely cannot figure this one out. I'm sure I'm just overlooking something, but the issue is, nothing even happens when I open up the menu, so I don't know where to look for problems.

Also, if anyone has recommendations on condensing this script, feel free to share.

Thanks for your time!
My pronouns are they/them
Ps. I love my wife
Metal King Slime
Send private message
 
 PostSun Jan 18, 2015 6:41 am
Send private message Reply with quote
Did you solve this? I hope you found the "open := true " instead of "menu open := true" error. But you can simply that by replacing "while(menuopen)" with "while(menu is open(3))". Also, "menu item true slot(selected menu item) " should be "menu item true slot(selected menu item(top menu))"

There's no point writing clear string(5), clear string(6) immediately before you set the contents of strings 5 and 6.

But anyway, my advice for condensing the script is to next time set up all those slices in a slice collection in the editor. You can either use a separate collection for each menu item, or put everything in the same collection (duplicate all shared slices), and change which bits of the collection are hidden or visible. No point rewriting your existing script though.
Display posts from previous: