+Delta68 Posted January 29, 2019 Share Posted January 29, 2019 How do I do this Javascript in lua in Urwigo? Obviously var v will be declared as a global variable. I can't see how to write a function and pass it parameter n Thanks var v=0; function checkV(n) { v = v | n; return(v==7); } Quote Link to comment
Ranger Fox Posted January 29, 2019 Share Posted January 29, 2019 What are you trying to accomplish? Are you just trying to say you'll allow all values less than or equal to seven until the first number greater than seven is seen, then it's false for all values after that? You'd have to look in the lua language specification to see if there's an operator that would give you want you want without having to refactor to use an if statement. Quote Link to comment
+Delta68 Posted January 29, 2019 Author Share Posted January 29, 2019 I was trying to do bitwise ORs so the player had to talk to three characters before proceeding. Returning to a character a second time would be ignored So, talking to the charaters would OR 1, 2 , 4 Probably a bit excessive for this project so I've used three flags instead now Thanks Quote Link to comment
+technetium Posted January 31, 2019 Share Posted January 31, 2019 Wherigo uses a version of lua that does not come with the bit module. So if you want to implement bitwise operators, you have to implement them yourself. For your problem I think I would define an array, set the n-th position true and check if they all are true in a loop, (or for just three in an explicit and statement) 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.