QuickCat allows mapmakers to easily concatenate strings in a variety of ways. This is especially useful for large loops where individually concatenating strings would take a very long time. For you noobs out there: Concatenating strings means combining them together. ;)
Basic features:
Simple installation - just load the library and begin using the function
Basic example trigger included
Instructional notation included
Can add a string to the front or back of another string, or after an index or word position
Changelog
0.2
Added a function to replace underscores with spaces
Improved function speed
Added overflow protection
Demonstration
This function allows you to quickly concatenate strings, adding one string to another at the specified index or word. An index of 0 adds the Addition string to the front (left) of the Primary String.
-1 adds the Addition string to the back (right.) All other positive numbers add the Addition string to the right of that index or word.
Position Type lets you define whether to place the Addition after an index position or a word. Disregard this value if you use -1 or 0 for Position.
Example trigger:
TestEventsGame-PlayerAnyPlayertypesachatmessagecontaining"-front",matchingPartiallyGame-PlayerAnyPlayertypesachatmessagecontaining"-back",matchingPartiallyGame-PlayerAnyPlayertypesachatmessagecontaining"-index",matchingPartiallyGame-PlayerAnyPlayertypesachatmessagecontaining"-word",matchingPartiallyLocalVariablesConditionsActionsGeneral-Switch(Actions)dependingon(Word1of(Enteredchatstring))CasesGeneral-If("-front")ActionsUI-Display(Text((QuickCat(" comes before this statement.",(Word2of(Enteredchatstring)),0,Index))))for(Allplayers)toSubtitleareaGeneral-If("-back")ActionsUI-Display(Text((QuickCat("Something which follows is ",(Word2of(Enteredchatstring)),-1,Index))))for(Allplayers)toSubtitleareaGeneral-If("-index")ActionsUI-Display(Text((QuickCat("Somewhere within this statement is something neat.",(Word3of(Enteredchatstring)),(Integer((Word2of(Enteredchatstring)))),Index))))for(Allplayers)toSubtitleareaGeneral-If("-word")ActionsUI-Display(Text((QuickCat("Somewhere within this statement is something neat.",(Word3of(Enteredchatstring)),(Integer((Word2of(Enteredchatstring)))),WordofString))))for(Allplayers)toSubtitleareaDefault
Installation
Download the library, then from the trigger editor right click in the top left window and go down to Library -> Import Library. Select QuickCat from the directory into which you downloaded and hit OK. Then simply call the function as needed. It returns a String value.
Known Issues
Using QuickCat to concatenate a string with a space at the front or the back will cause that space to be dropped depending on how the function is used. This occurs especially when using the Word of String function, which uses spaces to separate words even if there are multiple spaces next to each other in a string. This can be corrected by setting Replace Underscore With Space to True when you call the function. Then, put underscores where you want spaces to be.
I would recommend adding some tick counter when you use repeat forever (which could be replaced by 'while' btw). Then when counter mod 1000 == 0 you call wait 0.0 (Wait 0 actually waits quite a lot once you add it up.)
It's function with return which do not (and can't) run on separate thread so often waits will lead to unnecessary slowdown.
Interesting, thanks for the advice. Is there a practical difference between a While loop and a Repeat Forever loop (besides being able to use conditions for the while loop?) I've used both but have never really noticed any changes between the two.
Also, about how many times can a loop repeat in a single game tick before causing bad lag/crashes?
Interesting, thanks for the advice. Is there a practical difference between a While loop and a Repeat Forever loop (besides being able to use conditions for the while loop?) I've used both but have never really noticed any changes between the two.
Also, about how many times can a loop repeat in a single game tick before causing bad lag/crashes?
Well there's no such thing as repeat forever itself. In code, as you can see, it's: while (true),
Limit is around 690k operations per game tick i believe. Wait 0.0 pushes execution to next tick.
Still you need to count the fact that user may be running a lot of actions prior to your function call. This vary a lot. Personally i had issues with 6k+ loops
So count mod 1000 or 500 it's safe limit. Probably won't even reach it in single call yet it's worth to have it because error breaks everything.
Alright, thanks. It would be extremely rare for my particular function to exceed more than, say, 100 loops, though perhaps not impossible. Just in case, I'll throw in an overflow protection check.
I'd suggest making more effective use of negative position values, extending the logic of the reverse indexing.
What do you mean? I can't really think of any practical use for having reverse indexing. An index of 0 already moves the Addition string to the front. Any more than that would simply add spaces which you can put in the Addition string anyway...
Oh, right, I added a function to convert underscores to spaces to get around that one annoying problem. ;)
QuickCat v0.2 by BasharTeg
Description
QuickCat allows mapmakers to easily concatenate strings in a variety of ways. This is especially useful for large loops where individually concatenating strings would take a very long time. For you noobs out there: Concatenating strings means combining them together. ;)
Basic features:
Changelog
0.2
Demonstration
This function allows you to quickly concatenate strings, adding one string to another at the specified index or word. An index of 0 adds the Addition string to the front (left) of the Primary String.
-1 adds the Addition string to the back (right.) All other positive numbers add the Addition string to the right of that index or word.
Position Type lets you define whether to place the Addition after an index position or a word. Disregard this value if you use -1 or 0 for Position.
Example trigger:
Installation
Download the library, then from the trigger editor right click in the top left window and go down to Library -> Import Library. Select QuickCat from the directory into which you downloaded and hit OK. Then simply call the function as needed. It returns a String value.
Known Issues
Download
Link Removed: http://www.mediafire.com/?mmdvwbviek2mw6w
Link Removed: http://www.mediafire.com/?le77u1r8dur7s8m
I would recommend adding some tick counter when you use repeat forever (which could be replaced by 'while' btw). Then when counter mod 1000 == 0 you call wait 0.0 (Wait 0 actually waits quite a lot once you add it up.)
It's function with return which do not (and can't) run on separate thread so often waits will lead to unnecessary slowdown.
@Nerfpl: Go
Interesting, thanks for the advice. Is there a practical difference between a While loop and a Repeat Forever loop (besides being able to use conditions for the while loop?) I've used both but have never really noticed any changes between the two.
Also, about how many times can a loop repeat in a single game tick before causing bad lag/crashes?
I'd suggest making more effective use of negative position values, extending the logic of the reverse indexing.
Well there's no such thing as repeat forever itself. In code, as you can see, it's: while (true),
Limit is around 690k operations per game tick i believe. Wait 0.0 pushes execution to next tick.
Still you need to count the fact that user may be running a lot of actions prior to your function call. This vary a lot. Personally i had issues with 6k+ loops
So count mod 1000 or 500 it's safe limit. Probably won't even reach it in single call yet it's worth to have it because error breaks everything.
@Nerfpl: Go
Alright, thanks. It would be extremely rare for my particular function to exceed more than, say, 100 loops, though perhaps not impossible. Just in case, I'll throw in an overflow protection check.
What do you mean? I can't really think of any practical use for having reverse indexing. An index of 0 already moves the Addition string to the front. Any more than that would simply add spaces which you can put in the Addition string anyway...
Oh, right, I added a function to convert underscores to spaces to get around that one annoying problem. ;)