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 262 63 64121 122 Next To the start

old Re: Scripting Questions

jockmo42
User Off Offline

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

old Re: Scripting Questions

Tau
User Off Offline

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

old Re: Scripting Questions

jockmo42
User Off Offline

Quote
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;
     }
edited 5×, last 14.04.09 11:05:54 pm

old Re: Scripting Questions

The Second
User Off Offline

Quote
The Second has written
Is it possible to make: Lions hunt (and kill) other animals like kiwis??


Can anybody answer me?
edited 1×, last 16.04.09 08:40:25 pm

old Re: Scripting Questions

jockmo42
User Off Offline

Quote
Could someone define "stable" for me?

          //$s2g_stablebuildings=1;     //are buildings stable?
edited 1×, last 17.04.09 11:37:22 pm

old Re: Scripting Questions

Tau
User Off Offline

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

old Re: Scripting Questions

jockmo42
User Off Offline

Quote
The Second has written
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.

old Re: Scripting Questions

The Second
User Off Offline

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

old Re: Scripting Questions

jockmo42
User Off Offline

Quote
The Second has written
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.
edited 3×, last 23.04.09 01:51:03 am

old Re: Scripting Questions

jockmo42
User Off Offline

Quote
The Second has written
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?

old Re: Scripting Questions

jockmo42
User Off Offline

Quote
The Second has written
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.

old Re: Scripting Questions

The Second
User Off Offline

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

old Re: Scripting Questions

HudaJan
Super User Off Offline

Quote
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 ...:(

old Re: Scripting Questions

Tau
User Off Offline

Quote
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.
To the start Previous 1 262 63 64121 122 Next To the start
Log in to reply Scripts overviewStranded II overviewForums overview