lua: get/set block commands
This commit is contained in:
		
					parent
					
						
							
								e07f06d75f
							
						
					
				
			
			
				commit
				
					
						538f7c7c61
					
				
			
		
					 1 changed files with 26 additions and 0 deletions
				
			
		
							
								
								
									
										26
									
								
								init.lua
									
										
									
									
									
								
							
							
						
						
									
										26
									
								
								init.lua
									
										
									
									
									
								
							|  | @ -64,6 +64,7 @@ minetest.register_chatcommand("g1_send", { | |||
| 				http.fetch({url="http://127.0.0.1:30061/send/"..address.."/"..amount, method="GET"}, | ||||
| 					function(res) | ||||
| 						if res ~= nil and res.code == 200 then | ||||
| 							minetest.log("action", "mt-g1 - "..name.." sent "..amount_mg.."MG to "..address) | ||||
| 							core.chat_send_player(name, "Transfer sent") | ||||
| 						else | ||||
| 							core.chat_send_player(name, "Error during transfer, giving your money back") | ||||
|  | @ -87,6 +88,7 @@ minetest.register_chatcommand("g1_claim", { | |||
| 		local inv = core.get_inventory({type="player", name=name}) | ||||
| 		local stack = "currency:minegeld "..amount_mg | ||||
| 		if inv:room_for_item("main", ItemStack(stack)) then | ||||
| 			minetest.log("action", "mt-g1 - "..name.." claimed "..amount_mg.."MG") | ||||
| 			inv:add_item("main", ItemStack(stack)) | ||||
| 			core.chat_send_player(name, "Claimed "..amount_mg.."MG") | ||||
| 			mod_storage:set_int("debt_"..name, 0) | ||||
|  | @ -95,3 +97,27 @@ minetest.register_chatcommand("g1_claim", { | |||
| 		end | ||||
| 	end | ||||
| }) | ||||
| 
 | ||||
| minetest.register_chatcommand("g1_block", { | ||||
| 	description = "Get latest block number known by the server", | ||||
| 	func = function(name, param) | ||||
| 		local block = mod_storage:get_int("block") | ||||
| 		core.chat_send_player(name, "Current block: "..block) | ||||
| 	end | ||||
| }) | ||||
| 
 | ||||
| minetest.register_chatcommand("g1_setblock", { | ||||
| 	privs = { | ||||
| 		server = true | ||||
| 	}, | ||||
| 	params = "<block number>", | ||||
| 	description = "(admin) Set latest block number", | ||||
| 	func = function(name, param) | ||||
| 		local new_block = tonumber(param) | ||||
| 		if type(new_block) == "number" then | ||||
| 			mod_storage:set_int("block", new_block) | ||||
| 		else | ||||
| 			core.chat_send_player("name", "Argument must be an integer.") | ||||
| 		end | ||||
| 	end | ||||
| }) | ||||
|  |  | |||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue