![]() |
How to convert a string to an integer? - Printable Version +- Frictional Games Forum (read-only) (https://www.frictionalgames.com/forum) +-- Forum: Amnesia: The Dark Descent (https://www.frictionalgames.com/forum/forum-6.html) +--- Forum: Custom Stories, TCs & Mods (https://www.frictionalgames.com/forum/forum-35.html) +--- Thread: How to convert a string to an integer? (/thread-8533.html) |
How to convert a string to an integer? - cook - 06-11-2011 As the title says, making a script that returns the Entity's 6th letter(which is a number) that is being interacted with to a string using SetLocalVarString("bigman", StringSub(asEntity, 5, 1));, but that didn't work. Couldn't use LocalVarInt bigman either. I believe I need a way to convert it to an integer to make use of it like so SetEntityActive("crowbar_joint_"+"bigman", true); It's for a crowbar that works on all doors script so I don't have to copy like 30 lines of code 9 times, if anyone could think of a easier way to do it please tell me. Also, while I am here, what is the actual definition of a signature? RE: How to convert a string to an integer? - palistov - 06-11-2011 I read something on the FricGames blog that mentioned AngelScript being a strong-typed language. Try this: for(int x=1;x<2;x++) if(StringSub(asEntity, 5, 1) == x) SetLocalVarString("bigman", x); This line doesn't try to convert the string into an integer it just tries to make a relation between the two. Change SetLocalVarString to SetLocalVarInt if that's what you need. Not sure if it will work but it's a guess ![]() RE: How to convert a string to an integer? - MrBigzy - 06-11-2011 You would use it like this: SetEntityActive("crowbar_joint_"+bigman, true); With bigman as LocalInt of course. Edit: Oh, for multiple areas. Just do: for(int i=1;i<10;i++) SetEntityActive("crowbar_joint_"+i, true); RE: How to convert a string to an integer? - Apjjm - 06-11-2011 I wrote a function some time back that parses out all the digits from a string and converts them into one integer. E.g: "1a2b3c" would become 123. Code: int getDigit(uint8 digit) { RE: How to convert a string to an integer? - cook - 06-11-2011 Thanks a lot guys |