It looks like you're new here. If you want to get involved, click one of these buttons!
Do you like [[fighting|Intro][$leader = $warrior]] monsters, [[stealing|Intro][$leader = $rogue]] from the rich or [[zapping|Intro][$leader = $mage]] evil-doers?
<<set $party = [$leader.name]>>
<<set $newchar = $warrior>>
<<set $newchar.name to either($names)>>
You meet <<$newchar.name>>the<<$newchar.class>>
<<set $party.push($newchar.name)>>
[[Location2]]
Your Party has <<$party.length>> <<if $party.length is 1>>person<<else>>people<<endif>> in it:
<<$party[0]>>
<<if $party.length gte 2>><<$party[1]>> [[remove|Party Stats][$party.splice($party.[1],1)]]<<endif>>
<<if $party.length gte 3>><<$party[2]>> [[remove|Party Stats][$party.splice($party.[2],1)]]<<endif>>
<<if $party.length gte 4>><<$party[3]>> [[remove|Party Stats][$party.splice($party.[3],1)]]<<endif>>
<<$party>>
[[Back to Game!|previous()]]
Is there a way to do this?
Comments
start
parameters in the calls to theArray
object'ssplice()
method. For example:EDIT: Brain fart. Disregard this bit.
Additionally, consider this bit:
[[Back to Game!|previous()]]
That will not do what you expect if the player removes any party members. The reason being that
previous()
yields the title of the last passage which is not the same as the current one. What you'll need to do there, or for any menu that uses recursion or is otherwise comprised of multiple passages, you'll have to set a $variable with the title of the passage you actually want to return to and use that. For example:[[Back to Game!|$return]]
There are several ways in which you could set the return variable, but doing it automatically via tags is probably easiest.
Now an odd one, after testing the "remove" links worked, I hit the "back to game" button and it seemed to work fine without any of the changes you mentioned - i.e. even after hitting remove two or three times, it still took me back to the passage I was in prior to going to the Party passage. Has the functionality of it changed recently?
Ah. Yes, sorry, I suppose if you're simply recursing into the same passage over and over, then
previous()
will work fine. The more complicated solution is only required if your menu spans different passages.