I am pretty new at scripting and what I want is when a player is near an object (let’s say a car spawner) the player can type a letter on there keyboard and a GUI will show up. And the other thing is the same thing but for tools. Thank you
You could use a ProximityPrompt.
Another way is a ton of complex(ish) code that uses UserInputService to detect input and some other code to detect key presses within a range.
ProximityPrompt does everything you need without any complexity, though.
Related
I'm trying to build a simple KaiOS app with a text input but I can only insert numbers (numbers of the phone keyboard). Is there a way to write characters (like a specific input type)?
For example : if the 2 is pressed twice it prints B, or even better having the T9 feature and write hello with 43556 pressed).
I don't know if you're still on this issue (I doubt but it can help others). I had the same problem and actually, the emulator doesn't work very well and doesn't really trigger keys. So just use your own keyboard or test directly on the device.
Have you tried to switch to a different input mode?
If I remember correctly, that could be done by pressing the # button.
I am working on a word game where the user creates words from an ever changing grid of letters. Validating the users selection is easy enough to do using a wordlist.
Since the playing grid is randomly generated and previously played tiles are removed and replaced with new letters, I need to be able to effectively check for possible valid plays between each user submission, so if there are no possible valid words I can reset the grid or something to that affect. The solution only needs to detect that there is at least one valid 3 - 7 letter word within the current set of tiles. It does not need to know ever possible combination. A user can start on any tile and build a word using one tile away in any direction from the currently selected letter.
Important: The solution can't slow the game play down. As soon as the user submits the current word and the new tiles appear they can start a new selection without delay.
Any direction would be greatly appreciated as I have not been able to find what I think I'm looking for with any google searches so far.
Building with Swift for iOS8+
As #jamesp mentioned, a trie is your best bet. You have a couple of advantages for yourself here, the first one being is that you can bail out the second you have found a word. You don't have to scan the whole grid for all possible words, just find one and be done with it. Start with any random letter and look at the ones around it, and match those up against the trie. If you find a match, continue with the letters around that one and so on until you have found a word or a dead end. If the current start tile doesn't have a full word around it, go on to the next tile in the grid and try from there again.
It's going to take quite a bit of processing time to get through a problem like that, especially since the words can twist and turn.
There's a couple of ways to approach that, but if you have a fast dictionary lookup, you'll probably want to step through your puzzle, starting at the upper-left tile, and look at the letter there. Say it is "S". Your dictionary will provide you with a list of acceptable "S" words. You can step through those words looking at the second letter of each word and seeing if there is an adjacent tile to the current tile that has that letter. If not, you're done - move to the next tile. If so, you can do that exact same process again recursively for words starting with "S" and the next letter.
For instance, say the current tile is "S". You'd look up your list of "S" words, and start looping through them. One of them is "Syzygy". If there is no adjacent "Y" tile, you're done - move to the next word. If there is a "Y" tile adjacent, look around that tile for a "Z". If there is none, you're done. Otherwise, move to the second "Y", and so on. (If tiles can only be used once for a word, you may have to remember tiles to exclude from later letters, so that the player can't use the same "Y" three times to spell that "Syzygy".)
I'd wager that the vast majority of your tiles would be excluded quickly with this approach, but it still could take a long time to process, especially if your grid is large. You can address this by running that check in the background, and letting the player continue to play while it's checking, and then show an alert when you finally ascertain that there are no valid plays.
Keep in mind that just because there is one valid word in the puzzle, it doesn't mean that it's still really solvable by the end user. This sort of puzzle isn't like your typical match-three games where if you just look long enough, you'll find the match. Most "valid word" lists are going to contain many words that most people aren't going to know. Words like "propale" and "helctic" and "syzygy". (And you can't exclude words like that, because then when someone finds one, instead of the intense satisfaction of finding an obscure word, they get the intense frustration of "But that's a real word, dang it!")
So, probably what you want is an assessment of how obscure the existing words are. If "dog" is the only word available, that's still probably pretty solvable for most people, whereas if the only words available are "propale" and "helctic" and "syzygy", that's probably impossible for most people, even though there are more words available.
To do that, you'll need to rank your dictionary words as to how common they are, and then add up the ubiquity score for the existing words to make that sort of assessment, and calling the puzzle "unsolvable" if it doesn't reach a certain threshold for that score. Same algorithm, but you'll be adding a score for each word you find. And you can't just quit when you find the first word, but you can quit when you reach that threshold.
If this sounds daunting, then that's because you've designed yourself into a corner. A better approach might be letting the user swap some tiles if they're stumped, or letting them add a wildcard letter, etc. Things that they manage, so that even if there are no real words in the puzzle, they still have strategic options. Then you don't even have to solve this problem, and it solves the deeper problem of knowing whether a puzzle is practically solvable rather than technically solvable.
Why not construct your grid by first putting a randomly selected valid word somewhere on it and then filling in the blank spaces with random letters.
Edit
So if you can't do that, one way that might be quick enough is to organise your words in a trie. This might be enough to make the search fast enough. The idea would be to iterate through the letters in the grid and for each one select the appropriate first letter in the trie. This makes the search for each allowed neighbour smaller and so on until either your trie runs out or you find a word.
I would also select the random letters in a distribution that mirrors the distribution of letters in your dictionary. One way to do this is to
count the number of each letter in your dictionary to give each one a weight
generate a random number between 0 and the total of all the weights
iterate through the letters, subtracting each one's weight from your random number
when the subtraction gets below zero, the letter you are on is the one you want.
You can speed the above up by using a binary search but there's only 26 letters, so the extra complication isn't worth it.
if I call a function foo(t[1]) through the C API, can I in any way see what table and what index is as argument, in this case t and 1?
The problem at hand is a function move_card(card, table_slots[0]) where I move a card from one slot on a game area to another one. table_slots can also be hand or player_slots. This can be solved using a metatable, stating the name of the table being accessed. But the index is impossible to solve, or is it? table_slots[0] can be a card table, or an overlay or stack (arrays of cards), or nil if it's empty, as could player_slots. But what I need to know is in fact if it's from a table_slots or player_slots.
Could I hack some code analysis? Like, get the line where the function call is made, and then grep the index through a regexp? I could send table_slots[0] as a string, also, like move_card(card, "table_slot[0]"). Not as elegant, but still working.
No, once a value reaches a function, be it C or Lua, its origins are lost.
On the other hand, when an error occurs in Lua, the runtime system tries quite a bit to reconstruct the origin of the relevant values, but it does not always succeeds.
I am using DDMathParser in my app, and have recently come across the need to get occurrences of any group of numbers within a () parentheses bracket thingy (very highly technical!). For example, I would need to get (6+5) out of 6+7/8(6+5). Specifically, I would like to be able to do this so that I can make (56+9)sqrt compile just as well as sqrt(56+9). Any help?
P.S. I know that the maker of DDMathParser is often sighted in this neck of the woods. I am secretly hoping that he will come to the rescue and either fix my problem so I can implement it myself or him make it part of DDMathParser! :)
So, I've thought a lot about this question since you posted it a month ago. From what I understand, you're constructing a string as the user clicks/taps buttons.
I think this is your problem.
As the user taps buttons, you should be constructing (or modifying) DDExpression objects. This is the "pure" format of a math expression, whereas a string is lossy and difficult to manipulate. The string you show to the user should be generated from the DDExpression tree you're building.
This is a complex problem, and I'm still not entirely sure how I would go about implementing this, but this is the root of how I'd do it. I would not just construct a string based on what the user types.
I am using scintilla edit control in an MFC dialog based app.
I load scilexer.dll, and set the lexer to lua, but the only thing that is getting highlighted is the comments. I can also set keywords and they get highlighted:
mySciCtrl.SendMessage(SCI_SETKEYWORDS, 0, "for while end function")
However, I can not figure out how to enable highlighting of say lua basic functions like print, setmetatable, etc.
I thought that would be automatic just like the comments highlighting. Can anyone point me in the right direction?
Found it, it was pretty trivial of course just needed to look at the scintilla functions. So, if anyone else runs into this:
in your scintilla window class initilize color by using SendMessage(SCI_STYLESETFORE, SCE_LUA_WORD2, RGB(100,149,237)); for a second list of keywords.
Then in your dialog do m_ScinCtrl.SendMessage( SCI_SETKEYWORDS, 1, ( long )_T( "the words you want highlighted with the above specified color"));
SCE_LUA_WORD2 corresponds to integer value 1 in the second statement so if you want a third set of keywords highlighted differently just use SCE_LUA_WORD3 and integer value 2 in the second statement!