Monday, September 12, 2016

NFC + Legos = ?, Adventures in Gamification of Legos

Who knew that buying a package of Legos could lead to an emotion roller coaster? On one hand, I was psyched when I picked up a few Lego Dimension kits at Five Below. The small set seemed perfect for a quick afternoon activity. I then found myself disappointed when I opened the package and found out that the instructions for building the small set were available only through a Lego game. I was then back to happy when I found a site that gave free access to said instructions. Finally, my little journey of joy and annoyance ended on a happy note when I learned that the plastic bases that hold the Lego Dimension characters are actually NFC Tags.

Over the summer, I sent the kids home with their Lego Dimension characters and vehicles, but held onto the little magic plastic bases. I figured I'd have to put them to use, somehow. Here's a random knock-off minifigure perched upon the NFC base, waiting for me to do something brilliant with him:

I thought about doing something practical, but I couldn't really see any value the NFC Lego base would have over the NFC stickers that are quite frankly, awesome. Then last night it hit me: I should build a sort of hybrid game, where you play with Legos but use the NFC base and a mobile phone to help steer the playing. Think Dungeons and Dragons, only with Lego Characters and your mobile phone and not dice.

There's only one small detail: I know absolutely nothing about D&D. While my older brother played, I did not. Even Simple DnD was too complex for me to quickly absorb and turn into some sort of program. So yeah, my vision of being a game master would have to wait.

But I decided I'd dip a toe into the process, regardless. Step 1: vastly simplify *everything*.

I imagined that for a character roll playing game to work you'd need something random (think: roll of a dice) and some sort of state (think: the health of your player). And so I started to futz around with these ideas. Of course, I went to my goto prototyping environment: Tasker.

Here's a Task that generates a random number, whether it's positive or negative, and updates your current score (which starts at 100). Every time I scan the character's base, my phone brings up a dialog box with the updated status of my character:

%Lego Refresh (162)
 A2: Variable Set [ Name:%char To:char1 Do Maths:Off Append:Off ] 
 A3: Variable Randomize [ Name:%polarity Min:0 Max:1 ] 
 A4: Variable Randomize [ Name:%offset Min:1 Max:10 ] 

 A5: Test File [ Type:Type Data:Tasker/lego/%char.txt Store Result In:%found Use Root:Off Continue Task After Error:On ] 
 A6: If [ %found !Set ]
   A7: Variable Set [ Name:%current To:100 Do Maths:Off Append:Off ] 
 A8: Else 
   A9: Read Line [ File:Tasker/lego/%char.txt Line:1 To Var:%current ] 
 A10: End If 

 A11: Variable Set [ Name:%updated To:%current Do Maths:Off Append:Off ] 

 A12: If [ %polarity eq 0 ]
   A13: Variable Add [ Name:%updated Value:%offset Wrap Around:0 ] 
   A14: Variable Set [ Name:%operator To:+ Do Maths:Off Append:Off ] 
 A15: Else 
   A16: Variable Subtract [ Name:%updated Value:%offset Wrap Around:0 ] 
   A17: Variable Set [ Name:%operator To:- Do Maths:Off Append:Off ] 
 A18: End If 

 A19: If [ %updated < 0 ]
   A20: Variable Set [ Name:%updated To:0 Do Maths:Off Append:Off ] 
 A21: End If 

 A22: Write File [ File:Tasker/lego/%char.txt Text:%updated Append:Off Add Newline:On ] 

 A23: Show Scene [ Name:Lego Update Display As:Dialog Horizontal Position:100 Vertical Position:100 Animation:System Show Exit Button:On Continue Task Immediately:On ] 
 A24: Element Text [ Scene Name:Lego Update Element:Score Position:Replace Existing Text:%current %operator %offset 
%updated Selection: ] 

Here's 3 scans of my character in a row:

So yeah, there's not much to see here. But it is interesting to see how Tasker Scenes work, and to continue to experiment with novel uses of NFC. I'll have to think about what strategic code I can write that will start moving this closer to an actual playable activity. With the right story line and heavy use of imagination, perhaps not much. We'll see.

No comments:

Post a Comment


Related Posts with Thumbnails