Forum

> > Stranded II > Scripts > Scripting Questions
Forums overviewStranded II overview Scripts overviewLog in to reply

English Scripting Questions

2,429 replies
Page
To the start Previous 1 210 11 12121 122 Next To the start

old Re: Scripting Questions

bizzl
User Off Offline

Quote
Ice has written
hmm, sorry, I'm a big noob there, but how do I create a global variable?

either use s2 cmd global , or just set it to a value without defining it at all before

old Re: Scripting Questions

Ice
User Off Offline

Quote
my code in Game.inf:

1
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
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

old Re: Scripting Questions

Flying Lizard
User Off Offline

Quote
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 s2 cmd currentid

EDIT:
it anyway is better NOT to use capital letters in variable-names

old Re: Scripting Questions

Ice
User Off Offline

Quote
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 s2 cmd 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!

old Re: Scripting Questions

Flying Lizard
User Off Offline

Quote
o.O somehow you're making really strange mistakes.

this should work doesn't it?

on:doresearch {
$id=currentid ();
msg "$id";
}

old Re: Scripting Questions

Ice
User Off Offline

Quote
yeah currentid work. I dont know how the hell I managed to make it go wrong the first time

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.

old Re: Scripting Questions

bizzl
User Off Offline

Quote
nope. the event function just add an event caller at the end of the event queue, and your script will be executed sometime after the current script is finished.
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)

old Re: Scripting Questions

Satis
User Off Offline

Quote
great to see that you are making progress with my bug

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

old Re: Scripting Questions

Ice
User Off Offline

Quote
hehe I'll not work on it either, I'm away for 4 days

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.

old Re: Scripting Questions

Guest

Quote
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;
where "unit" is the class of the object and 100 the id of itself.

old Re: Scripting Questions

HudaJan
Super User Off Offline

Quote
It's not very "scripting" question, but is it possible to create new models? Ok, I'll tell you. I tried to make the gunpowder. I used upgraded icon of flour. I also used model of flour, than i assigned script "colour etc.". It works perfectly. The new item is in menu and when it is on the ground it is like dark flour. But if I take it, then drop it, the colour is again white. I understend why, but how can I avoid this? Is it possible? Thx

old Re: Scripting Questions

Flying Lizard
User Off Offline

Quote
Try using the corresponding definition parameter

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.

old Re: Scripting Questions

Don Philippe
User Off Offline

Quote
I have a little question! If I had the figure 18.2 ('cause of command getplayervalue), what can I do to transfer this number to the next highest one, in this case 19.

Thanks

old Re: Scripting Questions

HudaJan
Super User Off Offline

Quote
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 )

old Re: Scripting Questions

Flying Lizard
User Off Offline

Quote
I know exactly what you kean, if you use my solution in the definition of the object it works.
(Look, there is a = wich means it is a definition parameter)

old Re: Scripting Questions

HudaJan
Super User Off Offline

Quote
Ehm, another problem.

1
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;
	}
}
first two parto works(from on:start to exchange..)
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:-)

old Re: Scripting Questions

bizzl
User Off Offline

Quote
$radius and $damage are not initialized and therefor counts as 0.
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 )

old Re: Scripting Questions

HudaJan
Super User Off Offline

Quote
No no, this is not a problem. This is changeable value, what is deafutly set on something(in this case it is 100,50). As you maybe recognized it is explosive barrel. I wanted to make him explode only if there are some amount of item(120 its gunpowder from post before:-) ). Im'quite sure, that the problem is in "count_stored".
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 ?
To the start Previous 1 210 11 12121 122 Next To the start
Log in to reply Scripts overviewStranded II overviewForums overview