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 249 50 51121 122 Next To the start

old Re: Scripting Questions

Amritsar
User Off Offline

Quote
Two questions

1: Can you tell what texture the player is standing on top of? I know I've asked a bunch of times but it never gets answered -.-

2: How does the animal trap script work? I've been looking at it and I understand (almost) everything, but is there a way to affect how many animals it spawns? Because I really need a similar script that spawns more than one of a certain type of animal so I was looking at doing something like this.

EDIT:
3: Can I make a script (similar to the fish trap script) that spawns an item in a storage like object every day, except that it spawns more than one type of item and multiple of them?

And (warning: Ultra noob question )

What do the $ signs represent as a value? I know they're a variable but what do they vary?!
edited 2×, last 26.09.08 08:02:50 am

old Re: Scripting Questions

wojtek961
User Off Offline

Quote
$ sign is a object state. for example script:

on:use {
     if ($staying=0) {
          $staying=1;
          ai_stay "self";
     }
     elseif ($staying=1) {
          $staying=0
          ai_mode "self","goto","unit" "1";
          ai_center;
     }
}

That script you can use for units. For example native.
That script adds for selected unit two states:
$staying=0 and $staing=1. At start it's going
everywhere, but when you use it, that unit stays
at selected place and it adds state: $staing=1.
So when you use it, selected unit beging going
near you.

It's only one example. It has more applications
________________________________________

And sorry for my bad English. I'm from Poland too...
.

old Re: Scripting Questions

Flying Lizard
User Off Offline

Quote
uh... it would be best to forgett what wojtek said (no offense, but that's just not right)

the $ sign tells S2, that what is written directly after it is the name of a variable. So S2 uses everything with a $ in front of it as a variable.

You can imagine a Variable as a very small text file, with a single line of information written into it. This information can either be an integer (for example 3 or 25), a float (2.456 or 7.12345) or a string ("text" or "stuff", it simply means there's text written into the variable)

Variables are used to store information. In the script wojtek posted the variable in use ($staying) contains an integer.
Wojtek said that the "object state" as he refered to the variable makes the unit stop moving, but that's wrong. Variables don't have any functions beside storing information. The information stored in $staying is just used to figure out if the unit already is forbidden moving or not. The lines with "ai_" in front of them are the ones doing the work.

Amritsar has written
1: Can you tell what texture the player is standing on top of? I know I've asked a bunch of times but it never gets answered -.-

sry, this isn't possible

Amritsar has written
2: How does the animal trap script work? I've been looking at it and I understand (almost) everything, but is there a way to affect how many animals it spawns? Because I really need a similar script that spawns more than one of a certain type of animal so I was looking at doing something like this.

hm, you'd just have to execute the part of the script where animals are spawned multiple times. you should use s2 cmd loop for that.
If you're not able to do this all by yourself you can ask again. But we wont write the script for you, we will just help you understanding how it works.

Amritsar has written
3: Can I make a script (similar to the fish trap script) that spawns an item in a storage like object every day, except that it spawns more than one type of item and multiple of them?

That actually IS what the Bownet script DOES

old Re: Scripting Questions

DontKnowToScript
User Off Offline

Quote
Armistar has written
3: Can I make a script (similar to the fish trap script) that spawns an item in a storage like object every day, except that it spawns more than one type of item and multiple of them?

just use s2 cmd setamount.after the line $id=create ("item",...)put setamount $id,//number you want.

old Re: Scripting Questions

Amritsar
User Off Offline

Quote
Thanks guys, that helped but on the subject of the texture question...

Could I at least use a script to tell how far you are away from the sea? I know there are script to tell how far you are from an object but is there one for how far you are from water?

I'm pretty sure it involves those variables right?

It involves getting the location of the player (X), and the distance of the nearest water and if it's (X is) above a certain amount it doesn't continue the script I think?

I've been trawling through the game files and I've only found stuff that checks the distance of fountains and campfires, so I would really appreciate help with that one.

@DontKnowHowToScript
                         $id=create("item",255,setamount $id//5);

??

It always gives me an error, could you give me a small example instead just so I know the layout?
is it $id=create("Item",255)setamount $id,5?

I need to know where all the brackets and breaks are.

@ Flying Lizard
I thought the bownet spawned one lot of one type of object per day? That's all it's ever done for me (the exception being if you let it alone for a while it adds up) when I looked at the script (my minute knowlege of scripting not affecting =p) it didn't appear to have a multiple amount?
edited 1×, last 27.09.08 03:24:21 am

old Re: Scripting Questions

Amritsar
User Off Offline

Quote
}elseif($r==2){
                         $id=create("item",255)setamount $id//5);

The random choice thing works great but when it gets to the spawning a set amount of something it comes up saying stuff like too many operators and that it was expecting a " ' " somewhere in there...

I just need an example of the script or something similar and I can work out how it works.

EDIT: And I checked the Stranded 2 Website info on the setamount command, it has absolutely nothing about it except for that it works with items?

old Re: Scripting Questions

DC
Admin Off Offline

Quote
EVERY single command has to have a ; at its end. moreover: why are there two slashes (//) before 5? // start a COMMENT! comments are not part of a script. so never ever use // inside a script. just use it at the very end of a line AFTER all commands to add a comment.

that's how you have to do it:
1
$id=create("item",255); setamount $id,5;

old Re: Scripting Questions

DontKnowToScript
User Off Offline

Quote
@Armistar
i dont want you to make // inside,i just wanted to explain what that parameter does.NEVER EVER write // inside a script.

old Re: Scripting Questions

jockmo42
User Off Offline

Quote
I'm trying to add a lot of bug items as bait, but in-game, it doesn't use them. No errors or anything, it simply doesn't work.

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
script=start
	on:attack2 {
		jade 2.5;
		event "iskill_fish","global";
	}
	on:fish_failure {
		$tmp=current_id();
		if (parent_class($tmp)==2){
			if (parent_id($tmp)==1){
				speech "negative";
				msg "I cannot fish here!",3;
			}
		}
	}
	on:fish_success {
		$tmp=current_id();
		if (parent_class($tmp)==2){
			if (parent_id($tmp)==1){
				//Bait?
			if 

((playergotitem(98)+playergotitem(119)+playergotitem(122)+
playergotitem(125)+playergotitem(124)+pla

yergotitem(127))==0){
					$tmp2=skillvalue("fish");
					if ($tmp2>=500){
						find 89,random(1,2);
						speech "positive";
					}elseif($tmp2>=200){
						$tmp3=random(1,6);
						if ($tmp3==1){
							find 109;
							speech "positive";
						}elseif($tmp3==2){
							find 102;
							speech "positive";
						}elseif($tmp3==3){
							find 103;
							speech "positive";
						}else{
							find 89;
							speech "positive";
						}
					}elseif($tmp2>=100){
						$tmp3=random(1,3);
						if ($tmp3==1){
							find 109;
							speech "positive";
						}elseif($tmp3==2){
							find 102;
							speech "positive";
						}elseif($tmp3==3){
							find 103;
							speech "positive";
						}				
					}elseif($tmp2>=50){
						$tmp3=random(1,5);
						if ($tmp3==1){
							find 109;
							speech "positive";
						}elseif($tmp3==2){
							find 102;
							speech "positive";
						}elseif($tmp3==3){
							find 103;
							speech "positive";
						}
					}elseif($tmp2>=25){
						$tmp3=random(1,7);
						if ($tmp3==1){
							find 109;
							speech "positive";
						}elseif($tmp3==2){
							find 102;
							speech "positive";
						}elseif($tmp3==3){
							find 103;
							speech "positive";
						}
					}
				//Use a Bait
				}else{
					//Worm
					if (playergotitem(119)>0){
						freestored "unit",1,119,1;
						msg "Used worm as bait!",1;
					//Insectparts
					}elseif (playergotitem(98)>0){
						freestored "unit",1,98,1;
						msg "Used insect parts as bait!",1;
					//Spider
					}elseif (playergotitem(122)>0){
						freestored "unit",1,122,1;
						msg "Used spider as bait!",1;
					//Fly
					}elseif (playergotitem(125)>0){
						freestored "unit",1,125,1;
						msg "Used fly as bait!",1;
					//Dragonfly
					}elseif (playergotitem(124)>0){
						freestored "unit",1,124,1;
						msg "Used dragonfly as bait!",1;
					//Grasshopper
					}elseif (playergotitem(127)>0){
						freestored "unit",1,127,1;
						msg "Used grasshopper as bait!",1;
					}

					//Get Fish?
					$tmp2=skillvalue("fish");
					if ($tmp2>=500){
						find 89,random(1,3);
					}elseif($tmp2>=200){
						find 89,1;
						speech "positive";
					}elseif($tmp2>=50){
						$tmp3=random(1,100);
						if ($tmp3<=70){
							find 89;
							speech "positive";
						}
					}elseif($tmp2>=25){
						$tmp3=random(1,100);
						if ($tmp3<=50){
							find 89;
							speech "positive";
						}						
					}else{
						$tmp3=random(1,100);
						if ($tmp3<=30){
							find 89;
							speech "positive";
						}
					}
				}
			}
		}
	}
script=end
healthchange=0

I've added all the items to the bait and the playergotitem list, but it looks messy. What did I do wrong and why am I not getting any errors?
edited 1×, last 26.09.08 11:26:46 pm

old Re: Scripting Questions

Amritsar
User Off Offline

Quote
I just tested it now, it doesn't say anything in the debugger and just refuses to use the stuff as bait...

I had the same problem ages ago when I wanted to add beachworms.

I just noticed (I've been typing this response for about 15 mins due to all the testing) that if you use a normal worm with that script still there it gives an error about mismatched brackets?

@DC - Thanks!

old Re: Scripting Questions

Amritsar
User Off Offline

Quote
The script I tested that problem with was exactly what Jockmo has and it doesn't appear to have an extra { or { anywhere?

Can you test it with a normal worm and see if you have the same results Jockmo? Since I used your stuff to test it for a problem it should be the same so that might be what's causing this.

old Re: Scripting Questions

DontKnowToScript
User Off Offline

Quote
hmmmmm... strange.
maybe try to make }else{ on the baits.but this will apply only to cases where you dosent have worms or insect parts but you have somehting else you want.

old Re: Scripting Questions

Amritsar
User Off Offline

Quote
So it would be }else{ in between all the baits?

If that is the solution then how did the original two baits work without it?

And should you put it before or after the //*Name*?

Sorry for all these newbie questions but I really wanna learn how to do this well and I can't use the official Stranded script info because it's A: In German or B: Non-existent

Edit: I just noticed, doesn't the elseif in between all the items already exist and work?

//Worm
if (playergotitem(119)>0){
freestored "unit",1,119,1;
msg "Used worm as bait!",1;
//Insectparts
}elseif{(playergotitem(98)>0){
freestored "unit",1,98,1;
msg "Used insect parts as bait!",1;[b]

old Re: Scripting Questions

DontKnowToScript
User Off Offline

Quote
hmmmm..i think you shall:
1
2
3
4
5
//Spider,or somehting you want
elseif (playergotitem(spider ID)>0){
freestored "unit",1,spider ID,1;
msg "used spider as bait!",1;
//next thing...
of course,do not write the // and "spider id" but instead of spider id write the id of the item you wan tto use as bait.

old Re: Scripting Questions

Amritsar
User Off Offline

Quote
So

All that stuff at the beggining then the actual bait part:

//Beachworm(whatever)
}elseif (playergotitem(250)>0){
freestored "unit",1,250,1;
msg "Used bait",1;
//Spider(whatever)
}elseif (playergotitem(251)>0{
fteestored "unit",1,251,1;
msg "Used Bait",1;
}

Should theoretically work? Assumingg this was placed beneath the insectparts in the script and the correct things were added to ((playergotitem(251)+playergotitem(252))==0){

Out of curiosity what does the ==0{ do?

The { denotes the end of the script and the double == mean that something is equal to but what does the 0 mean?

old Re: Scripting Questions

DontKnowToScript
User Off Offline

Quote
the 0 means you have equally amount of 0 items in inventory.if its not correct,the script will skip this.so if there is 0 you MUST have 0 items of that kind in inventory.

old Re: Scripting Questions

jockmo42
User Off Offline

Quote
Ack, so confusing. For anyone that wants to know, yes, worms and insect parts work fine for me, but I haven't used them in debug mode. It may still be complaining about brackets.

I wonder if DC knows what's up.

EDIT: Woah! I just tested again and it worked.

Still confused, but whatever.
To the start Previous 1 249 50 51121 122 Next To the start
Log in to reply Scripts overviewStranded II overviewForums overview