howdy all,
this is just a quick question, but im working on using alfred as a text expander, which is working very well. but i will mainly be using it for coding. but one thing that happens in coding is that you change function names etc, and what im trying to do right now is work out how to make it even more special.
now what i am thinking on is, is that i have a line of code, or even an entire keyboard function that is ready to go, but instead of the text being put in and then editing out what i need to change, i instead use alfred to put in arguments that change specific things in the text right away. ill post some code up to show exactly what i mean
but just say i tap 'cmd-spacebar' to bring up alfred. i then type in something like '-keyboardmovement' and tap enter to put it in sublime text, it will put in this exact text
function DEFAULT:key_down(key)
if key == string.byte('LEFT') then
DEFAULT-X = DEFAULT-X - DEFAULT-SPEED
elseif key == string.byte('RIGHT') then
DEFAULT-X = DEFAULT-X + DEFAULT-SPEED
end
if key == string.byte('UP') then
DEFAULT-Y = DEFAULT-Y + DEFAULT-SPEED
elseif key == string.byte('DOWN') then
DEFAULT-Y = DEFAULT-Y - DEFAULT-SPEED
end
end
now as you can see, i would now need to start editing everything that says 'DEFAULT', 'DEFAULT-X/Y' and 'DEFAULT-SPEED'. whilst its alright, it still means going back to edit.
but, what i would like some sage like advice on, is how could i set arguments when first typing in '-keyboardmovement', that would then affect each 'DEFAULT' to my own liking.
so when alfred is open, i type in '-keyboardmovement' then right after it asks for the first argument, which would be 'playerMove', the next argument would be for 'playerPosX', the next would be for 'playerPosY'... and so on.
but then the output with my inputted arguments in alfred would then make the code look like this
function playerMove:key_down(key)
if key == string.byte('LEFT') then
playerPosX = playerPosX - playerSpeed
elseif key == string.byte('RIGHT') then
playerPosX = playerPosX + playerSpeed
end
if key == string.byte('UP') then
playerPosY = playerPosY + playerSpeed
elseif key == string.byte('DOWN') then
playerPosY = playerPosY - playerSpeed
end
end
so, how could i work on something like that using alfred as the text expander?
i know in sublime text when making cheap auto-complete in JSON, is that its has this type of way 'function(${1:first}, ${2:second})', but ive never used alfred to do this type of thing
this will take me some time to make in the end. but id like to work on it as im going along in my coding, so i can put things in a take things out as im making stuff
thanks to anyone who can point me in the right direction
best