forked from minetest-mods/player_monoids
		
	Compare commits
	
		
			4 Commits
		
	
	
		
			nalc-1.2.0
			...
			master
		
	
	| Author | SHA1 | Date | |
|---|---|---|---|
| daf92c43e3 | |||
| 
						 | 
					8d6f1ade93 | ||
| 0bbad015ef | |||
| 
						 | 
					08bc018f92 | 
							
								
								
									
										12
									
								
								README.md
									
									
									
									
									
								
							
							
						
						
									
										12
									
								
								README.md
									
									
									
									
									
								
							@@ -40,9 +40,10 @@ mymod.speed_monoid = player_monoids.make_monoid({
 | 
				
			|||||||
	end,
 | 
						end,
 | 
				
			||||||
	fold = function(tab)
 | 
						fold = function(tab)
 | 
				
			||||||
		local res = 1
 | 
							local res = 1
 | 
				
			||||||
	     	for _, speed in pairs(tab) do
 | 
							for _, speed in pairs(tab) do
 | 
				
			||||||
			res = res * speed
 | 
								res = res * speed
 | 
				
			||||||
	     	end
 | 
							end
 | 
				
			||||||
 | 
							return res
 | 
				
			||||||
	end,
 | 
						end,
 | 
				
			||||||
	identity = 1,
 | 
						identity = 1,
 | 
				
			||||||
	apply = function(speed, player)
 | 
						apply = function(speed, player)
 | 
				
			||||||
@@ -108,9 +109,10 @@ newmod.speed_boosts = player_monoids.make_monoid({
 | 
				
			|||||||
	end,
 | 
						end,
 | 
				
			||||||
	fold = function(tab)
 | 
						fold = function(tab)
 | 
				
			||||||
		local res = 1
 | 
							local res = 1
 | 
				
			||||||
	     	for _, speed in pairs(tab) do
 | 
							for _, speed in pairs(tab) do
 | 
				
			||||||
			res = math.max(res, speed)
 | 
								res = math.max(res, speed)
 | 
				
			||||||
	     	end
 | 
							end
 | 
				
			||||||
 | 
							return res
 | 
				
			||||||
	end,
 | 
						end,
 | 
				
			||||||
	identity = 1,
 | 
						identity = 1,
 | 
				
			||||||
	apply = ???
 | 
						apply = ???
 | 
				
			||||||
@@ -202,4 +204,4 @@ global state.
 | 
				
			|||||||
* The order that different effects get combined together is based on key order,
 | 
					* The order that different effects get combined together is based on key order,
 | 
				
			||||||
which may not be predictable. So you should try to make your monoids commutative
 | 
					which may not be predictable. So you should try to make your monoids commutative
 | 
				
			||||||
in addition to associative, or at least not care if the order of two changes
 | 
					in addition to associative, or at least not care if the order of two changes
 | 
				
			||||||
is swapped.
 | 
					is swapped.
 | 
				
			||||||
 
 | 
				
			|||||||
							
								
								
									
										2
									
								
								test.lua
									
									
									
									
									
								
							
							
						
						
									
										2
									
								
								test.lua
									
									
									
									
									
								
							@@ -14,6 +14,8 @@ local function test(player)
 | 
				
			|||||||
	minetest.chat_send_player(p_name, "Your speed is: " .. speed:value(player))
 | 
						minetest.chat_send_player(p_name, "Your speed is: " .. speed:value(player))
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	minetest.after(3, function()
 | 
						minetest.after(3, function()
 | 
				
			||||||
 | 
							local player = minetest.get_player_by_name(p_name)
 | 
				
			||||||
 | 
							if not player then return end
 | 
				
			||||||
		speed:del_change(player, ch_id)
 | 
							speed:del_change(player, ch_id)
 | 
				
			||||||
		minetest.chat_send_player(p_name, "Your speed is: " .. speed:value(player))
 | 
							minetest.chat_send_player(p_name, "Your speed is: " .. speed:value(player))
 | 
				
			||||||
	end)
 | 
						end)
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user