It should be
1
2
3
4
5
6
7
2
3
4
5
6
7
on:hit { 	if(getplayerweapon()==id of the knife){ 		if(random(1,3)==1){ 			find idleaf,random(1,2); 			} 		} 	}
on:hit { 	if(getplayerweapon()==id of the knife){ 		if(random(1,3)==1){ 			find idleaf,random(1,2); 			} 		} 	}
script=start on:attack2{ $sakcur+=1; if($sakcur>=9){ $sakcur=0; } } on:attack1{ if($sakcur==0){ msg "Closed"; } elseif($sakcur==1){ msg "Knife"; } elseif($sakcur==2){ msg "Saw Blade"; } 	 elseif($sakcur==3){ msg "Magnifying Glass"; } 	 elseif($sakcur==4){ msg "Tweezers"; } 	 elseif($sakcur==5){ msg "Nail File"; } 	 elseif($sakcur==6){ msg "Scissors"; } 	 elseif($sakcur==7){ msg ""; } 	 elseif($sakcur==8){ msg ""; } } script=end
on:attack1{ 		$class=impact_class(); 		$id=impact_id(); 		if($sakcur==1){ 			if(compare_material($class,$id,"wood")==1){ 				if(random(3)==1){ 					find 15,random(1,3); 				} 			} 		} 	}
$wep=currentid(); 	on:ai_attack{ 		if(getplayerweapon()==$wep){ 			$hit+=1; 			msg "hit $hit times"; 		} 	} 	on:inhand{ 		if($hit<=20){ 			if(getplayerweapon()==$wep){ 				heal "unit",1,2000; 			} 		}elseif($hit>20){ 			free "self",1; 			msg "The shield broke!",3; 			$hit=0; 		} 	}
on:ai_attack { 	echo "trigger ai_attack event"; 	if(getplayerweapon()==$wep){ 		$hit+=1; 		msg "hit $hit times"; 	} }
$wep=currentid(); 	on:ai_attack{ 		if(getplayerweapon()==$wep){ 			$hit+=1; 			msg "hit $hit times"; 		} 	} 	on:inhand{ 		if($hit<=20){ 			if(getplayerweapon()==$wep){ 				heal "unit",1,2000; 			} 		}elseif($hit>20){ 			free "self",1; 			msg "The shield broke!",3; 			$hit=0; 		} 	}
on:attack1{ 		$class=impact_class(); 		$id=impact_id(); 		if($sakcur==1){ 			if(compare_material($class,$id,"wood")==1){ 				if(random(3)==1){ 					find 15,random(1,3); 				} 			} 		} 	}
spawn=item-type [, time to grow in days][,X-radius][,y-radius][,y-offset][,objects][,number per object]