mirror of
				https://codeberg.org/tenplus1/mobs_redo.git
				synced 2025-10-30 23:25:36 +01:00 
			
		
		
		
	simplify string/table searches
This commit is contained in:
		
							
								
								
									
										31
									
								
								api.lua
									
									
									
									
									
								
							
							
						
						
									
										31
									
								
								api.lua
									
									
									
									
									
								
							| @@ -587,20 +587,9 @@ function mob_class:flight_check() | ||||
|  | ||||
| 	if not def then return false end | ||||
|  | ||||
| 	if type(self.fly_in) == "string" | ||||
| 	and self.standing_in == self.fly_in then | ||||
|  | ||||
| 	-- are we standing inside what we should be to fly/swim ? | ||||
| 	if check_for(self.standing_in, self.fly_in) then | ||||
| 		return true | ||||
|  | ||||
| 	elseif type(self.fly_in) == "table" then | ||||
|  | ||||
| 		for _,fly_in in pairs(self.fly_in) do | ||||
|  | ||||
| 			if self.standing_in == fly_in then | ||||
|  | ||||
| 				return true | ||||
| 			end | ||||
| 		end | ||||
| 	end | ||||
|  | ||||
| 	-- stops mobs getting stuck inside stairs and plantlike nodes | ||||
| @@ -1289,22 +1278,10 @@ function mob_class:follow_holding(clicker) | ||||
| 	end | ||||
|  | ||||
| 	local item = clicker:get_wielded_item() | ||||
| 	local t = type(self.follow) | ||||
|  | ||||
| 	-- single item | ||||
| 	if t == "string" | ||||
| 	and item:get_name() == self.follow then | ||||
| 	-- are we holding an item mob can follow ? | ||||
| 	if check_for(item:get_name(), self.follow) then | ||||
| 		return true | ||||
|  | ||||
| 	-- multiple items | ||||
| 	elseif t == "table" then | ||||
|  | ||||
| 		for no = 1, #self.follow do | ||||
|  | ||||
| 			if self.follow[no] == item:get_name() then | ||||
| 				return true | ||||
| 			end | ||||
| 		end | ||||
| 	end | ||||
|  | ||||
| 	return false | ||||
|   | ||||
		Reference in New Issue
	
	Block a user