Advertisement
Guest User

Untitled

a guest
Jun 16th, 2015
37
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 0.80 KB | None | 0 0
  1. local width, height = minetest.get_screen_size();
  2.  
  3. local player = minetest.get_local_player();
  4.  
  5. -- ^ this is client-side script
  6. -- for server-side (single player), we might do minetest.get_sp_player()
  7.  
  8. local formspec = FormSpec()
  9.  
  10. formspec.width = width / 2
  11. formspec.height = height / 2
  12.  
  13. local button = Button()
  14.  
  15. button.text = "OK"
  16. button.width = 75
  17. button.height = 25
  18. button.x = (width - formspec.width) / 2
  19. button.y = (height - formspec.height) / 2
  20.  
  21. button.onclick = function(target, params)
  22.  
  23.     -- target - ref to button which was clicked (because the same callback can be
  24.                 bound to multiple buttons)
  25.     -- params - additional mouse/keyboard parameters
  26.    
  27.     target.parentForm:close()
  28. end
  29.  
  30. formspec:addControl(button);
  31.  
  32. formspec:showTo(player); -- or maybe player:showForm(formspec)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement