Making a minigame

I am trying to make a mini game for players. I know how I want it but not sure how it should be. I want to make it like a computer hacker so they can make money. Basically they have 3 modes easy medium hard. they would have to unscramble words in a set amount of time to win so easy mode i figured 5 3 letter words in 30 seconds medium 5 4 letter words in 45 seconds and hard would be 5 5 letter words in 60 seconds. I know how to use the time widget and the textbox widget what im not sure of is how they would input the answer and have it check to see if they are correct and allow them a win or loss.

2 Likes

Hi,

Could you explain more what kind of mini-game you are trying to do? (Like what do you mean by unscramble the words).
We’d be able to give a more specific answer for our question.

But the general gist of a timed puzzle with player input:

/*Textbox to input */
<<textbox "$varToCheck" "">> <span id="error"></span>

/*Button to check the input of the player*/
<<button "Confirm">>
     <<if $varToCheck is "the correct answer">>
          <<set $money += 10>> /*for example*/
          <<goto "Next Passage">>
     <<else>>
           <<replace "#error">>Nope. Not correct<</replace>>
      <</if>>
<</button>>

/*The timer to send the player to a failed passage*/
<<timed 60s>>
      <<goto "Lost Passage">>
<</timed>>
2 Likes

basically they logon to a computer and try hacking a bank. the hack would be easy medium or hard

the easy would be 3 letter words like for are cat dog just scrambled so ogd tca like that. they would have to input the correct word up to 5 words in the time allotted if they do they get a set amount of money if they fail they would lose money from their account as a penalty for hacking

2 Likes

However this code looks as though it could be what i need Ill try it out and see how it goes. I was thinking Ill probably need to set up some arrays with words to choose from as well. Thanks.

3 Likes

So I set this up and im getting an error. not sure if i did it right
/*Textbox to input */
<<textbox “$easy” “”>><<CompGame “Easy”>>

/Button to check the input of the player/
<<button “Confirm”>>
<<if $easy== $check>>
<<set $money += 50>> /for example/
<<goto “wineasy”>>
<>
<<replace “#error”>>Nope. Not correct<>
<>
<>

/The timer to send the player to a failed passage/
<<timed 60s>>
<<goto “faileasy”>>
<>
I set up a widget with an array which probably could be wrong not sure,
<<widget “CompGame”>>
<<if $args[0] is “Easy”>>
<<print ‘<“$easy”/>’>>
<>
<>

<<set $easy to [“atc”, “ogd”, “het”, “elt”, “onw”]>>
either($easy)


I know it needs some kind of $check not sure how though if it should be another array or how it would check the words are right if they are spit out at random

Error: <<textbox>>: no default value specified  then at the end of the text box <"$easy"/>

This is the error that I keep getting


1 Like

Looks like the formatting of the code went the wrong way…
(text in the code formating, code as regular text)
It’s hard to see what went wrong when part of the macros are not visible :wink:
Would you mind re-editing your post?

1 Like

`for some reason its not letting me save the edit

So I set this up and im getting an error. not sure if i did it right

/*Textbox to input */
<<textbox "$easy" "">><<CompGame "Easy">> <span id="error"></span>

/*Button to check the input of the player*/
<<button "Confirm">>
<<if $easy== $check>>
<<set $money += 50>> /*for example*/
<<goto "wineasy">>
<<else>>
<<replace "#error">>Nope. Not correct<</replace>>
<</if>>
<</button>>

/*The timer to send the player to a failed passage*/
<<timed 60s>>
<<goto "faileasy">>
<</timed>>

I set up a widget with an array which probably could be wrong not sure,

<<widget "CompGame">>
	<<if $args[0] is "Easy">>
	<<print '<"$easy"/>'>>
	 <</if>>
 <</widget>>


<<set $easy to ["atc", "ogd", "het", "elt", "onw"]>>
either($easy)

I know it needs some kind of $check not sure how though if it should be another array or how it would check the words are right if they are spit out at random

Error: <>: no default value specified then at the end of the text box <“$easy”/>

This is the error that I keep getting

Still not working. You need to wrap the code with the three (back) ticks

`
Code 

image

for some reason its taking out the /if and /widget part of the code

ok i was doing it wrong was thinking the ``` need to be around the regular sentences not the code for some reason I fixed the one above

cool! nice

Some stuff:

  • is your widget set in a widget-tagged passage? (otherwise it won’t work, I’m guessing this is where your error comes from…)
  • <<CompGame "Easy">> will only print the variable $easy when the passage first loads (so it will be empty). It will not update as you type.
  • You shouldn’t use the same variable for the array and the textbox.
  • Is $check set anywhere? If so, how?
  • Where is $easy set in the first place?
  • and either(easy)?

yea the widget is tagged as widget. i wasnt sure how to set up the $check. as an array or what how it would check against the word that was choosen. so the variable $easy is for the widget what should i be using for the textbox would that be the check

I have $easy as an array just underneath the widget on the widget page as well as an array for check

<<set $easy to ["atc", "ogd", "het", "elt", "onw"]>>
either($easy)

<<set $check to ["cat", "dog", "the", "let", "now"]>>

the only thing I cannot get it to do now is to display the words in the $easy Array. its just a blank textbox with a button

I don’t see a need for widgets here, I think it would be easiest to make two arrays for each difficulty level (6 in all). So easy will have a scrambled array and an unscrambled array. We’ll assign a temp variable 0-4 to be the random index used by both arrays (0 will hold the first word, 4 will hold the 5th word in the array).

Then when the player hits confirm, the textbox variable $checkVar will be matched up against the unscrambled array and see if it matches. If it does, a variable $easyCounter will be incremented. Once it’s to 5, the player will be moved on to the Medium difficulty passage.

My only problem is the timed macro will reset with each correct answer and page refresh, so the best way I can mimic 45 seconds total is give 9 seconds for each word. I know this isn’t as desirable, maybe someone can help with a javascript function to allow the timer to withstand page refreshes? Or could put all the five words on one page with 5 text boxes, but this would be messy with tons of variables.

<<if visited() < 2>>\
<<set $easyCounter = 0>>\ 
<<set $easy to ["atc", "ogd", "het", "elt", "onw"]>>\ 
<<set $easyCheck to ["cat", "dog", "the", "let", "won"]>>\ 
<</if>>\
<<if $easyCounter < 5>>\
<<set _rand = random (0,4)>>\
5 correct answers need to advance. Current correct answers: $easyCounter

Word to crack: $easy[_rand]
Your answer: <<textbox "$varToCheck" "">> <span id="error"></span>

/*Button to check the input of the player*/
<<button "Confirm">>
     <<if $varToCheck == $easyCheck[_rand]>>
          <<set $money += 10>> /*for example*/
		  <<set $easyCounter += 1>>\
          <<goto "Easy difficulty">>
     <<else>>
           <<replace "#error">>Nope. Not correct. Hurry time is ticking!<</replace>>
      <</if>>
<</button>>

/*The timer to send the player to a failed passage*/
<<timed 9s>>
      <<goto "Lost Passage">>
<</timed>>
<<else>>\
<<goto "Medium difficulty">>\
<</if>>\

Ill give this a try thanks. Right now no matter what i try i cant get the words to print out on screen I just get the textbox and button

This has sort of worked better than the others have for me. the problem is that the words showing up. one was just a plain t another is $easy[_rand] that was showing up as well.

got this resolved now thanks for the help!!! now on to other issues before i can finally move on with this game!