+Spire67 Posted April 30, 2018 Posted April 30, 2018 I have built a cartridge using the Urwigo builder. I am now in the process of testing it. I have several input fields in the cartridge. They are all numeric fields. In testing the cartridge I have entered alpha characters and found that it simply quits out of question with no message. You then have to exit the zone and re-enter it to get it to fire the question again. Is there any way of dealing with the user inputting their response in the wrong format so that it gives an appropriate message and then allows them to re-input their response? Quote
+bflentje Posted April 30, 2018 Posted April 30, 2018 2 hours ago, Spire67 said: I have built a cartridge using the Urwigo builder. I am now in the process of testing it. I have several input fields in the cartridge. They are all numeric fields. In testing the cartridge I have entered alpha characters and found that it simply quits out of question with no message. You then have to exit the zone and re-enter it to get it to fire the question again. Is there any way of dealing with the user inputting their response in the wrong format so that it gives an appropriate message and then allows them to re-input their response? You can do it a couple of different ways. Here's a way I've used.. in LUA. function ValidateCode(code) if not IsNumeric(code) then var_codeValid = false return end function IsNumeric(var) local num = tonumber(var) if num == nil then return false else return true end end Quote
+Spire67 Posted May 1, 2018 Author Posted May 1, 2018 6 hours ago, bflentje said: You can do it a couple of different ways. Here's a way I've used.. in LUA. function ValidateCode(code) if not IsNumeric(code) then var_codeValid = false return end function IsNumeric(var) local num = tonumber(var) if num == nil then return false else return true end end Thanks for the response. Can that be added to code written through the urwigo app? If so how? Quote
+Spire67 Posted May 1, 2018 Author Posted May 1, 2018 I have inserted a LUA User code at the start of the flow for the input. See attached screen shot. The first script threw up an error "Expecting 'end'. Around line 5 character 4. The second script was error free but then did nothing to trap the input of an alpha character. Does the (code) need to be changed to the name of the input variable and if so how do identify what that is? Thanks Quote
+bflentje Posted May 1, 2018 Posted May 1, 2018 I use Earwigo so don't know how your tool implements it. But my functions are located in the Author Script block. Once it's there.. - I have a boolean variable named var_codeValid - I have an expression named codeValid - In the GetInput event, first step is to do a Lua statement: ValidateCode(var_answer) - followed by If/Then, checking the expression. You should get the gist of it?? This was my first attempt at this in a builder tool so I would definitely do it differently if I wrote it today. But it works. Quote
Ranger Fox Posted May 3, 2018 Posted May 3, 2018 Another way is just to store the input in a text/string variable type instead of a number variable type. The player app won't have issues and you can check for the value. Things get iffy if you're trying to check for a numeric range, though. Quote
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.