Forum

> > Stranded II > Scripts > Scripting Questions
ForenübersichtStranded II-Übersicht Scripts-ÜbersichtEinloggen, um zu antworten

Englisch Scripting Questions

2.429 Antworten
Seite
Zum Anfang Vorherige 1 262 63 64121 122 Nächste Zum Anfang

alt Re: Scripting Questions

jockmo42
User Off Offline

Zitieren
Okay, back and modding again, but I've got problems getting back into the flow of things.

I've got a script on the kiwi nest that drops an egg when it's killed. Problem is, it also spawns a kiwi. This is what I've got. First spawns eggs over time around it, second is the default kiwi spawning script, third is my kill script which makes an egg when the nest is destroyed.

Anybody know what's wrong?

script=start
     on:changeday {
          //Spawn Eggs
          if (random(2)==1){
               if (count_inrange("item",143,25,"self")<$max){
                    local $xp,$zp;
                    $xp=getx("self");
                    $zp=getz("self");
                    $xp+=random(-15,15);
                    $zp+=random(-15,15);
                    create "item",143,$xp,$zp;
                    freevar $xp,$zp;
                    }
               }
          }
          loop("count",$count) {
               if (count_inrange("unit",26,$radius,"self")<$max){
                    create "unit",26,getx("self"),getz("self");
               }
          }
     on:kill {
          create "item",143,getx("self"),getz("self");
          corona getx("self"),getz("self");
     }
script=end

Thanks for the help.

alt Re: Scripting Questions

Tau
User Off Offline

Zitieren
Brackets are wrong I think.
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
script=start
     on:changeday {
          //Spawn Eggs
          if (random(2)==1){
               if (count_inrange("item",143,25,"self")<$max){
                    local $xp,$zp;
                    $xp=getx("self");
                    $zp=getz("self");
                    $xp+=random(-15,15);
                    $zp+=random(-15,15);
                    create "item",143,$xp,$zp;
                    freevar $xp,$zp;
                    }
               }
          loop("count",$count) {
               if (count_inrange("unit",26,$radius,"self")<$max){
                    create "unit",26,getx("self"),getz("self");
               }
          }
     }
     on:kill {
          create "item",143,getx("self"),getz("self");
          corona getx("self"),getz("self");
     }
script=end
I think this should work.

alt Re: Scripting Questions

jockmo42
User Off Offline

Zitieren
Would there be a way to change the buildsite object that a certain building uses? I suppose I could just up the scale of all the buildsites, but that's a tad extreme. I need to increase the scale of the buildsite so it can be worked on through the item it's being built on.

The problem is that the item you're building on is so large, it engulfs the build site and you can't see it to build.

And thanks a lot, nmG, but I tried that before. No worries though, problem half-solved itself.

I'm also trying to get the local id of an object and move it up 330 units right after it's finished being built.

I've completely butchered it.

     on:build_finish {
          event "treehousebuild",0,0;
          local $y,$ty;
          $y=gety("object",localid);
          $ty=gety("self");
          if ($y<($ty+150)){
               setpos "unit",1, "self", ($ty+330), "self";
          }
          freevar $y,$ty;
     }
5× editiert, zuletzt 14.04.09 23:05:54

alt Re: Scripting Questions

The Second
User Off Offline

Zitieren
The Second hat geschrieben
Is it possible to make: Lions hunt (and kill) other animals like kiwis??


Can anybody answer me?
1× editiert, zuletzt 16.04.09 20:40:25

alt Re: Scripting Questions

jockmo42
User Off Offline

Zitieren
Could someone define "stable" for me?

          //$s2g_stablebuildings=1;     //are buildings stable?
1× editiert, zuletzt 17.04.09 23:37:22

alt Re: Scripting Questions

Tau
User Off Offline

Zitieren
1
2
3
on:shakeoff{
skipevent;
}
To be included via editor script, addscript or def_extend.

alt Re: Scripting Questions

jockmo42
User Off Offline

Zitieren
The Second hat geschrieben
Thanks!:)

And new guestion:
How can I make a new plantable object?


I'd look at one of the base plant scripts, like grain, and see what you can do by borrowing from there, and modifying as needed.

alt Re: Scripting Questions

The Second
User Off Offline

Zitieren
I chanced them like this:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
//Sunflower
			if ($item==254){
				if ($y>0){
					if (freespace($x,$y,$z,20,1,0,0,0)){
						freestored "unit",1,254,1;
						$id=create("object",226,$x,$z);
						event "plant","object",$id;
						if (skillvalue("plant")>=400){
							process "planting sunflower",1000;
						}else{
							process "planting sunflower",2000;
						}
						play "dig.wav";
						play "mat_leaf1.wav";
						event "iskill_plant","global";
What is wrong?

alt Re: Scripting Questions

jockmo42
User Off Offline

Zitieren
The Second hat geschrieben
I chanced them like this:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
//Sunflower
			if ($item==254){
				if ($y>0){
					if (freespace($x,$y,$z,20,1,0,0,0)){
						freestored "unit",1,254,1;
						$id=create("object",226,$x,$z);
						event "plant","object",$id;
						if (skillvalue("plant")>=400){
							process "planting sunflower",1000;
						}else{
							process "planting sunflower",2000;
						}
						play "dig.wav";
						play "mat_leaf1.wav";
						event "iskill_plant","global";
What is wrong?


I really couldn't tell you at the moment. I don't know what your objects are or any of their properties, I'm not even all that familiar with the planting scripts. Sorry.

Also, could someone tell me how a defense tower knows when a creature is in its range? I see nothing in the object info about it and I'd like to be able to have certain conditions happen only when it's actively shooting something.
3× editiert, zuletzt 23.04.09 01:51:03

alt Re: Scripting Questions

jockmo42
User Off Offline

Zitieren
The Second hat geschrieben
My "item" what I want to plant is id 254, and object id is 226.


And what kind of error message are you getting, if any?

alt Re: Scripting Questions

jockmo42
User Off Offline

Zitieren
The Second hat geschrieben
When I try to plant that item, nothing happens.


Look in your game.inf, there should be a section for planting. Try adding an entry for your plant there.

alt Re: Scripting Questions

The Second
User Off Offline

Zitieren
Just that I did.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
//Sunflower 
               if ($item==254){ 
                    if ($y>0){ 
                         if (freespace($x,$y,$z,20,1,0,0,0)){ 
                              freestored "unit",1,254,1; 
                              $id=create("object",226,$x,$z); 
                              event "plant","object",$id; 
                              if (skillvalue("plant")>=400){ 
                                   process "planting sunflower",1000; 
                              }else{ 
                                   process "planting sunflower",2000; 
                              } 
                              play "dig.wav"; 
                              play "mat_leaf1.wav"; 
                              event "iskill_plant","global";

That is the game.inf.

alt Re: Scripting Questions

HudaJan
Super User Off Offline

Zitieren
Uhm.. I guess it's not possible, but if anyone knows the command for square root return, I'd be very grateful
(square root is this IMG:https://upload.wikimedia.org/math/9/f/b/9fb14005ad88018667acf29aa39cb5ff.png
)
But I think square root extraction is not possible in S2s ...:(

alt Re: Scripting Questions

Tau
User Off Offline

Zitieren
root extraction isn't directly possible with s2script, but it should be possible to use Heron's method a few times, then you should get a good approach for the square root.
Zum Anfang Vorherige 1 262 63 64121 122 Nächste Zum Anfang
Einloggen, um zu antworten Scripts-ÜbersichtStranded II-ÜbersichtForenübersicht