Forum

> > Stranded II > Scripts > A Chicken/Egg Query
Forums overviewStranded II overview Scripts overviewLog in to reply

English A Chicken/Egg Query

5 replies
To the start Previous 1 Next To the start

old A Chicken/Egg Query

aimeewilbury
User Off Offline

Quote
I created a chicken unit which spawns eggs (item 123, for reference). But when using this script, the sound plays but no eggs are dropped:
1
2
3
4
5
6
7
8
9
10
//Get Eggs on Use
	on:use {
		if (count_stored("self")>0){
			play "RoosterCrow.wav";
			unstore 123,1;
		}else{
			msg "It has no eggs!",3;
			speech "negative";
		}
	}

If I use "exchange "self",0;" instead of unstore you can see the eggs. Any suggestions?

old Re: A Chicken/Egg Query

HudaJan
Super User Off Offline

Quote
And you want the chicken to drop eggs on the ground or you want it to store eggs it it's "inventory" ?

old Re: A Chicken/Egg Query

HudaJan
Super User Off Offline

Quote
I can see the problem now. The command "unstore" takes the parameter Item-ID and not Type-ID of the item.
So the easiest way shall be
1
2
3
4
5
6
7
8
9
10
11
12
on:use {
	if(count_stored("self",123)>0){
		local $x,$z;
		$x=getx("self");
		$z=getz("self");
		create "item",123,$x,$z;
		freestored "self",123,1;
	}else{
		msg "It has no eggs!",3;
		speech "negative";
	}
}
So it basically creates new egg and removes one egg from the chicken's inventory.
Let me know how did it work for you

old Re: A Chicken/Egg Query

Feuer der veraenderung
User Off Offline

Quote
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
on:start {
local $r,$r2,$z,$x,$count;
}
     on:use {
           if (count_stored("self")>0){
                play "RoosterCrow.wav";
                unstore 123,1;
                $x=getx("self");
                $z=getz("self");
                $count=count_stored("self",$eggid);
                $r=random(-20,20);
                $r2=random(-20,20);			  
create "item",123,$x+$r,$z+$r2,$count;
           }else{
                msg "It has no eggs!",3;
                speech "negative";
           }
      }
I had combined the extent script from S2ext with yours. I hope it works.
To the start Previous 1 Next To the start
Log in to reply Scripts overviewStranded II overviewForums overview