put a global var into string

hello
i really need a little help...
i dont know if people in here are the type
of keeping knowledge or information for themselves
so my apologies if iam hurting anyone sensibilities for asking questions.

this is for a computer game iam making alone.
i really need to create a global variable with a name like "map2"
then store this "map2" into a string maybe...
then call this "map2" string later on...

example

1
2
3
4
file1.txt 
void main() 
{
	setglobalvar("gomap", map2);
}



1
2
3
4
5
file2.txt 
    float exit = getglobalvar("gomap");

    if(frame==15){
	jumptobranch(exit, 1);
    }


its very simple i just need to get that name "map2"
and put it on jumptobranch...

i dont have college professor in my pocket so my opologies for looking dumb.


i really need to create a global variable

I don't believe in the "need".

Why can't you pass the data as a reference parameter?
Why can't you pass the data as a reference parameter?


i cant because i have to change the "setglobalvar("gomap", map2);"
to map1 / map2/ map3/ map4/ etc...

so i need to put the word "mapNÂș" in the jumptobranch so that the file2.txt goes to the correct mapNÂș.

i could use jumptobranch(map2, 1); but i would need to create a new txt file
like ?!?!?!?

file1.txt jumptobranch(map1, 1);
file2.txt jumptobranch(map2, 1);
file3.txt jumptobranch(map3, 1);
file4.txt jumptobranch(map4, 1);
file5.txt jumptobranch(map5, 1);

i just need to put the golbal variable name on a string or char
then put that string or char in the jumptobranch....
Who does/will change the "gomap"? The main()?
yes
the "void main()" in file1.txt in the frist post above
i really need to create a global variable with a name like "map2"

unlike some other languages, in c++ you can't create global variables dynamically. You can however, create objects dynamically and store then in a global container, such as std::map.

Since you have not shown your code for setglobalvar, getglobalvar, or jumptobranch, it's impossible for us to know what these functions do.

Is file1.txt supposed to be C++? if so, main must be type int, not void.

Are these files (file1.txt, file2.txt, etc) files that you're trying to interpret at run time?

i dont know if people in here are the type of keeping knowledge or information for themselves

If we were the type of keeping information to ourselves, this forum would not be successful.
Last edited on
it's impossible for us to know what these functions do.


i also cant get access to the code...
are you familiar with the microsoft XNA... by the time it came with libraries and functions like health, speed, etc.. you could call them anytime and use them for lots of things...

but in here i can only access the jumptobranch script log...
####animationscript function main#####
# data/chars/misc/branch/homexit.txt
########################################
void main()
{
int frame = getlocalvar("frame");
int animhandle = getlocalvar("animhandle");
if(animhandle==813)
{


void self = getlocalvar("self"); //Get calling entity

void exit = getglobalvar("gomap");



if(frame==15){

jumptobranch(exit, 1);

}

return;
}

}


in this script log theres nothing wrong...
but "globalvar" sets a value in memory that will clear once you exit the aplication...
"localvar" will set it in an object or function (i think?!?)

this is the original setglobalvar description
setglobalvar(varname, value)
~Set a persistent global variant's value by name. If the value is empty, the variant will be deleted.
~Return 1 if succeeded, 0 if failed.
~See 'global variants'.
~Notice: It is important to remove unused global variants since there's a limit in amount.



The only place where Google finds {getlocalvar,setlocalvar,jumptobranch} is not XNA but the description of the script language of some "OpenBOR" game engine.

void self = ...

Obviously, your question is about neither C nor C++.

Are you sure that there is no Forum for this game engine? They could help you much better than us. Our knowledge about never-heard-of-foreign-things is not infinite.
Last edited on
Topic archived. No new replies allowed.