Facebook Twitter YouTube Frictional Games | Forum | Privacy Policy | Dev Blog | Dev Wiki | Support | Gametee


Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Couple of Questions
DRedshot Offline
Senior Member

Posts: 374
Threads: 23
Joined: Jun 2011
Reputation: 11
#1
Couple of Questions

OK, i have a couple of questions,
1. in my map there is a part where i am froze to the spot, while a few visual things happen, after the visuals are over, a few script areas are activated (AddEntityCollideCallback). If One of these areas are activated whilst i am inside it, will the alState be 1? or will it be undefined untill i leave and reenter it?

2. how do i convert an integer into a string and vica versa? eg
void OnStart()
{
           for(int i=0, i<10, i++)
          {
           AddEntityCollideCallback("Player , i  , Collide , False , 1);
          }
AddLocalVarInt("Number" , 0);
}
void Collide(string &in asParent , string &in asChild , int &in alState)
{
SetLocalVarInt("Number" , asChild);
}
in this code i is an integer not a string, so it wont work in the AddEntityCollideCallback, also, asChild is not an integer, so it wont work in the SetLocalVarInt, help?

07-06-2011, 11:53 PM
Find
MrBigzy Offline
Senior Member

Posts: 616
Threads: 18
Joined: Mar 2011
Reputation: 8
#2
RE: Couple of Questions

Er, this code would just set more integers, not create a string. Is there any reason why you would want to do that conversion? Are you trying to suffix strings for multiple callbacks?

Also for your first question, I'm pretty sure the boundaries of the area are the only thing that trigger the state and not the area itself. I could be wrong though; you would have to do some testing if you need to find out. Doing a debug might give you a message telling you whether you entered it or not.
(This post was last modified: 07-07-2011, 12:24 AM by MrBigzy.)
07-07-2011, 12:20 AM
Find
DRedshot Offline
Senior Member

Posts: 374
Threads: 23
Joined: Jun 2011
Reputation: 11
#3
RE: Couple of Questions

Yeah, basically, my script has 9 areas, named simply 1 to 9, and if im in one of these areas whilst looking away from an entity, named entity1 and entity2, it spawns a new entity, either entity1_(1 to 9) or entity2_(1 to 9) depending on which area im stood in. i hope that makes sense to you,

and thanks for answering my first question, i will try a debug message in a minute

EDIT: I managed to get it working fine, i declared int i as a string, and used LocalVarStrings instead of LocalVarInts

(This post was last modified: 07-07-2011, 12:51 AM by DRedshot.)
07-07-2011, 12:26 AM
Find
Apjjm Offline
Is easy to say

Posts: 496
Threads: 18
Joined: Apr 2011
Reputation: 52
#4
RE: Couple of Questions

Just for future reference, to you initial request for #2.

Integer to string conversion is easy, just append the integer onto the end of a string and angelscript will do the rest.
//Example usage

void example() {
int x = 50;
string s = "" + x;
}
String to UNSIGNED integer conversion, not so easy, need to build a parsing function. I've already built one though, so feel free to use it.
//Usage:
void example() {
string s = "a1b2c3d4";
int x = parseStringInt(s);
//X now equals 1234
}
//Helper functions written by me (Apjjm):
int getDigit(uint8 digit) {
    int d = digit-48; //48 is ASCII code for 0
    return ((d >= 0)&&(d<=9)) ? d : -1;
}
int parseStringInt(string str) {
    int output = 0;
    for(uint i=0; i<str.length(); i++)
     {
      int digit = getDigit(str[i]);
      output = (digit > -1)?(10*output+digit):(output);
     }
    return output;
}
(This post was last modified: 07-07-2011, 01:25 AM by Apjjm.)
07-07-2011, 01:22 AM
Find
DRedshot Offline
Senior Member

Posts: 374
Threads: 23
Joined: Jun 2011
Reputation: 11
#5
RE: Couple of Questions

Thank You, that may come in handy at some point.

07-07-2011, 01:26 AM
Find




Users browsing this thread: 1 Guest(s)