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 255 56 57121 122 Next To the start

old Re: Scripting Questions

DontKnowToScript
User Off Offline

Quote
use the banana scripts for example,event ai_eat.
use on animal if (gotstate("self","tame")==1){
//do something
//another thing
//third thing
}
and thats it.

old corn help

darksol
User Off Offline

Quote
i just made a new item it is corn and i want to make it so that you can fry it and make corn on he cob. win i went to go test out fry and the eat it dose not let me do it can some one help me.

heres the code

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
### corn
id=137
name=corn
group=stuff
icon=gfx\corn.bmp
model=gfx\cornraw.b3d
scale=2
fx=16
mat=flesh
weight=200
info=i cant wate to fry it up
healthchange=0
	//Fry!
	on:use {
		if ((count_inrange("state",5,50)+count_inrange("state",4,50))>0){
			process "frying",500;
			fry;
			alteritem 1,138;
		}else{
			msg "I need fire to fry this!",3;
			speech "negative";
		}
	}
	//Eat
	on:eat {
		process "eating",1000;
		eat 0,10,5,0;
	}
script=end

### corn(cooked)
id=138
name=corn on the cob
group=stuff
icon=gfx\corncooked.bmp
model=gfx\corn.b3d
scale=2
fx=16
mat=flesh
weight=200
info=i love corn on the cob
healthchange=0
	//Eat
	on:eat {
		process "eating",1000;
		eat 5,10,5,3;
	}

old Re: Scripting Questions

CoreyRDean
User Off Offline

Quote
Okay guys I'm not sure exactly what happened but I was putting a horse into my mod and idk what happened the horse works fine but I have aggressive natives in my mod and in the code the horses are right under the natives

1
2
3
4
5
### Aggressive Native
id=49

### Horse
id=50

anyway the bug I got was I put some natives on an island with me and after a few seconds they turn into horses what i'm think is there is a leak in the code somewhere around
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
on:newPath { 
		$rnd=random(1,9);

		if ($rnd==1 || $rnd==2){ 
			ai_mode "self", "mover";
		}
		if ($rnd==3 || $rnd==4){ 
			ai_mode "self", "movel";
		}
		if ($rnd>4){
			ai_mode "self", "move";
		}
		if(inrange(self ,430)){
			msg "Mam Mam!";
			$x=getx("self");
			$z=getz("self");
			$newId=create("unit",50,$x,$z);
			$sh = health(self);
			$h = $sh -100;
			health "unit", $newId, $h;
			free "self";
		}
		if($h < 100){
			health "self", 1;
		}
	}
Because right before like a millisecond before the the natives turn to horses the message "mam mam!" is shown one message for each native on the island. I've tried to fix it but im stumped please can someone help me out?

old Re: Scripting Questions

bezmolvie
User Off Offline

Quote
try putting somthing else between horse and AGN and give us both of they're scripts. Still odd though...

old Re: Scripting Questions

CoreyRDean
User Off Offline

Quote
EDIT: I figured out what the problem but now I have another problem

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
on:intro {
	// Intro Music
	music "music_castaway.mp3",0.4;

	// strong blur
	blur 0.85;
	
  
	// setup intro sequence
	seqstart 1,1;
	seqtimemode 1000,1;
	cammode 0,1,"info",10; // Camera Points at Ship
	
	// ------------------------------------------------------------------------------ intro start

	// scene 1
	setcam 0,2;
	seqfade 0,1500,0,0,0,2;
	seqmsg 6,"Ryan Dean Games",5;
	seqfade 8,10000,0,0,0,0;
	seqmsg 9,"Presents...",5;

	// scene 2
	seqevent 9,"scene2a";
	setcam 9,11;
	seqevent 12,"scene2b";
	seqmsg 14,"A second adventure",5;
	seqmsg 20,"A second chance to survive",5;
	seqfade 24,26000,0,0,0,0;

	// scene 3
	seqevent 25,"scene3a";
	setcam 25,5;
	movecam 25,30000,6;
	seqevent 30,"scene3b";
	seqmsgclear 24;
	seqmsg 26,"A second Cast Away",5;
	seqfade 34,36000,0,0,0,0;

	// scene 4
	seqevent 35,"scene4a";
	setcam 35,7;
	seqmsgclear 34;
	seqmsg 37,"Only nature will decide when it's time",5;
	movecam 35,45000,8;
	seqevent 37,"scene4b";
	seqevent 38,"scene4c";
	seqevent 39,"scene4c";
	seqevent 40,"scene4b";
	seqevent 42,"scene4c";
	seqevent 43,"scene4c";
	seqmsg 43,"Cast",5;
	seqevent 46,"scene4d";
	seqmsg 49,"Away",5;

	// scene 5
	movecam 53,45000,12;
	seqmsgclear 54;
	seqmsg 55,"Again",5;
	seqmsg 56,"Cast Away Again Coming Soon",5;
	seqfade 57,53000,0,0,0,1;
	seqmsgclear 58;
	
	// ------------------------------------------------------------------------------ intro end

	// end intro / loadmap
	seqevent 59,"loadnextmap";

}

on:skipsequence {
	event "loadnextmap","global";
}

// scene 1
// stuff is done in intro event

// scene 2
on:scene2a {
	setpos "info",10,$x,$y,$z;
	freeunitpath 101;
	unitpath 101,3;
}
on:scene2b {
	thunder;
}

// scene 3
on:scene3a {
	setpos "info",10,$x,$y,$z;
	freeunitpath 101;
	unitpath 101,3;
}
on:scene3b {
	thunder;
	flash 230,230,255;
	addstate "info",10,"electroshock";
	addstate "info",10,"smoke";
	$x2=getx("info",10);
	$y2=gety("info",10);
	$z2=getz("info",10);
	explosion $x2,($y2+100),$z2,150;
}

// scene 4
on:scene4a {
	setpos "info",10,$x,$y,$z;
	freeunitpath 101;
}
on:scene4b {
	explosion $x,($y+80),$z,300;
}
on:scene4c {
	explosion $x+random(-50,50),($y+random(50,80)),$z+random(-50,50),100;
}
on:scene4d {
	flash 255,180,50,0.05,2.0;
	play "explode.wav";
	free "info",10;
	fademusic 8000;
}

// load next map
on:loadnextmap {
	loadmap "maps\adven2\firstile.s2";
}

In the code above the sequence goes all fine until scene five. At scene five it doesn't move to camera 12 and then at the end of the scene it doesn't fade out. I'm not sure what the problem is but everything else works fine.

old Re: Scripting Questions

Gradir
User Off Offline

Quote
You probably gave it too much time to fade out? (53 seconds?)
I never got these sequences right

about my problems - I'm desperately trying to add a blur effect on start of each RANDOM map, but without effects. I even tried adding state "fuddle" or "dizzy" to the player, it failed to give the blur. strange.

Also how can I make an event at a specific game time (for example when hour=19) by script?

And is it possible to make the collision radius on units be impassable?

old Re: Scripting Questions

DontKnowToScript
User Off Offline

Quote
@Gradir
for events on hours,this: (requires timer)
on:start {
timer "global",2000,1,"gethour";
}
on:gethour {
if (hour==19){
//do something like find a bag...
find 1;
//message
msg "found a bag";
}
}

old Re: Scripting Questions

Gradir
User Off Offline

Quote
indeed, I don't know how to set the trigger's options from script.

another question from me: how to check the map type (normal, swamp, snowy etc) ?

old Re: Scripting Questions

Flying Lizard
User Off Offline

Quote
@ryandeanrocks
no, there is no way to do that.

@DontKnowToScript
Ah damn it! I should stop trying to help people in the evening or at night

And the command you're talking of is s2 cmd terraintexture I believe?
Anyway, I can't see what that command has to do with your question. Bmpf files in S2 only contain informations for S2 how to use the font images. You can open them with the editor (that already is contained in windows) but you won't be able to get much use out of it.

@Gradir
that actually isn't possible, sry. (Who want's to take a bet on wether I'm wrong again or not? -_-)

old Re: Scripting Questions

NP_Beta
COMMUNITY BANNED Off Offline

Quote
bet flying lizard all
i looked up for, at all, i cant find a answer for the questions too.

old Re: Scripting Questions

Guest

Quote
Gradir has written
oh yeah, it works!
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
on:drop
	{
	$mieso=currentid();
	$miesox=getx("self");
	$miesoz=getz("self");
	if ((count_inrange("state",5,50)+count_inrange("state",4,50))>0)
		{
		timer 0,3000,1,"pieczenie";
		freetimers "self";
		}
	}
on:pieczenie
	{
	create "item",10,($miesox),($miesoz);
	fry;
	free "item",$mieso;
	freevar $mieso, $miesox, $miesoz;
	freetimers "self";
	}
It works fine when you drop one meat near the fire. Too bad there are complications, when dropping more, or even having more than one in backpack (not sure)
maybe I should use global timers

Nevertheless, thanks for help DontKnow


I'm wayyyyy late on this one, but here you go :

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
on:drop {
		local $myid,$myx,$myz;
		$myid=currentid();
		$myx=getx("self");
		$myz=getz("self");
		if ((count_inrange("state",5,50)+count_inrange("state",4,50))>0){
			timer "self",5000,1,"frying";
		}
	}

	on:frying {
		local $myid,$myx,$myz;
		create "item",10,($myx),($myz);
		free "item",$myid;
		freetimers "self";
	}

Most two important things I found out : first, the timer must be assigned to self.
Second, maybe even more important : local variables, but do not free them - main problem with that is that it seems to free all similarly-named variables, whatever the scope. Did'nt find a way to get around that one, I simply do not free them. Memory leak powa.

This works for any number of dropped meat, and does not mess up with inventory.

old Re: Scripting Questions

Guest

Quote
No edit button in guest mode - too bad.

@Darksol - You are missing something pretty important:
1
script=begin

Pleasure.

old Re: Scripting Questions

Gradir
User Off Offline

Quote
Vora, thanks for that!
Still I'm afraid you haven't tested it for good. There are strange tweaks, whose purpose lie in the Standed engine.

For now, I'm using the script I've found in the Czechstension Mod subForum, which I've adjusted for my mod:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
on:drop
	{
  timer 0,15600,1,"fryvar";
	if ((count_inrange("state",5,50)+count_inrange("state",4,50))>0)
		{
		skipevent;
		if($fry==0)
			{
			freestored "unit",1,70,1;
			$id=create("item",70);
			timer "item",$id,15500,1,"fry";
			play "fry.mp3";
			$fry=1;
			}
		else
			{
			msg "I must wait until the first thing is finished",3;
			speech "negative";
			}     
		}
	}
on:fry
	{
	$id=currentid();
	if ((count_inrange("state",5,50,"item",$id)+count_inrange("state",4,50,"item",$id))>0)
		{
		local $x;
		local $z;
		local $id;
		$x=getx("self");
		$z=getz("self");
		$id=create("item",71,$x,$z);
		$fry=0;
		free "self";
		timer "item","$id",8000,1,"burned";
		}
	}
on:collect
	{
	freetimers "self";
	$fry=0;
	}
cheers
To the start Previous 1 255 56 57121 122 Next To the start
Log in to reply Scripts overviewStranded II overviewForums overview