funkd0ct0r

Untitled

Apr 2nd, 2014
68
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 18.78 KB | None | 0 0
  1. --todo:
  2. -- autorefuel from found coal
  3. -- fix the edge extra block
  4. -- display current fuel level while refueling
  5. -- refueling during doChest etc
  6. -- maybe refuel limit = 1
  7. -- J5wXS4AE
  8. -- PT0SmjPx
  9. -- JYYEHcy5
  10. -- GeyqYHnM
  11. -- i6J1bA3Q
  12. -- sCpfzzgV
  13. -- xq91ssuy
  14. -- aC20GtgU
  15. -- gK7A19W4
  16. -- pGdmLjjr
  17. -- eYCve9Eb
  18. -- ge4QnKbY
  19.  
  20.  
  21. local programState = "done"
  22. local refuelingState = ""
  23.  
  24. local curX = 0
  25. local curY = 0
  26. local curZ = 0
  27. local subStep = 0
  28. local isReversed = false
  29.  
  30. local sizeX = 0
  31. local sizeY = 0
  32. local sizeZ = 0
  33.  
  34. local useEnderChest = false
  35. local useEnderFuel = false
  36. local useChest = false
  37. local useCobblestone = false
  38. local useCoal = false
  39.  
  40. local saveFile = "savedata"
  41.  
  42. local outputSlot = 0
  43. local cobbleSlot = 0
  44.  
  45. local function getYesNo()
  46. local i
  47. local event, param
  48.  
  49. while true do
  50. event, param = os.pullEvent("key")
  51.  
  52. if param == 21 then
  53. return true
  54. end
  55. if param == 49 then
  56. return false
  57. end
  58. end
  59. end
  60.  
  61. local function requestFuel()
  62. local i
  63. local c = false
  64. local event, param
  65.  
  66. if useCoal and turtle.getItemCount(coalSlot) > 1 then
  67. turtle.select(coalSlot)
  68. if turtle.refuel(1) then
  69. turtle.select(cobbleSlot)
  70. return true
  71. end
  72. end
  73.  
  74. print("Press F to refuel from slot 16")
  75. print("Press Q to exit the program")
  76.  
  77. if turtle.getFuelLevel() >= 64 then
  78. c = true
  79. print("Press C to continue quarry")
  80. end
  81.  
  82. while true do
  83. event, param = os.pullEvent("key")
  84.  
  85. if param == 33 then --f
  86. turtle.select(16)
  87. turtle.refuel()
  88. if not c and turtle.getFuelLevel() >= 64 then
  89. c = true
  90. print("Press C to continue quarry")
  91. end
  92. end
  93. if param == 16 then --q
  94. return false
  95. end
  96. if c and param == 46 then --c
  97. turtle.select(cobbleSlot)
  98. return true
  99. end
  100. end
  101. end
  102.  
  103.  
  104. local function restoreProgress()
  105. if fs.exists(saveFile) then
  106. local file = fs.open(saveFile,"r")
  107.  
  108. programState = tostring(file.readLine())
  109. refuelingState = tostring(file.readLine())
  110.  
  111. curX = tonumber(file.readLine())
  112. curY = tonumber(file.readLine())
  113. curZ = tonumber(file.readLine())
  114. subStep = tonumber(file.readLine())
  115. sizeX = tonumber(file.readLine())
  116. sizeY = tonumber(file.readLine())
  117. sizeZ = tonumber(file.readLine())
  118.  
  119. if file.readLine() == "true" then isReversed = true else isReversed = false end
  120.  
  121. if file.readLine() == "true" then useEnderChest = true else useEnderChest = false end
  122. if file.readLine() == "true" then useEnderFuel = true else useEnderFuel = false end
  123. if file.readLine() == "true" then useChest = true else useChest = false end
  124. if file.readLine() == "true" then useCobblestone = true else useCobblestone = false end
  125. if file.readLine() == "true" then useCoal = true else useCoal = false end
  126.  
  127. file.close()
  128. end
  129. end
  130.  
  131. local function saveProgress()
  132. local file = fs.open(saveFile,"w")
  133.  
  134. file.write(tostring(programState).."\n")
  135. file.write(tostring(refuelingState).."\n")
  136.  
  137. file.write(tostring(curX).."\n")
  138. file.write(tostring(curY).."\n")
  139. file.write(tostring(curZ).."\n")
  140. file.write(tostring(subStep).."\n")
  141.  
  142. file.write(tostring(sizeX).."\n")
  143. file.write(tostring(sizeY).."\n")
  144. file.write(tostring(sizeZ).."\n")
  145.  
  146. file.write(tostring(isReversed).."\n")
  147.  
  148. file.write(tostring(useEnderChest).."\n")
  149. file.write(tostring(useEnderFuel).."\n")
  150. file.write(tostring(useChest).."\n")
  151. file.write(tostring(useCobblestone).."\n")
  152. file.write(tostring(useCoal).."\n")
  153.  
  154. file.close()
  155. end
  156.  
  157. local function moveForward()
  158. turtle.dig()
  159. while not turtle.forward() do
  160. sleep(0)
  161. turtle.dig()
  162. end
  163. end
  164. local function moveUp()
  165. turtle.digUp()
  166. while not turtle.up() do
  167. sleep(0)
  168. turtle.digUp()
  169. end
  170. end
  171. local function moveDown()
  172. print("movedown")
  173. turtle.digDown()
  174. while not turtle.down() do
  175. print("cant")
  176. sleep(0)
  177. turtle.digDown()
  178. end
  179. end
  180.  
  181. local function doRefuel()
  182. refuelingState = "refuel"
  183. saveProgress()
  184.  
  185. while turtle.getFuelLevel() < 64 do
  186.  
  187. if turtle.getItemCount(2) > 0 then
  188. turtle.select(2)
  189. while not turtle.placeUp() do
  190. sleep(0)
  191. turtle.digUp()
  192. end
  193. end
  194.  
  195. turtle.select(16)
  196. turtle.drop()
  197. for maxstacks = 1, 1 do
  198. turtle.suckUp()
  199. if not turtle.refuel() then turtle.drop() end
  200. end
  201. end
  202.  
  203. turtle.select(2)
  204. turtle.digUp()
  205. refuelingState = ""
  206. saveProgress()
  207. end
  208.  
  209. local function doEmpty()
  210. refuelingState = "empty"
  211. saveProgress()
  212.  
  213. if turtle.getItemCount(1) > 0 then
  214. turtle.select(1)
  215. while not turtle.placeUp() do
  216. sleep(0)
  217. turtle.digUp()
  218. end
  219. end
  220.  
  221. for slot = outputSlot, 16 do
  222. while turtle.getItemCount(slot) > 0 do
  223. turtle.select(slot)
  224. turtle.dropUp()
  225. sleep(1)
  226. end
  227. end
  228.  
  229. turtle.select(1)
  230. turtle.digUp()
  231. refuelingState = ""
  232. saveProgress()
  233. end
  234.  
  235. local function checkFuel()
  236.  
  237. if turtle.getFuelLevel() < 64 then
  238. if useEnderFuel then
  239. doRefuel()
  240. else
  241. if not requestFuel() then
  242. programState = "done"
  243. return
  244. end
  245. end
  246. end
  247.  
  248. end
  249.  
  250. local function doChest()
  251. programState = "chest"
  252. saveProgress()
  253.  
  254. --orient toward x
  255. local limit
  256.  
  257. limit = 1
  258. while subStep < limit do
  259. subStep = subStep + 1
  260. saveProgress()
  261. if (curX % 2 == 0) == isReversed then
  262. --facing = 1
  263. turtle.turnRight()
  264. else
  265. --facing = 3
  266. turtle.turnLeft()
  267. end
  268. end
  269.  
  270. limit = limit + curY
  271. while subStep < limit do
  272. checkFuel()
  273. subStep = subStep + 1
  274. saveProgress()
  275. moveUp()
  276. end
  277.  
  278. limit = limit + curX
  279. while subStep < limit do
  280. checkFuel()
  281. subStep = subStep + 1
  282. saveProgress()
  283. moveForward()
  284. end
  285.  
  286. limit = limit + 1
  287. while subStep < limit do
  288. subStep = subStep + 1
  289. saveProgress()
  290. turtle.turnLeft()
  291. end
  292.  
  293. limit = limit + curZ
  294. while subStep < limit do
  295. checkFuel()
  296. subStep = subStep + 1
  297. saveProgress()
  298. moveForward()
  299. end
  300.  
  301. limit = limit + 1
  302. while subStep < limit do
  303. for slot = outputSlot, 16 do
  304. while turtle.getItemCount(slot) ~= 0 do
  305. turtle.select(slot)
  306. turtle.drop()
  307. sleep(1)
  308. end
  309. end
  310. subStep = subStep + 1
  311. saveProgress()
  312. end
  313.  
  314. limit = limit + 2
  315. while subStep < limit do
  316. subStep = subStep + 1
  317. saveProgress()
  318. turtle.turnRight()
  319. end
  320.  
  321. limit = limit + curZ
  322. while subStep < limit do
  323. checkFuel()
  324. subStep = subStep + 1
  325. saveProgress()
  326. moveForward()
  327. end
  328.  
  329. limit = limit + 1
  330. while subStep < limit do
  331. subStep = subStep + 1
  332. saveProgress()
  333. turtle.turnRight()
  334. end
  335.  
  336. limit = limit + curX
  337. while subStep < limit do
  338. checkFuel()
  339. subStep = subStep + 1
  340. saveProgress()
  341. moveForward()
  342. end
  343.  
  344. limit = limit + curY
  345. while subStep < limit do
  346. checkFuel()
  347. subStep = subStep + 1
  348. saveProgress()
  349. moveDown()
  350. end
  351.  
  352. limit = limit + 1
  353. while subStep < limit do
  354. subStep = subStep + 1
  355. saveProgress()
  356. if (curX % 2 == 0) == isReversed then
  357. --facing = 1
  358. turtle.turnRight()
  359. else
  360. --facing = 3
  361. turtle.turnLeft()
  362. end
  363. end
  364.  
  365. turtle.select(cobbleSlot)
  366. programState = "quarry"
  367. subStep = 0
  368. saveProgress()
  369. end
  370.  
  371. local function doReturn()
  372. programState = "return"
  373. saveProgress()
  374.  
  375. --orient toward x
  376. local limit
  377.  
  378. limit = 1
  379. while subStep < limit do
  380. subStep = subStep + 1
  381. saveProgress()
  382. if (curX % 2 == 0) == isReversed then
  383. --facing = 1
  384. turtle.turnRight()
  385. else
  386. --facing = 3
  387. turtle.turnLeft()
  388. end
  389. end
  390.  
  391. limit = limit + curY
  392. while subStep < limit do
  393. checkFuel()
  394. subStep = subStep + 1
  395. saveProgress()
  396. moveUp()
  397. end
  398.  
  399. limit = limit + curX
  400. while subStep < limit do
  401. checkFuel()
  402. subStep = subStep + 1
  403. saveProgress()
  404. moveForward()
  405. end
  406.  
  407. limit = limit + 1
  408. while subStep < limit do
  409. subStep = subStep + 1
  410. saveProgress()
  411. turtle.turnLeft()
  412. end
  413.  
  414. limit = limit + curZ
  415. while subStep < limit do
  416. checkFuel()
  417. subStep = subStep + 1
  418. saveProgress()
  419. moveForward()
  420. end
  421.  
  422. if useChest then
  423. limit = limit + 1
  424. while subStep < limit do
  425. for slot = outputSlot, 16 do
  426. while turtle.getItemCount(slot) ~= 0 do
  427. turtle.select(slot)
  428. turtle.drop()
  429. sleep(0)
  430. end
  431. end
  432. subStep = subStep + 1
  433. saveProgress()
  434. end
  435. end
  436.  
  437. turtle.turnRight()
  438. turtle.turnRight()
  439. turtle.select(1)
  440. programState = "done"
  441. subStep = 0
  442. saveProgress()
  443. end
  444.  
  445. local function checkInventory()
  446.  
  447. if turtle.getItemCount(16) == 0 then
  448. return
  449. end
  450.  
  451. if useCobblestone then
  452. turtle.select(cobbleSlot)
  453. turtle.drop(turtle.getItemCount(cobbleSlot) - 1)
  454. for slot = outputSlot, 16 do
  455. while turtle.compareTo(slot) do
  456. turtle.select(slot)
  457. turtle.drop()
  458.  
  459. for swap = 16, slot, -1 do
  460. if turtle.getItemCount(swap) > 0 then
  461. turtle.select(swap)
  462. turtle.transferTo(slot)
  463. break
  464. end
  465. end
  466.  
  467. turtle.select(cobbleSlot)
  468. end
  469. end
  470. if turtle.getItemCount(16) == 0 then
  471. return
  472. end
  473. end
  474.  
  475.  
  476. if useEnderChest then
  477. doEmpty()
  478. elseif useChest then
  479. doChest()
  480. else
  481. print("Inventory Full")
  482. local full = true
  483. while full do
  484. full = false
  485. sleep(5)
  486. for slot = outputSlot, 16 do
  487. if turtle.getItemCount(slot) > 0 then
  488. full = true
  489. break
  490. end
  491. end
  492. end
  493. end
  494.  
  495. end
  496.  
  497. local function doQuarryDig()
  498.  
  499. checkFuel()
  500.  
  501. if curY > 0 then
  502. checkInventory()
  503. turtle.digUp()
  504. end
  505. if curY < sizeY - 1 then
  506. checkInventory()
  507. turtle.digDown()
  508. end
  509.  
  510. checkInventory()
  511.  
  512. end
  513.  
  514. local function doQuarry()
  515.  
  516. turtle.select(cobbleSlot)
  517.  
  518. while true do
  519.  
  520.  
  521. if curX % 2 == 0 then
  522. if isReversed then
  523.  
  524. if curZ == 0 then
  525. if curX == 0 then
  526. if curY >= sizeY - 2 then
  527. programState = "return"
  528. return
  529. else
  530. if subStep < 3 then
  531. if curY > 0 then
  532. turtle.digUp()
  533. end
  534. subStep = subStep + 1
  535. if curY < sizeY - 2 then
  536. curY = curY + 1
  537. saveProgress()
  538. moveDown()
  539. end
  540. elseif subStep == 3 then
  541. subStep = subStep + 1
  542. saveProgress()
  543. turtle.turnRight()
  544. elseif subStep == 4 then
  545. subStep = 0
  546. isReversed = false
  547. saveProgress()
  548. turtle.turnRight()
  549. end
  550. end
  551. else
  552. if subStep == 0 then
  553. subStep = subStep + 1
  554. saveProgress()
  555. turtle.turnRight()
  556. elseif subStep == 1 then
  557.  
  558. if curY > 0 then
  559. turtle.digUp()
  560. end
  561. if curY < sizeY - 1 then
  562. turtle.digDown()
  563. end
  564.  
  565. subStep = subStep + 1
  566. saveProgress()
  567. moveForward()
  568. else
  569. subStep = 0
  570. curX = curX - 1
  571. saveProgress()
  572. turtle.turnRight()
  573. end
  574. end
  575. else
  576. doQuarryDig()
  577. saveProgress()
  578. curZ = curZ - 1
  579. moveForward()
  580. end
  581.  
  582. else
  583.  
  584. if curZ == sizeZ - 1 then
  585. if curX == sizeX - 1 then
  586. if curY >= sizeY - 2 then
  587. programState = "return"
  588. return
  589. else
  590. if subStep < 3 then
  591. if curY > 0 then
  592. turtle.digUp()
  593. end
  594. subStep = subStep + 1
  595. if curY < sizeY - 2 then
  596. curY = curY + 1
  597. saveProgress()
  598. moveDown()
  599. end
  600. elseif subStep == 3 then
  601. subStep = subStep + 1
  602. saveProgress()
  603. turtle.turnRight()
  604. elseif subStep == 4 then
  605. subStep = 0
  606. isReversed = true
  607. saveProgress()
  608. turtle.turnRight()
  609. end
  610. end
  611. else
  612. if subStep == 0 then
  613. subStep = subStep + 1
  614. saveProgress()
  615. turtle.turnRight()
  616. elseif subStep == 1 then
  617.  
  618. if curY > 0 then
  619. turtle.digUp()
  620. end
  621. if curY < sizeY - 1 then
  622. turtle.digDown()
  623. end
  624.  
  625. subStep = subStep + 1
  626. saveProgress()
  627. moveForward()
  628. else
  629. subStep = 0
  630. curX = curX + 1
  631. saveProgress()
  632. turtle.turnRight()
  633. end
  634. end
  635. else
  636. doQuarryDig()
  637. curZ = curZ + 1
  638. saveProgress()
  639. moveForward()
  640. end
  641.  
  642. end
  643.  
  644. else -- curX % 2 ~= 0
  645.  
  646. if isReversed then
  647.  
  648. if curZ == sizeZ - 1 then
  649. if curX == 0 then
  650. if curY >= sizeY - 2 then
  651. programState = "return"
  652. return
  653. else
  654. if subStep < 3 then
  655. if curY > 0 then
  656. turtle.digUp()
  657. end
  658. subStep = subStep + 1
  659. if curY < sizeY - 2 then
  660. curY = curY + 1
  661. saveProgress()
  662. moveDown()
  663. end
  664. elseif subStep == 3 then
  665. subStep = subStep + 1
  666. saveProgress()
  667. turtle.turnLeft()
  668. elseif subStep == 4 then
  669. subStep = 0
  670. isReversed = false
  671. saveProgress()
  672. turtle.turnLeft()
  673. end
  674. end
  675. else
  676. if subStep == 0 then
  677. subStep = subStep + 1
  678. saveProgress()
  679. turtle.turnLeft()
  680. elseif subStep == 1 then
  681.  
  682. if curY > 0 then
  683. turtle.digUp()
  684. end
  685. if curY < sizeY - 1 then
  686. turtle.digDown()
  687. end
  688.  
  689. subStep = subStep + 1
  690. saveProgress()
  691. moveForward()
  692. else
  693. subStep = 0
  694. curX = curX - 1
  695. saveProgress()
  696. turtle.turnLeft()
  697. end
  698. end
  699. else
  700. doQuarryDig()
  701. curZ = curZ + 1
  702. saveProgress()
  703. moveForward()
  704. end
  705.  
  706. else
  707.  
  708. if curZ == 0 then
  709. if curX == sizeX - 1 then
  710. if curY >= sizeY - 2 then
  711. programState = "return"
  712. return
  713. else
  714. if subStep < 3 then
  715. if curY > 0 then
  716. turtle.digUp()
  717. end
  718. subStep = subStep + 1
  719. if curY < sizeY - 2 then
  720. curY = curY + 1
  721. saveProgress()
  722. moveDown()
  723. end
  724. elseif subStep == 3 then
  725. subStep = subStep + 1
  726. saveProgress()
  727. turtle.turnLeft()
  728. elseif subStep == 4 then
  729. subStep = 0
  730. isReversed = true
  731. saveProgress()
  732. turtle.turnLeft()
  733. end
  734. end
  735. else
  736. if subStep == 0 then
  737. subStep = subStep + 1
  738. saveProgress()
  739. turtle.turnLeft()
  740. elseif subStep == 1 then
  741.  
  742. if curY > 0 then
  743. turtle.digUp()
  744. end
  745. if curY < sizeY - 1 then
  746. turtle.digDown()
  747. end
  748.  
  749. subStep = subStep + 1
  750. saveProgress()
  751. moveForward()
  752. else
  753. subStep = 0
  754. curX = curX + 1
  755. saveProgress()
  756. turtle.turnLeft()
  757. end
  758. end
  759. else
  760. doQuarryDig()
  761. curZ = curZ - 1
  762. saveProgress()
  763. moveForward()
  764. end
  765.  
  766. end
  767.  
  768. end
  769.  
  770. end
  771. end
  772.  
  773. local function getArgs()
  774.  
  775. if sizeX == nil or sizeY == nil or sizeZ == nil then
  776. return false
  777. end
  778.  
  779. sizeX = tonumber(sizeX)
  780. sizeY = tonumber(sizeY)
  781. sizeZ = tonumber(sizeZ)
  782.  
  783. programState = "done"
  784. refuelingState = ""
  785. curX = 0
  786. curY = 0
  787. curZ = 0
  788. subStep = 0
  789.  
  790. useEnderChest = false
  791. useEnderFuel = false
  792. useChest = false
  793. useCobblestone = false
  794.  
  795. print("Excavate right " .. sizeX .. ", down " .. sizeY .. ", forward " .. sizeZ)
  796. print("Is this correct?")
  797. if not getYesNo() then
  798. return false
  799. end
  800.  
  801. print("Use Ender Chest in slot 1 for output?")
  802. useEnderChest = getYesNo()
  803. if useEnderChest then
  804. print("Use Ender Chest in slot 2 for fuel?")
  805. useEnderFuel = getYesNo()
  806. else
  807. print("Use Chest behind turtle for output?")
  808. useChest = getYesNo()
  809. end
  810.  
  811. if useEnderChest then
  812. if useEnderFuel then
  813. outputSlot = 3
  814. else
  815. outputSlot = 2
  816. end
  817. else
  818. outputSlot = 1
  819. end
  820.  
  821. print("Discard Cobblestone? (requires cobblestone in slot" .. outputSlot .. ")")
  822. useCobblestone = getYesNo()
  823. cobbleSlot = outputSlot
  824. if useCobblestone then
  825. outputSlot = outputSlot + 1
  826. end
  827.  
  828. print("Use Mined Coal? (requires coal in slot" .. outputSlot .. ")")
  829. useCoal = getYesNo()
  830. coalSlot = outputSlot
  831.  
  832. local fuelRequired = (sizeX * sizeZ) * math.ceil(sizeY / 3) + sizeY
  833.  
  834. print("Fuel Required: " .. fuelRequired)
  835. print("Fuel Current: " .. turtle.getFuelLevel())
  836. if (not useEnderFuel) and (turtle.getFuelLevel() < fuelRequired) then
  837. if not requestFuel() then
  838. return false
  839. end
  840. end
  841.  
  842. print("Start Quarry with these parameters?")
  843. if not getYesNo() then
  844. return false
  845. end
  846.  
  847. programState = "init"
  848. saveProgress()
  849. return true
  850. end
  851.  
  852. local function main()
  853.  
  854. outputSlot = 1
  855. if useEnderChest then
  856. outputSlot = 2
  857. if useEnderFuel then
  858. outputSlot = 3
  859. end
  860. end
  861. cobbleSlot = outputSlot
  862. if useCobblestone then
  863. outputSlot = outputSlot + 1
  864. end
  865. coalSlot = outputSlot
  866. if useCoal then
  867. outputSlot = outputSlot + 1
  868. end
  869.  
  870. if refuelingState == "refuel" then
  871. doRefuel()
  872. end
  873.  
  874. if refuelingState == "empty" then
  875. doEmpty()
  876. end
  877.  
  878. if useEnderChest then
  879. if turtle.getItemCount(1) == 0 then
  880. print("Place Ender Chest in slot 1")
  881. while turtle.getItemCount(1) == 0 do
  882. sleep(1)
  883. end
  884. end
  885. if useEnderFuel then
  886. if turtle.getItemCount(2) == 0 then
  887. print("Place Ender Chest in slot 2")
  888. while turtle.getItemCount(2) == 0 do
  889. sleep(1)
  890. end
  891. end
  892. end
  893. end
  894. if useCobblestone then
  895. if turtle.getItemCount(cobbleSlot) == 0 then
  896. print("Place Cobblestone in slot " .. cobbleSlot)
  897. while turtle.getItemCount(cobbleSlot) == 0 do
  898. sleep(1)
  899. end
  900. end
  901. end
  902. if useCoal then
  903. if turtle.getItemCount(coalSlot) == 0 then
  904. print("Place Coal in slot " .. coalSlot)
  905. while turtle.getItemCount(coalSlot) == 0 do
  906. sleep(1)
  907. end
  908. end
  909. end
  910.  
  911.  
  912. while true do
  913.  
  914. if programState == "quarry" then
  915. doQuarry()
  916. end
  917. if programState == "chest" then
  918. doChest()
  919. end
  920. if programState == "init" then
  921. print("init")
  922. if useEnderFuel then doRefuel() end
  923. turtle.select(cobbleSlot)
  924. if curY < sizeY - 1 then
  925. print("init2")
  926. curY = curY + 1
  927. moveDown()
  928. end
  929. programState = "quarry"
  930. print("quarry")
  931. end
  932. if programState == "return" then
  933. doReturn()
  934. break
  935. end
  936.  
  937. end
  938.  
  939. end
  940.  
  941.  
  942. restoreProgress()
  943. if programState == "done" then
  944. sizeX, sizeY, sizeZ = ...
  945. if not getArgs() then
  946. print("Usage")
  947. print(" startup x y z")
  948. return
  949. end
  950. end
  951.  
  952. main()
Advertisement
Add Comment
Please, Sign In to add comment