Steve_Yorkshire Posted August 17, 2018 Share Posted August 17, 2018 For some reason, tab seperated strings hate me. :? Sometimes my custom player/aiplayers will spawn with skin set to "alt3 alt4" as the tabbed string decides to ignore the tab seperation because ... because it hates me. :cry: A second issue with the stock skin selection is that %skin = addTaggedString( getField(%availableSkins, getRandom(%count)) ); gives the whole getCount(), but getRandom() starts at 0, meaning that it's looking for 1 more skin than is available because "base" skin is in the availableSkins string.So I changed everything to words seperated with a space. Player/AIPlayer datablock //availableSkins = "base alt1 alt2 alt3 alt4"; availableSkins = "base alt1 alt2 alt3 alt4";//words not tabs In wherever you have the randomized skin function (scripts/server/gameBase.cs is stock) // Choose a random, unique skin for this client %count = getWordCount(%availableSkins);//getFieldCount(%availableSkins);//tabs out words in if(%count > 0) { %skin = getWord(%availableSkins, getRandom(%count - 1));//now with -1 for the real number //%skin = addTaggedString( getField(%availableSkins, getRandom(%count)) ); %player.setSkinName(%skin); echo("skins " @ %count SPC %skin); } Not entirely certain why tabbed fields were chosen over spaced words for stock but hey. :| Quote Link to comment Share on other sites More sharing options...
Duion Posted August 17, 2018 Share Posted August 17, 2018 I noticed "\t" being used as a separator in my code sometimes, is that a replacement for the tab? Quote Link to comment Share on other sites More sharing options...
fLUnKnhaXYU Posted August 18, 2018 Share Posted August 18, 2018 Torque3D Documentation Release 3.5.1p. 373Field ManipulatorsFunctions to deal with whitespace-seperated lists of values in strings. TorqueScript excessively uses strings to representlists of values . The functions in this group simplify working with these lists and allow to easily extract individual valuesfrom their strings .The list strings are segregated into three Groups according to the delimiters used to separate individual values in thestrings Strings of words; Elements are separated by newlines (n), spaces or tabs (t). strings of fields: Elements are separated by newlines (n),or tabs (t). strings of records: Elements are separated by newlines (n)Aside from the functions here , another useful means to work with strings of words is TorqueScripts foreach$ state-ment .some other page -bool isspace (string str, int index) Test whether the character at a given position is a whitespace character. Characters such as tab, space, or newline are considered whitespace. Parameters str - the string to test. index - the index of a charcter in str Returns true if the character at the given index in str is a whitespace character, false otherwise. Quote Link to comment Share on other sites More sharing options...
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.