+Ah! Posted February 26, 2020 Share Posted February 26, 2020 (edited) I'm trying to use author script with Earwigo and the example below seems to work OK most of the time. When the player inputs some text 'vin' the text is converted to a string of characters. Digits in the input are converted to members of the 'tnum' table/array, alphabet characters (upper and lower case) are converted to members of the 'tlet' table/array and any other characters are left as they are. This works for all the printable characters except the double quotes ( " ) and the pound sign ( £ ). For the double quote sign I get this message ERROR unfinished string near '' For the pound sign I don't get an error message, I get nothing at all. Any one able to help ? function f1() tnum = {"d8-d10,","i4,","i1+i4,","i4-d8,","i2-i4,","d11-d10,","d11,","d9-i1,","d9,","d9+i3,"} tlet = {"g6,","j10,","a6,","c12,","e5,","k3,","h11,","b4,","d6,","c16,","a7,","b8,","e8,","d2,","g3,","d4,","c6,","f4,","h8,","k12,","f9,","i12,","g1,","X,","j11,","Z,"} for n = 1,string.len(vin),1 do v1 = string.byte(string.sub(vin,n,n)) v2 = string.sub(vin,n,n) if v1 >= 48 and v1 <= 57 then vout = vout..tnum[v1-47] elseif v1 >= 65 and v1 <= 90 then vout = vout..tlet[v1-64] elseif v1 >= 97 and v1 <= 122 then vout = vout..tlet[v1-96] else vout = vout..v2.."," end end end Edited February 26, 2020 by Ah! Forgot something Quote Link to comment
+Tungstène Posted February 27, 2020 Share Posted February 27, 2020 I didn't test your code but I try to understand it... How is the input text assigned to the vin variable? If it was with Earwigo's internal mechanisms, it would be named var_vin, not just vin. Did you test your code with several players? Which ones? Was the error consistent? Quote Link to comment
+Ah! Posted February 28, 2020 Author Share Posted February 28, 2020 16 hours ago, Tungstène said: I didn't test your code but I try to understand it... How is the input text assigned to the vin variable? If it was with Earwigo's internal mechanisms, it would be named var_vin, not just vin. Did you test your code with several players? Which ones? Was the error consistent? Thanks for your relpy. var_vin is an input variable of the player. I have written the code in both ways - as variable and as var_variable and the results are exactly the same. I have only used the emulator in Earwigo to test it. Here is a link to the gwz file https://app.box.com/s/dpoaztievc19u7dehaazd0dg9y0854e1 Quote Link to comment
+Tungstène Posted February 28, 2020 Share Posted February 28, 2020 35 minutes ago, Ah! said: I have only used the emulator in Earwigo to test it. I tested it too. With the same result as you. If you open and read the "LUA console" in Webwigo (the web application you called "the emulator in earwigo"), you can see that special characters (£, §, or µ, among others) are not treated as ASCII chars but replaced by a sequence which looks like an Unicode string. You'll also see that the quote char (i.e. ") triggers an error right when you validate your input (I don't think Webwigo gives it any chance to reach your f1 function). All this could be just a bug in Webwigo implementation of the player code. We'll have to check with real players (I'm sorry I can't right now, I'm already in a hurry). By the way, Your GWZ file triggers a bug in Earwigo too, if you try to import it. The Author Code is modified (while I see that it is correct when I unzip the file manually). Do you need these special chars? What if you ignore (skip) them? Quote Link to comment
+Ah! Posted February 28, 2020 Author Share Posted February 28, 2020 16 minutes ago, Tungstène said: Do you need these special chars? What if you ignore (skip) them? I downloaded the gwz file I sent you and found it had been changed. I corrected the author script part and that file now works OK for the £ sign !! I am not very computer savvy so it's quite disconcerting to find that there are so many problems/bugs etc. with this stuff. There is no way I can know for sure whether, when something doesn't work , is it my fault - probably - or not. I need all the keyboard characters because the player can input any text. Quote Link to comment
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.