Forum

> > Stranded II > Scripts > Trying to brush up on script.
Forums overviewStranded II overview Scripts overviewLog in to reply

English Trying to brush up on script.

4 replies
To the start Previous 1 Next To the start

old Trying to brush up on script.

aimeewilbury
User Off Offline

Quote
I finally decided to work on my personal mod again after moving. Anyways I managed to create a cow that drops a bucket of milk. Here's the current script:

(ID 144 is the milk-bucket)
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
script=start
//Spawn 2 Milk at Start
	on:start {
		local $id;
		$id=create("item",144,0,0,2);
		store $id,"self";
		freevar $id;
	}
//Add 1 Milk per Night
	on:changeday {
		if (count_stored("self",144)<5){
			local $id;
			$id=create("item",144,0,0,1);
			store $id,"self";
			freevar $id;
		}
	}
//Get Eggs on Use
on:use {
     if(count_stored("self",144)>0){
          local $x,$z;
          $x=getx("self");
          $z=getz("self");
          create "item",144,$x,$z;
          freestored "self",144,1;
		  play "RoosterCrow.wav"; [Yes I know about this. I copied it from the script for a chicken to lay an egg & need to fix this.]
     }else{
          msg "It has no milk!",3;
          speech "negative";
     }
}
//Kill
	on:kill {
		event "iskill_hunt","global";
	}
script=end

Now, I also have an Empty Bucket item. That's 141. I cannot remember for the life of me how to get it so the cow will only drop if the user has a bucket (which is then freed from the user). Any suggestions? There probably needs to be an if statement but my memory fails me.

old Re: Trying to brush up on script.

aimeewilbury
User Off Offline

Quote
I got it thank you.

EDIT: I put a timer on the milking. However the cow tends to walk away during it. I think s2 cmd ai_stay may work but Im not sure where exactly it goes:

(oh I also fixed the sound effects )

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
//Get Milk on Use
on:use {
	if(playergotitem(141)>0) {
		if(count_stored("self",144)>0){
          local $x,$z;
          $x=getx("self");
          $z=getz("self");
		  process "Milking",5000;
          create "item",144,$x,$z;
          freestored "self",144,1;
		  freestored "unit",1,141,1;
		  play "cow_idle1.wav";
		  play "fountain.wav";
     }else{
          msg "It has no milk!",3;
          speech "negative";
		}
	}else{
		msg "I have no buckets!",3;
		          speech "negative";
		}
}

Also I was trying to get rid of all the milk when the cow is killed. However the milk still appeared in the storage:
1
2
3
4
5
//Kill
	on:kill {
		event "iskill_hunt","global";
		freestored "self",141;
	}

I'm probably missing something simpel here
edited 2×, last 04.02.12 10:38:26 pm

old Re: Trying to brush up on script.

Hurri04
Super User Off Offline

Quote
just put the lines
1
2
ai_stay "self", 1;
timer "self", 6000, 1, "cow_move";
behind the second if command.

then create a new event
1
2
3
on:cow_move {
	ai_stay "self", 0;
}

I think when removing all the milk from the cow upon death, you need to use the number 144 instead of 141.


also I'd suggest to replace the lines with the local command, the x and z variables and the create command with the line
1
find 144;
To the start Previous 1 Next To the start
Log in to reply Scripts overviewStranded II overviewForums overview