Forum
Stranded II Scripts Scripting Questions Ice has written
hmm, sorry, I'm a big noob there, but how do I create a global variable?
either use global , or just set it to a value without defining it at all before
1
2
3
4
5
6
7
8
9
2
3
4
5
6
7
8
9
on:keyhit01 { 		$IDMainResearch=create("object",240); 		addscript "object",$IDMainResearch,"sys/scripts/anw_research.s2s"; 		msg "Script added to MainResearch $IDMainResearch",3; 		Setlocal "object", $IDMainResearch, "$ID_MainResearch" , $IDMainResearch; 		event doresearch,"object",$IDMainResearch; 		free "object",$IDMainResearch; 		freevar $IDMainResearch; 	}
my code in anw_research.s2s:
1
2
3
4
2
3
4
on:doresearch { 	msg "Mainresearch= $IDmainResearch",3; 	msg "Mainresearch= $ID_mainResearch",3; }
So I should have $IDMainResearch as a global variable, and anyway $ID_mainResearch as a local with the same value as $IDmainResearch, right?
Well the first msg, without the event call, is good (260+)
The two other msg, to test the values in the event, are always 0
But you don't need the local variable anyway, since it contains the ID of the object they are assigned to, it would be much simpler to use currentid
EDIT:
it anyway is better NOT to use capital letters in variable-names
Flying Lizard has written
in the one code you wrote $ID_MainResearch, in the other $ID_mainResearch, those are 2 different variables.
But you don't need the local variable anyway, since it contains the ID of the object they are assigned to, it would be much simpler to use currentid
But you don't need the local variable anyway, since it contains the ID of the object they are assigned to, it would be much simpler to use currentid
Arghhhh I didnt thought about the case! In delphi the variables are not case sensitive!
Ok, after more test, the setlocal work, but the global variable seems to not be reachable from another object/event, and the currentid return 0???
I will work with setlocal, and will pay attention to the case!
this should work doesn't it?
on:doresearch {
$id=currentid ();
msg "$id";
}
When a script is running, and is calling an event. Does it "pause" until the event have finished running?
Same question with "process"?
My first guess with the few tests I did would be "yes" and "no", but I have some strange things with process.
Similiar with the process function: the process bar actually shows up after your script get executed, and will add an event caller to the event queue.
I'm not sure about timers, but since BB3D is a non-threaded language I don't think DC was able to implement real timers, so it should behave similiar (the event queue is mostly empty anyway)
anyway... I will not be working on my mod for aboud 2 days, since my PSU exploded last night :S
Hopefuly it only my PSU that broke and nothing else.
New PSU have been ordered and should arive at my home in 1-2 days
Just a quick info for you
//Satis
So far, I think your code could use a major overhaul. Basically, the trick I found to prevent any lag due to large files, is to create a temporary object and to load into it the script from a .s2s file
This way, the game only load the code needed. My only problem is the backward communication. I can start the script of the temporary object, but I have a hard time to start another object script from this last one! (dont know if I'm understandable here...)
Anyway, look at the "addscript" command, I think it can be the correct solution.
Ice has written
I can start the script of the temporary object, but I have a hard time to start another object script from this last one! (dont know if I'm understandable here...)
If I'm understanding you right, you'll have to know the "class" and "id" of the object, where you'll have to trigger an event. For example by
1
event "unit",100;
color=r,g,b
Farbe (je 0-255)
anyway you should remember that if you make a map with this gunpowder, other people will not be able to play the map.
Thanks
Flying Lizard has written
anyway you should remember that if you make a map with this gunpowder, other people will not be able to play the map.
Yes I know that, it's for my personal usage (for now).
I know how to work with the script color, so I'll give you exact term:
on:start {//I tried also on:load
color 30,30,30;
}
This is not my problem, my problem is, that model of the gunpowder(flour) does't have dark color, only on start, but not after I drop it...(It's a bit chaotic I know )
(Look, there is a = wich means it is a definition parameter)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
2
3
4
5
6
7
8
9
10
11
12
13
14
on:start { 	local $id; 	$id=create("item",120,0,0,5); 	store $id,"self"; 	freevar $id; } on:use { 	exchange "self",1; } on:kill { 	if (count_stored("self",120)>0){ 	explosion getx("self"),gety("self"),getz("self"),$radius,$damage; 	} }
But my "if" doesn't work and I don't know why(it doe's nothing). I think the problem is in "count_stored", but where. Please I tried almost everything:-)
If you don't need variable values, uses number instead of variables -> explosion getx("self"),gety("self"),getz("self"),50,50; (or something like that )
So at start, there are 5 pieces of gunpowder. If I use it, it opens an exchange menu. But when I "kill" it, do nothing. I tried also:
on:kill {
local $gnp
$gnp=(count_stored("self",120));
msg "$gnp gunpowders in the barrel";
}
And message always reads 0 gunpowders in the barrel, so this might be the problem, but where ?