So, I am working on my Senses System (see my journal) and I temporarily typed the following code(LUA):
function TriggerEmotionChange() if See(box) then mood = 10 setText(state, getName(box) .. "es " .. "make me glad") elseif See(monkey) then mood = 3 setText(state, getName(monkey) .. "s " .. "make me sad") elseif See(building) then mood = 5 setText(state, getName(building) .. "s " .. "make me turn around in circles") end end
This made me want to create a grammar system. I know I need to do some operations on strings, namely checking whether the last letter in a string is a certain letter and then adding the appropriate ending. I know I would do a few if/else statements and then one else statement to check if all other letters of the alphabet.
Just in case someone wanted to know what the code does:
In the example above, the getName() function gets the name of the game object and returns a string.
The "state" variable is just a text game object.
The value of the mood value determines the emotional state of the character.
Anyone have any tips on how I might go about the grammar system (shouldn't take long to implement it) for "ing" and "es or s" endings?
Just a little something to get me started on how I should approach it in an efficient way?