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 281 82 83121 122 Next To the start

old Re: Scripting Questions

bezmolvie
User Off Offline

Quote
1. on:use{ effect here}
2. on:use{ $x++; if ($x==PUTVALUEHERE){
free "self",1;}
3. use find ITEMTYPE;
4. You can use $x=random (1,100); and then if($x==1){find ITEMTYPE;} and list every posibility. Put the number of different items for the 100.
5. on:collect{ if (count_stored ("unit",1,ITEMTYPE)>MAXIMUMOFITEM){unstore ITEMID,1}
6.Look in Game.inf for examples.

old Re: Scripting Questions

Qtw
User Off Offline

Quote
thanks but a few problems bloodshot...
1,can you give an example for this one? i have no clue what to put there as effect.
3, i dont understand this at all...mind giving an example here too?
6, i tried that advice long ago...noone told me how to do it so i managed to screw it up...mind giving me the code for this one as well? thanks in advance.

old Re: Scripting Questions

FalseID
User Off Offline

Quote
Bloodshot has written
Yeah, it should, because
1) It is a local variable, only accesible by THAT wine bottle
2) It should dissapeer on the second day, and lose all local vars.


It doesn't disappear and wine isn't stored anywhere as well. Something is still wrong with my 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
script=start 
	on:create {
	local $pid,$pclass,$age;
	$pid=parent_id();
	$pclass=parent_class();
	$age=1;
	}
	on:use {
	msg "Aged for $age days",3;
	}
	on:eat {
	process "drinking",2000;
	drink 10,5,30,0;
	}
	on:changeday {
	if ($age>=0){
	$age++;
	}elseif ($age>=2){
	freestored ("$pclass",$pid,39,1);
	store (228,"$pclass",$pid);
	}
freevar $age,$pid,$pclass; 
} 
script=end

old Re: Scripting Questions

bezmolvie
User Off Offline

Quote
3. find 1; will make you find a small crystal, the first item.
6.For the planting:
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
on:useground {
		local $x,$y,$z,$id,$item;
		$x=use_x();
		$y=use_y();
		$z=use_z();
		$item=getplayerweapon();
		
		if (count_stored("unit",1,$item)>0){
if ($item==42){
				if ($y>0){
					if (freespace($x,$y,$z,20,1,0,0,0)){
						freestored "unit",1,42,1;
						$id=create("object",121,$x,$z);
						event "plant","object",$id;
						if (skillvalue("plant")>=400){
							process "planting grain",500;
						}else{
							process "planting grain",2000;
						}
						play "dig.wav";
						play "mat_leaf1.wav";
						event "iskill_plant","global";
					}else{
						speech "negative";
						msg "Here is not enough space!",3;
					}
				}else{
					speech "negative";
					msg "Grain does not grow in water!",3;
				}
on:useground means when the player uses the ground. The vars $x,$y,$z,$id and $item are localized. $x,$y,& $z check where the player used the ground. $item=getplayerweapon(); checks and sets $item to the currently equiped item. The next if checks to make sure the player actually has some of that item. The next if checks what that item is, and if it's 42, or grain, it executes the script inside the { & } s. It makes sure the player isn't planting under water, and tells you "Grain does not grow in water!" if it is. The next part is important
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
if (freespace($x,$y,$z,20,1,0,0,0)){ 
                              freestored "unit",1,42,1; 
                              $id=create("object",121,$x,$z); 
                              event "plant","object",$id; 
                              if (skillvalue("plant")>=400){ 
                                   process "planting grain",500; 
                              }else{ 
                                   process "planting grain",2000; 
                              } 
                              play "dig.wav"; 
                              play "mat_leaf1.wav"; 
                              event "iskill_plant","global"; 
                         }else{ 
                              speech "negative"; 
                              msg "Here is not enough space!",3; 
                         }
It first checks to make sure there is enough space around where the player used the ground. If there is, it removes one grain item from the players INV with freestored. $id=create...; creates the grain and sets $id to its id. Then it sends out the event "plant" Only to the grain that was just planted, using $id to send it. Then it gives a process and so on. Copy this script and tweak it from grain to whatever you want to plant. Make sure you put growtime=Whatever to set the number of days it takes to grow. Hope I helped .

old Re: Scripting Questions

UnIdEnTiFiEd
User Off Offline

Quote
Is this really scripting?? well anyway I was Moding and i had a lot to do.i finished it but now it says "INVALID OBJECT ID FOR BUILDING (0)" what do i do???

Whats it mean?? is it the ID? because ID 0 is not possible!
Please help!!!

old Re: Scripting Questions

filfer
User Off Offline

Quote
UnIdEnTiFiEd has written
Is this really scripting?? well anyway I was Moding and i had a lot to do.i finished it but now it says "INVALID OBJECT ID FOR BUILDING (0)" what do i do???

Whats it mean?? is it the ID? because ID 0 is not possible!
Please help!!!

it probably doesn't mean ID 0, that 0 is there for something else. I think i had gotton that error whenever i overlap two or----- more of same object onto one id or when i register an object onto an id that is not usable(less than 0 or id above 9999 for buildings)

old Re: Scripting Questions

UnIdEnTiFiEd
User Off Offline

Quote
ive got another problem

How do i make it that if i go near something it will die?

is it on:trigger? if it is, what is the code for it?

old Re: Scripting Questions

bezmolvie
User Off Offline

Quote
1
2
3
if (count_inrange("unit",1,30,"self")>=1){
kill "self";
}
Put this in the thing you want to die. change the 30, which is the radius, to a bigger or smaller radius to determine how close you need to be.

old closed Re: Scripting Questions

FalseID
User Off Offline

Quote
FalseID has written
It doesn't disappear and wine isn't stored anywhere as well. Something is still wrong with my code.
Code:
script=start
on:create {
local $pid,$pclass,$age;
$pid=parent_id();
$pclass=parent_class();
$age=1;
}
on:use {
msg "Aged for $age days",3;
}
on:eat {
process "drinking",2000;
drink 10,5,30,0;
}
on:changeday {
if ($age>=0){
$age++;
}elseif ($age>=2){
freestored ("$pclass",$pid,39,1);
store (228,"$pclass",$pid);
}
freevar $age,$pid,$pclass;
}
script=end
Bump

Admin/mod comment

bumping is forbidden. read the rules first /TheKilledDeath

old Re: Scripting Questions

UnIdEnTiFiEd
User Off Offline

Quote
Here is my kamakaze script, i didnt use the "kill self" thing because it didnt work.


### Native
id=80
name=kamakaze
group=human
model=gfx\native.b3d
icon=gfx\native.bmp
scale=0.9
colxr=9
colyr=20
behaviour=raptor
speed=1.0
eyes=10
health=9
damage=1
range=150
attackrange=10
maxweight=25000
ani_move=2,3,0.10
ani_attack=23,25,0.10
ani_die=4,7,0.15
ani_idle1=9,13,0.09
ani_idle2=14,21,0.08
ani_idle3=21,23,0.12
sfx=native
script=start
     on:kill {
          explosion getx("self"),gety("self"),getz("self"),50,80;
}
     on:start {
          addstate "self",1;
          statesize "self",100,100;
     }
script=end

but it will blow up after a couple of seconds the explosion will do 80 damage

old Re: Scripting Questions

Spicy Night Owl
User Off Offline

Quote
Something is wrong with my script for the random island generation. Here is 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
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
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
################### Random Profile: Endless Game

id=1
name=Endless Game - Easy


################### Scripts

script=start
	on:preload {
		// Set Startpoint in Sea
		$size=mapsize();
		$size=$size/3;
		$id=create("info",1,$size,$size);
		setpos "info",$id,"self",2,"self";
		// Random Startscriptstuff
		extendscript 0,0,"sys/scripts/random_start.s2s";
	}

	on:start {		
		// Start Items
		$id=create("item",44,0,0,15);
		store $id,"unit",1;
		$id=create("item",66,0,0,20);
		store $id,"unit",1;
		$id=create("item",38,0,0,10);
		store $id,"unit",1;
		$id=create("item",47,0,0,10);
		store $id,"unit",1;
		$id=create("item",118);
		store $id,"unit",1;
		
		// Settings
		$s2g_firesuccess=60;
		$s2g_plagues=100000;

		// Forced Creation of Important Stuff
		if (count("object",75)==0){ randomcreate "object",75,1,500; } 	// Watersource
		if (count("object",121)==0){ randomcreate "object",121,1,500; } // Grain
		if (count("object",47)==0){ randomcreate "object",47,1,500; } 	// Cotton
		if (count("object",70)==0){ randomcreate "object",70,1,500; } 	// Metal
		
		// Cotton Spawn
		loop ("objects",47){
			$id=loop_id();
			$x=getx("object",$id);
			$z=getz("object",$id);
			$id=create("info",45,$x,$z);
			info_spawncontrol $id,50,"object",47,1,3,1;
			starttrigger $id;
			exit;
		}

	}

	on:stdiary {
		// Start Diary
		add "You are stranded.";
		add "Try to survive - besides this there is no special aim.";
		add "Have fun!";
		add "";
		add "!4Difficulty: Easy";
		add "A lot of resources and no dangerous animals.";
		add "You have a lot of supplies at the start.";
		diary "Stranded";
	}

	on:changeday {
		$mapc=mapsize();
		$mapc=($c/512);
		// Spawn Birds
		if (count("unit",25)<$mapc){ randomcreate "unit",25; }
		// Spawn Butterflies
		if (count("unit",6)<$mapc){ randomcreate "unit",6; }
		if (count("unit",7)<$mapc){ randomcreate "unit",7; }		
		freevar $mapc;
	}
script=end


################### Objects

### Palms
range=15,255
ratio=40
objects=1
ratio=30
objects=2,3,4
ratio=10
objects=5,7
ratio=5
objects=6,213
ratio=10
objects=8,9

### Trees
range=50,270
ratio=10
objects=10,12,13,14,16,
ratio=7
objects=15,229,230,231
ratio=2
objects=11,17

### Bushes
range=30,240
ratio=30
objects=33
range=50,250
ratio=10
objects=31,32,33,36,37,38,185,124
ratio=3
objects=34,39,40,41,42
ratio=6
objects=35,42,45,46,47
range=-10,10
ratio=5
objects=43
range=-500,-50
ratio=5
objects=48

### Stones
range=-5,500
ratio=20
objects=63
ratio=15
objects=65
ratio=5
objects=64,67,68,69,126,227,226,228
ratio=7
objects=70,73,74,75
ratio=1
objects=71,72
ratio=15
objects=60,61,62
ratio=7
objects=66

### Flowers
range=60,200
ratio=20
objects=100,101,102,103,105,106,107,108,109

### Stuff
range=50,100
ratio=5
objects=120,130,131,134,135,232,233
ratio=15
objects=121

### Reproduction
range=60,200
ratio=10
objects=197,198,202,204
range=-100000,-70
ratio=10
objects=210

################### Units

### Land
range=-10,40
ratio=15
units=3,10
range=10,200
ratio=20
units=6,7,16,17,18,20,26,46,47,49,50,52,53
ratio=10
range=50,150
units=19
ratio=5
units=15

### Sky
range=-100000,100000
ratio=10
units=25
ratio=5
units=36

### Sea
range=-100000,-70
ratio=20
units=4,11,12

################### Items

### Stuff
range=60,200
ratio=6
items=7,15,21,22,23,24,25,26
ratio=4
items=31,32,33,16,17,19,20
ratio=2
items=34,35,18
range=0,30
ratio=10
items=102
ratio=5
items=103

old Re: Scripting Questions

amstel bier9
User Off Offline

Quote
Bloodshot has written
alteritem NEWITEMTYPE;
Under NewItemType put the ID of the new item.


and how i do that for an object?

old Re: Scripting Questions

bezmolvie
User Off Offline

Quote
Bit harder.

1
2
3
4
5
6
local $x,$z;
$x=getx ("self");
$z=getz ("self");
create "object" TYPE,$x,$z;
freevar $x,$z;
free "self";
If you just want to do that for a model use the s2 cmd model command.

Edit: Wow. Just found out there was an s2 cmd alterobject command. Lol
edited 1×, last 25.12.09 08:59:08 pm

old Re: Scripting Questions

Spicy Night Owl
User Off Offline

Quote
@Bloodshot
yea I did that but the original wasnt destroyed

EDIT: Here is 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
### Leatherman
id=125
name=Leatherman
group=tool
icon=gfx\leatherman.bmp
model=gfx\ironbar.b3d
scale=2
mat=metal
weight=10
rate=1000
damage=5
info=my Leatherman Fuse
healthchange=0
script=start

	on:attack2 { 

                alteritem $Leathermans_qty,125,$Leathermans_qty,126;
		alteritem  1,126;
 
		msg "Knife Mode",4;

script=end
To the start Previous 1 281 82 83121 122 Next To the start
Log in to reply Scripts overviewStranded II overviewForums overview