Indie game storeFree gamesFun gamesHorror games
Game developmentAssetsComics
SalesBundles
Jobs
Tags

Hi ! 

On a card I have a slider, which can display values between 0 and 5. Next to it is a "validate" button.

I'd like the validate button to take the player to different cards depending on the value he chooses (so 6 different cards, since there are 6 possible values). I imagine this isn't very complicated, but I can't find the trick!

(+1)

The go[] function is used to navigate to a different card.

There are three ways to specify the card you want:

  • by index: if you provide a number n, go[n] will navigate to the nth card in the deck, counting from 0.
  • by name: if you provide a string s, go[s] will navigate to the card with that name.
  • by value: if you provide a card c, go[c] will navigate to the card you provided.

Navigating by index is usually not a great idea, because adding or removing cards can easily break such a script. We'll use navigation by value for these examples.

The numeric value of a slider widget can be viewed through its .value attribute.

To turn a numeric index into a card value, we'll make a list of cards and index into it using the slider's .value.

To slightly simplify your example, let's say you have a slider named "mySlider" with a range from 0 to 2, and cards named cardA, cardB, and cardC.

Forming a list:

(cardA,cardB,cardC)

Forming a list and then indexing it:

(cardA,cardB,cardC)[mySlider.value]

So the full button's script could be:

on click do
 go[(cardA,cardB,cardC)[mySlider.value]]
end

And of course, if you want a smoother transition you can specify go[]'s optional arguments for a transition style and delay:

on click do
 go[(cardA,cardB,cardC)[mySlider.value] "BoxIn" 15]
end 

This kind of approach also works if you don't need/want all the destinations to be distinct. Consider:

on click do
 go[(cardA,cardA,cardB,cardC,cardB)[mySlider.value]]
end

Is that clear?

(+1)

Totally clear and perfectly works (as usual you're the boss)

I'd like to make a "search" game system, so players type something into the bar, then click on a card that contains the term (so far I've had no problems!). 

But to put an end to the game, I'd like their number of moves to be limited, so they can view say 10 documents (so 10 different cards) before automatically arriving at a new card that forces them to turn in an investigation report. What would be the easiest way to do this? 

The other idea I have would be to set up a countdown visible from all the maps, at the end of which you arrive at a final map, but I imagine that's a lot more complicated...

I'd make a locked and/or invisible field (or maybe a slider) somewhere to track the number of moves the player has remaining.

If you're displaying search results as a bunch of links in a field, you could make clicking a link count down the remaining moves by overriding the "link" event for the field. The default handler for link events is

on link x do
 go[x]
end

So you could instead give the field something like

on link x do
 moves.text:moves.text-1
 if moves.text=0
  go[theGameOverCard]
 else
  go[x]
 end
end

Side note: you can also write that conditional as:

go[if moves.text=0 theGameOverCard else x end]

This approach might be a little weird, though, since it ignores the user's final selection and surprises them with a game over.

If the cards you can get to via search have a "back" button, maybe it would make sense to test for game overs there, and navigate to the final card instead of the search page?

I'm using SearchEngine contraption, I'm not sure if I can "override" the links displayed in this prototype?

You'd need to modify the contraption prototype, but it's a very simple change. In the SearchEngine the results are displayed in a rich-text field named "o". It doesn't currently contain any scripts and simply relies upon the default "on link" behavior.

The main thing to be aware of is that within a Contraption you won't auto-magically have cards and widgets of the deck in scope as variables; You do have access to "deck", though, so you can use fully-qualified paths to reach out to a specific widget. e.g. "deck.cards.theSearchCard.widgets.theSearchCounter", and if you use go[] you can refer to cards by name (as strings) instead of value (as cards).

I've tried to make all the contraptions in the bazaar as generic and reusable as possible, but don't be afraid of hacking them up or making changes to suit a specific application. In the worst case you can always delete the prototype and re-import the reference copy.

I think I'm close to the solution, but I don't understand why when I write "moves.text:moves.text-1" -> the field displays "-1" instead of doing a calculation...