A pong clone, but with a twist!
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

1537 rivejä
41 KiB

  1. --CALLING OTHER LUA FILES
  2. require "src/dependencies"
  3. io.stdout:setvbuf("no")
  4. --CANCELLED ATTEMPETED SHADING (NOT WORKING)
  5. local shader_code =
  6. [[
  7. vec4 effect(vec4 color, Image image, vec2 uvs, vec2 screen_coords) {
  8. vec4 pixel = Texel(image,uvs);
  9. return pixel * color;
  10. }
  11. ]]
  12. debug = true
  13. --GLOBAL VARIABLES
  14. gameMode = "normal"
  15. ts = 0
  16. globalState = "menu"
  17. timeIsSlow = false
  18. timeIsSlow2 = false
  19. originalSpeed = 200
  20. explosionRange = 0
  21. blockinput = false
  22. wall1width = 30
  23. nuclearanimation = 3
  24. easternum = 0
  25. ball_DIR = 0
  26. updaterate = 0.1
  27. RED = 255
  28. hitNum = {}
  29. hitNum[1] = 0
  30. hitNum[2] = 0
  31. hitNum[3] = 0
  32. confirmation = "N"
  33. hitNum[4] = 0
  34. p1bonus = 0
  35. p2bonus = 0
  36. hitNum[5] = 0
  37. hitNum[6] = 0
  38. GREEN = 255
  39. IP = '45.76.95.31'
  40. BLUE = 255
  41. updateTEXT = "Chalkboard Update"
  42. maxBalls = 1
  43. playerCount = 1
  44. player1reverbav = 0
  45. playertext = "1v1"
  46. player2reverbav = 0
  47. elapsed = 0
  48. rotation = 0
  49. TEXT = "Nuclear Pong"
  50. currentKey = " "
  51. ptw = 10
  52. --CHECKING IF CONTROLS ARE TAKEN
  53. danger = "none"
  54. danger2 = "none"
  55. nuckemodactive = 0
  56. maxspeed = 700
  57. DIFFERENCE_X = 1
  58. DIFFERENCE_Y = 1
  59. paddle_SPEED = 20
  60. textamount = 15
  61. AI_STRIKEMOD = 1000
  62. resolutionWin = 0
  63. AGAINST_AI = 0
  64. RESOLUTION_SET = 0
  65. AI_NUKEMOD = 1000
  66. animstart = true
  67. AI_SPEED = 30
  68. craz = 0
  69. AI_LEVEL = 500
  70. isFullscreen = 0
  71. prtext = "Easy"
  72. lastSentKey = "c"
  73. MAP_TYPE = 0
  74. lastSentKeyClient = "c"
  75. difficultyl = 300
  76. req = "pp"
  77. ballSet = 200
  78. p1control = {up = "a", down = "z", super = "s", counter = "x"}
  79. p2control = {up = ";", down = ".", super = "l", counter = ","}
  80. synctext = "Independent"
  81. synctype = 0
  82. function newButton(text, fn)
  83. return {
  84. text = text,
  85. fn = fn,
  86. now = false,
  87. last = false
  88. }
  89. end
  90. function love.keyboard.mouseWasReleased()
  91. return love.keyboard.mouseisReleased
  92. end
  93. function autoSave(dt)
  94. autoTimer = autoTimer + dt
  95. end
  96. function balancer()
  97. if (player2score == 9 or player1score == 9) then
  98. shakeDuration = 5
  99. if debug then
  100. --print("Shaking set to match almost over")
  101. end
  102. end
  103. if (player1score < player2score) then
  104. p1bonus = (player2score - player1score) * 5
  105. else
  106. p1bonus = 0
  107. end
  108. if (player2score < player1score) then
  109. p2bonus = (player1score - player2score) * 5
  110. else
  111. p2bonus = 0
  112. end
  113. end
  114. function newWall(wallx, wally, wallwidth, wallheight)
  115. return {
  116. wallx = wallx,
  117. wally = wally,
  118. walwidth = wallwidth,
  119. wallheight = wallheight
  120. }
  121. end
  122. speedParameters = {}
  123. buttons = {}
  124. IPselect = {}
  125. difbuttons = {}
  126. settings = {}
  127. walls = {}
  128. editorpicks = {}
  129. controlSettings = {}
  130. modeSelectorButtons = {}
  131. pracdiff = {}
  132. playerCountButtons = {}
  133. function controlChanger()
  134. if (gameState == "assign") then
  135. love.graphics.clear(50 / 255, 50 / 255, 50 / 255, 255)
  136. love.graphics.printf("SELECT BUTTON", 0, VIRTUAL_HEIGHT / 2, VIRTUAL_WIDTH, "center")
  137. end
  138. end
  139. function love.load()
  140. love.keyboard.setKeyRepeat(true)
  141. simpleScale.setWindow(VIRTUAL_WIDTH, VIRTUAL_HEIGHT, WINDOW_WIDTH, WINDOW_HEIGHT)
  142. configfile = io.open("config.lua", "r")
  143. configsave = io.open("config.lua", "w")
  144. shader = love.graphics.newShader(shader_code)
  145. time_1 = 0
  146. --print("Debug active")
  147. --load
  148. testwalls = love.filesystem.load("save.lua")()
  149. if testwalls ~= nil then
  150. walls = love.filesystem.load("save.lua")()
  151. end
  152. light = 0
  153. image = love.graphics.newImage("Madi.png")
  154. table.insert(
  155. editorpicks,
  156. newButton(
  157. "C",
  158. function()
  159. for k in pairs(walls) do
  160. walls[k] = nil
  161. end
  162. end
  163. )
  164. )
  165. table.insert(
  166. editorpicks,
  167. newButton(
  168. "S",
  169. function()
  170. love.filesystem.write("save.lua", serialize(walls))
  171. end
  172. )
  173. )
  174. table.insert(
  175. editorpicks,
  176. newButton(
  177. "L",
  178. function()
  179. walls = love.filesystem.load("save.lua")()
  180. end
  181. )
  182. )
  183. table.insert(
  184. buttons,
  185. newButton(
  186. "Singleplayer",
  187. function()
  188. gameState = "gameMode"
  189. end
  190. )
  191. )
  192. table.insert(
  193. buttons,
  194. newButton(
  195. "Online",
  196. function()
  197. gameState = "chooseIP"
  198. end
  199. )
  200. )
  201. table.insert(
  202. IPselect,
  203. newButton(
  204. "Host",
  205. function()
  206. globalState = "nettest"
  207. AGAINST_AI = 0
  208. gameState = "1serve"
  209. end
  210. )
  211. )
  212. table.insert(
  213. IPselect,
  214. newButton(
  215. "Guest",
  216. function()
  217. globalState = "clienttest"
  218. AGAINST_AI = 0
  219. gameState = "1serve"
  220. end
  221. )
  222. )
  223. table.insert(
  224. buttons,
  225. newButton(
  226. "Multiplayer",
  227. function()
  228. gameState = "multiMode"
  229. end
  230. )
  231. )
  232. table.insert(
  233. buttons,
  234. newButton(
  235. "Settings",
  236. function()
  237. AGAINST_AI = 0
  238. gameState = "windowsettings"
  239. end
  240. )
  241. )
  242. table.insert(
  243. buttons,
  244. newButton(
  245. "Exit",
  246. function()
  247. love.event.quit(0)
  248. end
  249. )
  250. )
  251. table.insert(
  252. difbuttons,
  253. newButton(
  254. "Easy",
  255. function()
  256. hardmanager("easy")
  257. end
  258. )
  259. )
  260. table.insert(
  261. difbuttons,
  262. newButton(
  263. "Normal",
  264. function()
  265. hardmanager("normal")
  266. end
  267. )
  268. )
  269. table.insert(
  270. difbuttons,
  271. newButton(
  272. "Hard",
  273. function()
  274. hardmanager("hard")
  275. end
  276. )
  277. )
  278. table.insert(
  279. difbuttons,
  280. newButton(
  281. "Smart",
  282. function()
  283. hardmanager("smart")
  284. end
  285. )
  286. )
  287. table.insert(
  288. settings,
  289. newButton(
  290. "Change Map",
  291. function()
  292. MAP_TYPE = MAP_TYPE + 1
  293. end
  294. )
  295. )
  296. table.insert(
  297. settings,
  298. newButton(
  299. "Toggle Fullscreen",
  300. function()
  301. myscreen:toggle(VIRTUAL_HEIGHT, VIRTUAL_WIDTH)
  302. DIFFERENCE_X = myscreen.c
  303. DIFFERENCE_Y = myscreen.d
  304. end
  305. )
  306. )
  307. table.insert(
  308. settings,
  309. newButton(
  310. "Editor",
  311. function()
  312. gameState = "editor"
  313. end
  314. )
  315. )
  316. table.insert(
  317. settings,
  318. newButton(
  319. "Speed Settings",
  320. function()
  321. gameState = "speedSettings"
  322. end
  323. )
  324. )
  325. table.insert(
  326. settings,
  327. newButton(
  328. "Control Settings",
  329. function()
  330. gameState = "controlSettings"
  331. end
  332. )
  333. )
  334. table.insert(
  335. settings,
  336. newButton(
  337. "Back to Menu",
  338. function()
  339. gameState = "menu"
  340. end
  341. )
  342. )
  343. table.insert(
  344. speedParameters,
  345. newButton(
  346. "Back to Menu",
  347. function()
  348. gameState = "windowsettings"
  349. end
  350. )
  351. )
  352. --table.insert(speedParameters, newButton("Ball Speed: ", function() speedSetter('ball') end))
  353. table.insert(
  354. playerCountButtons,
  355. newButton(
  356. "Ball Speed: ",
  357. function()
  358. speedSetter("ball")
  359. end
  360. )
  361. )
  362. --table.insert(speedParameters, newButton("snc", function() speedSetter('snc') end))
  363. table.insert(
  364. playerCountButtons,
  365. newButton(
  366. "snc",
  367. function()
  368. speedSetter("snc")
  369. end
  370. )
  371. )
  372. table.insert(
  373. speedParameters,
  374. newButton(
  375. "NUCLEAR MODE",
  376. function()
  377. speedSetter("nuclearmod")
  378. end
  379. )
  380. )
  381. table.insert(
  382. controlSettings,
  383. newButton(
  384. "1up",
  385. function()
  386. gameState = "assign"
  387. req = "p1up"
  388. end
  389. )
  390. )
  391. table.insert(
  392. controlSettings,
  393. newButton(
  394. "1down",
  395. function()
  396. gameState = "assign"
  397. req = "p1down"
  398. end
  399. )
  400. )
  401. table.insert(
  402. controlSettings,
  403. newButton(
  404. "1special",
  405. function()
  406. gameState = "assign"
  407. req = "p1super"
  408. end
  409. )
  410. )
  411. table.insert(
  412. controlSettings,
  413. newButton(
  414. "1ct",
  415. function()
  416. gameState = "assign"
  417. req = "p1ct"
  418. end
  419. )
  420. )
  421. table.insert(
  422. controlSettings,
  423. newButton(
  424. "2up",
  425. function()
  426. gameState = "assign"
  427. req = "p2up"
  428. end
  429. )
  430. )
  431. table.insert(
  432. controlSettings,
  433. newButton(
  434. "2down",
  435. function()
  436. gameState = "assign"
  437. req = "p2down"
  438. end
  439. )
  440. )
  441. table.insert(
  442. controlSettings,
  443. newButton(
  444. "2special",
  445. function()
  446. gameState = "assign"
  447. req = "p2super"
  448. end
  449. )
  450. )
  451. table.insert(
  452. controlSettings,
  453. newButton(
  454. "2ct",
  455. function()
  456. gameState = "assign"
  457. req = "p2ct"
  458. end
  459. )
  460. )
  461. table.insert(
  462. controlSettings,
  463. newButton(
  464. "Default",
  465. function()
  466. p1control = {up = "a", down = "z", super = "s", counter = "x"}
  467. p2control = {up = ";", down = ".", super = "l", counter = ","}
  468. end
  469. )
  470. )
  471. table.insert(
  472. controlSettings,
  473. newButton(
  474. "Return",
  475. function()
  476. gameState = "windowsettings"
  477. end
  478. )
  479. )
  480. table.insert(
  481. modeSelectorButtons,
  482. newButton(
  483. "Nuclear Pong",
  484. function()
  485. gameState = "difficulty"
  486. end
  487. )
  488. )
  489. table.insert(
  490. modeSelectorButtons,
  491. newButton(
  492. "Main Menu",
  493. function()
  494. gameState = "menu"
  495. end
  496. )
  497. )
  498. table.insert(
  499. pracdiff,
  500. newButton(
  501. "Silverblade",
  502. function()
  503. speedSetter("practice")
  504. end
  505. )
  506. )
  507. table.insert(
  508. pracdiff,
  509. newButton(
  510. "Return",
  511. function()
  512. speedSetter("reset")
  513. gameState = "gameMode"
  514. end
  515. )
  516. )
  517. table.insert(
  518. pracdiff,
  519. newButton(
  520. "Go!",
  521. function()
  522. gameMode = "practice"
  523. hardmanager("practice")
  524. end
  525. )
  526. )
  527. --table.insert(playerCountButtons, newButton("1v1", function() speedSetter('pc') end))
  528. table.insert(
  529. playerCountButtons,
  530. newButton(
  531. "ballCount",
  532. function()
  533. speedSetter("ballz")
  534. end
  535. )
  536. )
  537. table.insert(
  538. difbuttons,
  539. newButton(
  540. "ballCount",
  541. function()
  542. speedSetter("ballz")
  543. end
  544. )
  545. )
  546. table.insert(
  547. playerCountButtons,
  548. newButton(
  549. "Return",
  550. function()
  551. speedSetter("reset")
  552. gameState = "menu"
  553. end
  554. )
  555. )
  556. table.insert(
  557. playerCountButtons,
  558. newButton(
  559. "ptw",
  560. function()
  561. speedSetter("ptw")
  562. end
  563. )
  564. )
  565. table.insert(
  566. playerCountButtons,
  567. newButton(
  568. "Play",
  569. function()
  570. AGAINST_AI = 0
  571. gameState = "1serve"
  572. globalState = "base"
  573. end
  574. )
  575. )
  576. table.insert(
  577. playerCountButtons,
  578. newButton(
  579. "Reverse Play",
  580. function()
  581. gameState = "1serve"
  582. gameMode = "reversegame"
  583. end
  584. )
  585. )
  586. --table.insert(speedParameters, newButton("Ball Speed: ", function() speedSetter() end))
  587. love.window.setTitle("NUCLEAR PONG")
  588. textphrases = {
  589. "Amazing",
  590. "Superb",
  591. "Absolutely beautiful!",
  592. "Awesome",
  593. "Look at That!",
  594. "Great",
  595. "Nice",
  596. "Boom!",
  597. "Dangerous!",
  598. "Astonishing!",
  599. "u/ebernerd saved me",
  600. "Absolutely Wonderful!",
  601. "Exsquisite",
  602. "Delicate",
  603. "Pow!",
  604. "Great Hit",
  605. "all hail nazarbayev"
  606. }
  607. sounds = {
  608. ["updateMusic"] = love.audio.newSource("audio/theme1.mp3", "static"),
  609. ["gayTheme"] = love.audio.newSource("audio/theme2.mp3", "static"),
  610. ["gayTheme2"] = love.audio.newSource("audio/theme3.mp3", "static"),
  611. ["gayTheme3"] = love.audio.newSource("audio/theme4.mp3", "static"),
  612. ["beep"] = love.audio.newSource("audio/hit1.mp3", "static"),
  613. ["wallhit"] = love.audio.newSource("audio/hit2.wav", "static"),
  614. ["win"] = love.audio.newSource("win.wav", "static"),
  615. ["score"] = love.audio.newSource("audio/score.wav", "static"),
  616. ["nuke"] = love.audio.newSource("audio/bomb.wav", "static"),
  617. ["striking"] = love.audio.newSource("audio/superhit.wav", "static"),
  618. ["nuclearhit"] = love.audio.newSource("audio/hit1.mp3", "static"),
  619. ["time"] = love.audio.newSource("audio/time.wav", "static")
  620. }
  621. love.graphics.setDefaultFilter("nearest", "nearest")
  622. --comic sans lmao
  623. math.randomseed(os.time())
  624. smallfont = love.graphics.newFont("font.ttf", 25)
  625. scorefont = love.graphics.newFont("font.ttf", 60)
  626. love.graphics.setFont(smallfont)
  627. --push:setupScreen(VIRTUAL_WIDTH, VIRTUAL_HEIGHT, WINDOW_WIDTH, WINDOW_HEIGHT, {
  628. -- fullscreen = isFullscreen,
  629. -- resizable = true,
  630. -- vsync = true,
  631. --})
  632. player1score = 0
  633. player2score = 0
  634. areanuclear = 0
  635. player1nukescore = 0
  636. player2nukescore = 0
  637. striken = 0
  638. soundtype = 1
  639. soundturn = 1
  640. potentialstrike1 = 0
  641. potentialstrike2 = 0
  642. potentialnuke1 = 0
  643. potentialnuke2 = 0
  644. player1striken = 0
  645. player2striken = 0
  646. randomtext = 0
  647. selecting = 0
  648. number = 0
  649. elec = 1
  650. INDIC = {
  651. "",
  652. "",
  653. "",
  654. ""
  655. }
  656. --playe1nuke
  657. player1 = paddle(0, 30, 10, 100, 1)
  658. player2 = paddle(VIRTUAL_WIDTH * 0.99, VIRTUAL_HEIGHT * 0.88, 10, 100, 2)
  659. player3 = paddle(5000, 5000, 10, 100)
  660. player4 = paddle(5000, 5000, 10, 100)
  661. ball = {}
  662. ball[1] = eball(VIRTUAL_WIDTH / 2, VIRTUAL_HEIGHT / 2 - 2, 16, 16)
  663. ball[2] = eball(VIRTUAL_WIDTH / 1.9, VIRTUAL_HEIGHT / 2 - 2, 16, 16)
  664. ball[3] = eball(VIRTUAL_WIDTH / 1.8, VIRTUAL_HEIGHT / 2 - 2, 16, 16)
  665. ball[4] = eball(VIRTUAL_WIDTH / 2.2, VIRTUAL_HEIGHT / 2 - 2, 16, 16)
  666. ball[5] = eball(VIRTUAL_WIDTH / 2.1, VIRTUAL_HEIGHT / 2 - 2, 16, 16)
  667. myscreen = fullScreener(RESOLUTION_SET, isFullscreen, DIFFERENCE_X, DIFFERENCE_Y)
  668. mymenu = mainMenu()
  669. ballSpeed = 200
  670. ballDX = math.random(2) == 1 and 100 or -100
  671. ballDY = math.random(-50, 50)
  672. gameState = "animation"
  673. end
  674. t = 0
  675. shakeDuration = 0
  676. shakeMagnitude = 1
  677. function startShake(duration, magnitude)
  678. t, shakeDuration, shakeMagnitude = 0, duration or 1, magnitude or 5
  679. end
  680. function displayFPS()
  681. --love.window.setTitle(love.timer.getFPS())
  682. love.window.setTitle(globalState .. " " .. gameState)
  683. if love.keyboard.isDown("space") then
  684. player1nukescore = 200
  685. player1score = player1score + 0.2
  686. player2nukescore = 200
  687. end
  688. end
  689. function speedControl()
  690. if (ballSpeed > maxspeed and gameState == "play") then
  691. ballSpeed = maxspeed
  692. end
  693. end
  694. function love.update(dt)
  695. --print("IMPORTANT!!!!!" .. globalState .. gameState)
  696. staticanimatorcounter(dt)
  697. musicController('norm', 1)
  698. if debug then
  699. displayFPS()
  700. end
  701. if globalState == "base" then
  702. basegame(dt)
  703. end
  704. if globalState == "menu" then
  705. debugCheck(dt)
  706. end
  707. if globalState == "nettest" then
  708. print("Confcode: " .. confirmation)
  709. ts = ts + dt
  710. if confirmation == "N" then
  711. basegame(dt)
  712. end
  713. if ts > updaterate then
  714. nettest(dt)
  715. ts = ts - updaterate
  716. end
  717. end
  718. if globalState == "clienttest" then
  719. ts = ts + dt
  720. if confirmation == "N" then
  721. lastSentKeyP1 = lastSentKeyClient
  722. clientsBaseGame(dt)
  723. end
  724. if ts > updaterate then
  725. clienttest(dt)
  726. ts = ts - updaterate
  727. end
  728. end
  729. end
  730. serverinit = false
  731. clientinit = false
  732. function love.textinput(t)
  733. if gameState == "chooseIP" then
  734. IP = IP .. t
  735. end
  736. end
  737. function nettest(dt)
  738. if serverinit == false then
  739. local socket = require "socket"
  740. local address, port = IP, 12345
  741. print(address)
  742. udp = socket.udp()
  743. udp:setpeername(address, port)
  744. udp:settimeout(0)
  745. serverinit = true
  746. end
  747. for i = 1, maxBalls do
  748. print (tostring(ball[i].dy))
  749. udp:send(tostring(lastSentKey) ..
  750. '|' .. tostring(ball[i].dy) ..
  751. '|' .. tostring(player2.y) ..
  752. '|' .. tostring(player1.y) ..
  753. '|' .. tostring(player1score) ..
  754. '|' .. tostring(player2score) ..
  755. '|' .. tostring(player1nukescore) ..
  756. '|' .. tostring(player2nukescore) ..
  757. '|' .. tostring(ball[i].x) ..
  758. '|' .. tostring(ball[i].y) ..
  759. '|' .. gameState ..
  760. '|' .. tostring(ball[i].dx) ..
  761. "|HOST")
  762. print("SENT: " .. lastSentKey)
  763. end
  764. local data
  765. local datanumtest = 0
  766. repeat
  767. datanumtest = datanumtest + 1
  768. print("LATENCY: " .. tostring(datanumtest))
  769. data = udp:receive()
  770. if data then
  771. confirmation = "N"
  772. local p = split(data, '|')
  773. if p[3] ~= "CLIENT" then
  774. confirmation = "U"
  775. end
  776. if tonumber(p[4]) > 90 then
  777. confirmation = "L"
  778. end
  779. lastSentKeyClient = p[1]
  780. player2.y = tonumber(p[2])
  781. else
  782. confirmation = "D"
  783. print("NO PLAYER 2!!")
  784. end
  785. until not data
  786. end
  787. function clienttest(dt)
  788. if clientinit == false then
  789. local socket = require "socket"
  790. local address, port = IP, 12345
  791. udp = socket.udp()
  792. udp:setpeername(address, port)
  793. udp:settimeout(0)
  794. udp:send(tostring(lastSentKey) .. '|' .. tostring(player2.y) .. "|CLIENT")
  795. clientinit = true
  796. end
  797. local data
  798. local datanumtest = 0
  799. repeat
  800. datanumtest = datanumtest + 1
  801. print("LATENCY: " .. tostring(datanumtest))
  802. data = udp:receive()
  803. if data then
  804. print(data)
  805. udp:send(tostring(lastSentKey) .. '|' .. tostring(player2.y) .. "|CLIENT")
  806. print("SENT TO SERVER:" .. lastSentKey)
  807. confirmation = "N"
  808. local p = split(data, '|')
  809. if p[13] then
  810. if p[13] ~= "HOST" then
  811. confirmation = "U"
  812. end
  813. if tonumber(p[14]) > 5 then
  814. confirmation = "L"
  815. end
  816. for i = 1, maxBalls do
  817. local die = tonumber(p[2])
  818. lastSentKeyClient, ball[i].dy, player2.y, player1.y, player1score, player2score, player1nukescore, player2nukescore, ball[i].x, ball[i].y, gameState, ball[i].dx = p[1], die, tonumber(p[3]), tonumber(p[4]), tonumber(p[5]), tonumber(p[6]), tonumber(p[7]), tonumber(p[8]), tonumber(p[9]), tonumber(p[10]), p[11], tonumber(p[12])
  819. end
  820. end
  821. else
  822. confirmation = "D"
  823. end
  824. print("GOT: " .. lastSentKeyClient)
  825. until not data
  826. end
  827. function wallbreaker(x, y)
  828. if (gameState == "editor") then
  829. for i, wall in ipairs(walls) do
  830. if math.abs(wall.wallx - x) < 10 and math.abs(wall.wally - y) < 10 then
  831. table.remove(walls, i)
  832. end
  833. end
  834. end
  835. end
  836. function hardmanager(diff)
  837. selecting = 1
  838. if (diff == "easy") then
  839. INDIC[1] = ">"
  840. AGAINST_AI = 1
  841. AI_SPEED = ballSet / 10
  842. AI_STRIKEMOD = 100
  843. AI_NUKEMOD = 1000
  844. AI_LEVEL = 350
  845. difficultyl = 200
  846. selecting = 0
  847. gameState = "1serve"
  848. globalState = "base"
  849. end
  850. if (diff == "normal") then
  851. INDIC[2] = ">"
  852. AI_SPEED = ballSet / 10
  853. AI_LEVEL = 500
  854. AI_NUKEMOD = 250
  855. AI_STRIKEMOD = 60
  856. AGAINST_AI = 1
  857. difficultyl = 300
  858. selecting = 0
  859. gameState = "1serve"
  860. globalState = "base"
  861. end
  862. if (diff == "hard") then
  863. INDIC[3] = ">"
  864. AI_SPEED = ballSpeed * 1.1 + 50
  865. AI_SPEED = AI_SPEED / 10
  866. AI_LEVEL = 700
  867. AI_NUKEMOD = 200
  868. AI_STRIKEMOD = 20
  869. selecting = 0
  870. difficultyl = 350
  871. AGAINST_AI = 1
  872. gameState = "1serve"
  873. globalState = "base"
  874. end
  875. if (diff == "smart") then
  876. INDIC[3] = ">"
  877. AI_SPEED = ballSpeed * 1.1 + 50
  878. AI_SPEED = AI_SPEED / 10
  879. AI_LEVEL = 1500
  880. AI_NUKEMOD = 200
  881. AI_STRIKEMOD = 20
  882. selecting = 0
  883. difficultyl = 350
  884. AGAINST_AI = 1
  885. gameState = "1serve"
  886. globalState = "base"
  887. end
  888. if (diff == "practice") then
  889. INDIC[3] = ">"
  890. AI_SPEED = ballSpeed * 500 + 50
  891. AI_SPEED = AI_SPEED / 10
  892. AI_LEVEL = 700
  893. AI_NUKEMOD = 9000000000
  894. AI_STRIKEMOD = 90000000
  895. selecting = 0
  896. difficultyl = 350
  897. AGAINST_AI = 1
  898. gameState = "base"
  899. end
  900. end
  901. function dangerChecker() --CHECK IF CONTROLS ARE DUPLICATING
  902. if (p1control.up == p1control.down) then
  903. danger = "1up"
  904. danger2 = "1down"
  905. elseif (p1control.up == p1control.super) then
  906. danger = "1up"
  907. danger2 = "1special"
  908. elseif (p1control.up == p1control.counter) then
  909. danger = "1up"
  910. danger2 = "1ct"
  911. elseif (p1control.down == p1control.super) then
  912. danger = "1down"
  913. danger2 = "1special"
  914. elseif (p1control.down == p1control.counter) then
  915. danger = "1ct"
  916. danger2 = "1down"
  917. elseif (p1control.super == p1control.counter) then
  918. danger = "1special"
  919. danger2 = "1ct"
  920. elseif (p2control.down == p2control.up) then
  921. danger = "2down"
  922. danger2 = "2up"
  923. elseif (p2control.down == p2control.super) then
  924. danger = "2down"
  925. danger2 = "2special"
  926. elseif (p2control.down == p2control.counter) then
  927. danger = "2down"
  928. danger2 = "2ct"
  929. elseif (p2control.up == p2control.super) then
  930. danger = "2up"
  931. danger2 = "2special"
  932. elseif (p2control.up == p2control.counter) then
  933. danger = "2ct"
  934. danger2 = "2up"
  935. elseif (p2control.super == p2control.counter) then
  936. danger = "2special"
  937. danger2 = "2ct"
  938. else
  939. danger = "none"
  940. danger2 = "none"
  941. end
  942. end
  943. function love.keypressed(key)
  944. lastSentKey = key
  945. if gameState == "chooseIP" then
  946. if key == "backspace" then
  947. -- get the byte offset to the last UTF-8 character in the string.
  948. local byteoffset = utf8.offset(IP, -1)
  949. if byteoffset then
  950. -- remove the last UTF-8 character.
  951. -- string.sub operates on bytes rather than UTF-8 characters, so we couldn't do string.sub(text, 1, -2).
  952. IP = string.sub(IP, 1, byteoffset - 1)
  953. end
  954. end
  955. end
  956. if gameState == "assign" then
  957. if (req == "p1up") then
  958. p1control.up = key
  959. currentKey = key
  960. --love.window.setTitle(key)
  961. gameState = "controlSettings"
  962. end
  963. if (req == "p2up") then
  964. p2control.up = key
  965. currentKey = key
  966. --love.window.setTitle(key)
  967. gameState = "controlSettings"
  968. end
  969. if (req == "p1down") then
  970. p1control.down = key
  971. currentKey = key
  972. --love.window.setTitle(key)
  973. gameState = "controlSettings"
  974. end
  975. if (req == "p2down") then
  976. p2control.down = key
  977. currentKey = key
  978. -- love.window.setTitle(key)
  979. gameState = "controlSettings"
  980. end
  981. if (req == "p1super") then
  982. p1control.super = key
  983. currentKey = key
  984. -- love.window.setTitle(key)
  985. gameState = "controlSettings"
  986. end
  987. if (req == "p2super") then
  988. p2control.super = key
  989. currentKey = key
  990. -- love.window.setTitle(key)
  991. gameState = "controlSettings"
  992. end
  993. if (req == "p1ct") then
  994. p1control.counter = key
  995. currentKey = key
  996. -- love.window.setTitle(key)
  997. gameState = "controlSettings"
  998. end
  999. if (req == "p2ct") then
  1000. p2control.counter = key
  1001. currentKey = key
  1002. --love.window.setTitle(key)
  1003. gameState = "controlSettings"
  1004. end
  1005. end
  1006. if key == "escape" then
  1007. TEXT = "Escape Key"
  1008. love.event.quit()
  1009. elseif key == "enter" or key == "return" then
  1010. if gameState == "start" then
  1011. resettinggenius()
  1012. gameState = "menu"
  1013. globalState = "menu"
  1014. hardmanager()
  1015. elseif (gameState == "done") then
  1016. if (player1score > player2score) then
  1017. gameState = "2serve"
  1018. potentialnuke1 = 0
  1019. potentialnuke2 = 0
  1020. striken = 0
  1021. if (nuckemodactive == 0) then
  1022. areanuclear = 0
  1023. nuclearanimation = 3
  1024. end
  1025. potentialstrike1 = 0
  1026. potentialstrike2 = 0
  1027. player1nukescore = 0
  1028. player2nukescore = 0
  1029. else
  1030. gameState = "1serve"
  1031. resettinggenius()
  1032. for i = 1, maxBalls do
  1033. ball[i]:reset(i)
  1034. end
  1035. end
  1036. else
  1037. gameState = "menu"
  1038. globalState = "menu"
  1039. if (love.math.random(0, 10) == 1) then
  1040. TEXT = "Nuclear Ching Chong"
  1041. else
  1042. TEXT = "Nuclear Pong"
  1043. end
  1044. resettinggenius()
  1045. for i = 1, maxBalls do
  1046. ball[i]:reset(i)
  1047. end
  1048. end
  1049. end
  1050. end
  1051. function love.keyreleased(key)
  1052. currentKey = " "
  1053. if lastSentKey == key then
  1054. lastSentKey = "g"
  1055. end
  1056. end
  1057. function speedSetter(requesttype)
  1058. if (requesttype == "ball") then
  1059. if (ballSet > 550) then
  1060. ballSet = 0
  1061. paddle_SPEED = 0
  1062. else
  1063. ballSet = ballSet + 50
  1064. paddle_SPEED = paddle_SPEED + 5
  1065. end
  1066. ballSpeed = ballSet
  1067. end
  1068. if (requesttype == "snc") then
  1069. synctype = synctype + 1
  1070. if (synctype > 1) then
  1071. synctype = 0
  1072. end
  1073. if synctype == 0 then
  1074. synctext = "Independent"
  1075. end
  1076. if synctype == 1 then
  1077. synctext = "Synchronised"
  1078. end
  1079. end
  1080. if (requesttype == "nuclearmod") then
  1081. nuckemodactive = nuckemodactive + 1
  1082. if (nuckemodactive > 1) then
  1083. nuckemodactive = 0
  1084. end
  1085. if (nuckemodactive == 0) then
  1086. areanuclear = 0
  1087. nuclearanimation = 3
  1088. ballSet = 200
  1089. TEXT = "Nuclear Pong"
  1090. synctype = 0
  1091. maxspeed = 700
  1092. synctext = "Independent"
  1093. paddle_SPEED = ballSet / 10
  1094. AI_SPEED = ballSet / 10
  1095. end
  1096. if (nuckemodactive == 1) then
  1097. areanuclear = 1
  1098. ballSet = 2000
  1099. maxspeed = 2000
  1100. paddle_SPEED = ballSet / 10
  1101. AI_SPEED = ballSet / 10
  1102. synctext = "death is imminent"
  1103. end
  1104. ballSpeed = ballSet
  1105. end
  1106. if (requesttype == "practice") then
  1107. if (ballSpeed > 999) then
  1108. ballSpeed = 200
  1109. ballSet = 200
  1110. end
  1111. if (ballSpeed > 799) then
  1112. prtext = "Insane"
  1113. maxBalls = 5
  1114. elseif ballSpeed > 599 then
  1115. prtext = "Hard"
  1116. maxBalls = 4
  1117. elseif ballSpeed > 399 then
  1118. prtext = "Normal"
  1119. maxBalls = 3
  1120. elseif ballSpeed > 199 then
  1121. prtext = "Easy"
  1122. maxBalls = 3
  1123. end
  1124. ballSpeed = ballSpeed + 200
  1125. ballSet = ballSet + 200
  1126. end
  1127. if (requesttype == "reset") then
  1128. ballSpeed = 200
  1129. ballSet = 200
  1130. synctype = 0
  1131. prtext = "Easy"
  1132. maxBalls = 1
  1133. end
  1134. if (requesttype == "pc") then
  1135. if (playerCount == 2) then
  1136. playerCount = 1
  1137. playertext = "1v1"
  1138. elseif (playerCount == 1) then
  1139. playerCount = playerCount + 1
  1140. player3.x = player1.x + VIRTUAL_WIDTH / 2
  1141. player3.y = player3.y
  1142. playertext = "2v2"
  1143. end
  1144. end
  1145. if (requesttype == "ballz") then
  1146. if (maxBalls > 1) then
  1147. --love.window.setTitle("more than 4")
  1148. maxBalls = 1
  1149. else
  1150. maxBalls = maxBalls + 1
  1151. end
  1152. end
  1153. if requesttype == "ptw" then
  1154. if ptw == 10 then
  1155. ptw = 1
  1156. else
  1157. ptw = ptw + 1
  1158. end
  1159. end
  1160. end
  1161. function gameModeChanger()
  1162. if (gameState == "gameMode") then
  1163. local button_width = VIRTUAL_WIDTH * (1 / 3)
  1164. local BUTTON_HEIGHT = 50
  1165. local margin = 20
  1166. local hot = false
  1167. local cursor_y = 0
  1168. local total_height = (BUTTON_HEIGHT + margin) * #buttons
  1169. for i, button in ipairs(modeSelectorButtons) do
  1170. button.last = button.now
  1171. local bx = (VIRTUAL_WIDTH * 0.5) - (button_width * 0.5)
  1172. local by = (VIRTUAL_HEIGHT * 0.5) - (total_height * 0.5) + cursor_y
  1173. local color = {255, 255, 255, 255}
  1174. local mx, my = love.mouse.getPosition()
  1175. mx = mx * DIFFERENCE_X
  1176. my = my * DIFFERENCE_Y
  1177. hot = (mx > bx and mx < bx + button_width and my > by and my < by + BUTTON_HEIGHT) and i
  1178. if (hot == i) then
  1179. color = {10, 10, 0, 255}
  1180. end
  1181. button.now = love.mouse.isDown(1)
  1182. if button.now and not button.last and hot == i then
  1183. love.graphics.setColor(0, 0, 0, 1)
  1184. love.graphics.rectangle("fill", 0, 0, VIRTUAL_WIDTH, VIRTUAL_HEIGHT)
  1185. sounds["wallhit"]:play()
  1186. button.fn()
  1187. end
  1188. love.graphics.setColor(unpack(color))
  1189. love.graphics.rectangle("fill", bx, by, button_width, BUTTON_HEIGHT)
  1190. love.graphics.setColor(0, 0, 0, 255)
  1191. local textW = smallfont:getWidth(button.text)
  1192. local textH = smallfont:getHeight(button.text)
  1193. love.graphics.print(button.text, smallfont, VIRTUAL_WIDTH * 0.5 - textW * 0.5, by + textH * 0.5)
  1194. love.graphics.setColor(255, 255, 255, 255)
  1195. cursor_y = cursor_y + (BUTTON_HEIGHT + margin)
  1196. end
  1197. end
  1198. if (gameState == "multiMode") then
  1199. local button_width = VIRTUAL_WIDTH * (1 / 3)
  1200. local BUTTON_HEIGHT = 50
  1201. local margin = 20
  1202. local hot = false
  1203. local cursor_y = 0
  1204. local total_height = (BUTTON_HEIGHT + margin) * #buttons
  1205. for i, button in ipairs(playerCountButtons) do
  1206. button.last = button.now
  1207. local bx = (VIRTUAL_WIDTH * 0.5) - (button_width * 0.5)
  1208. local by = (VIRTUAL_HEIGHT * 0.3) - (total_height * 0.5) + cursor_y
  1209. if (button.text == "Play") then
  1210. by = by + by / 1.8
  1211. end
  1212. local color = {255, 255, 255, 255}
  1213. local mx, my = love.mouse.getPosition()
  1214. mx = mx * DIFFERENCE_X
  1215. my = my * DIFFERENCE_Y
  1216. hot = (mx > bx and mx < bx + button_width and my > by and my < by + BUTTON_HEIGHT) and i
  1217. if (hot == i) then
  1218. if (button.text == "Play") then
  1219. color = {0 / 255, 255 / 255, 0 / 255, 255}
  1220. else
  1221. color = {10, 10, 0, 255}
  1222. end
  1223. end
  1224. button.now = love.mouse.isDown(1)
  1225. if button.now and not button.last and hot == i then
  1226. love.graphics.setColor(0, 0, 0, 1)
  1227. love.graphics.rectangle("fill", 0, 0, VIRTUAL_WIDTH, VIRTUAL_HEIGHT)
  1228. sounds["wallhit"]:play()
  1229. if button.text == "Ball Speed: " and nuckemodactive == 1 then
  1230. else
  1231. button.fn()
  1232. end
  1233. end
  1234. love.graphics.setColor(unpack(color))
  1235. love.graphics.rectangle("fill", bx, by, button_width, BUTTON_HEIGHT)
  1236. love.graphics.setColor(0, 0, 0, 255)
  1237. local textW = smallfont:getWidth(button.text)
  1238. local textH = smallfont:getHeight(button.text)
  1239. if (button.text == "1v1") then
  1240. love.graphics.print(playertext, smallfont, VIRTUAL_WIDTH * 0.5 - textW * 0.5, by + textH * 0.5)
  1241. elseif button.text == "snc" then
  1242. if (nuckemodactive == 1) then
  1243. love.graphics.setColor(1, 0, 0, 1)
  1244. love.graphics.print(synctext, smallfont, VIRTUAL_WIDTH * 0.5 - textW * 0.5, by + textH * 0.5)
  1245. love.graphics.setColor(1, 1, 1, 1)
  1246. love.graphics.print(synctext, smallfont, VIRTUAL_WIDTH * 0.5 - textW * 0.5, by + textH * 0.5)
  1247. love.graphics.setColor(0, 0, 0, 1)
  1248. else
  1249. --
  1250. love.graphics.print(synctext, smallfont, VIRTUAL_WIDTH * 0.45 - textW * 0.5, by + textH * 0.5)
  1251. end
  1252. elseif (button.text == "ballCount") then
  1253. love.graphics.print(
  1254. "Ball Count: " .. maxBalls,
  1255. smallfont,
  1256. VIRTUAL_WIDTH * 0.5 - textW * 0.5,
  1257. by + textH * 0.5
  1258. )
  1259. elseif (button.text == "Ball Speed: ") then
  1260. if (nuckemodactive == 1) then
  1261. love.graphics.setColor(1, 0, 0, 1)
  1262. love.graphics.print(
  1263. "shaitan machina",
  1264. smallfont,
  1265. VIRTUAL_WIDTH * 0.5 - textW * 0.5,
  1266. by + textH * 0.5
  1267. )
  1268. love.graphics.setColor(1, 1, 1, 1)
  1269. love.graphics.print(
  1270. "shaitan machina",
  1271. smallfont,
  1272. VIRTUAL_WIDTH * 0.5 - textW * 0.5,
  1273. by + textH * 0.5
  1274. )
  1275. love.graphics.setColor(0, 0, 0, 1)
  1276. else
  1277. love.graphics.print(
  1278. button.text .. ballSet,
  1279. smallfont,
  1280. VIRTUAL_WIDTH * 0.5 - textW * 0.5,
  1281. by + textH * 0.5
  1282. )
  1283. end
  1284. elseif button.text == "ptw" then
  1285. love.graphics.print(
  1286. "Points to Win: " .. ptw,
  1287. smallfont,
  1288. VIRTUAL_WIDTH * 0.5 - textW * 1.5,
  1289. by + textH * 0.5
  1290. )
  1291. else
  1292. love.graphics.print(button.text, smallfont, VIRTUAL_WIDTH * 0.5 - textW * 0.5, by + textH * 0.5)
  1293. end
  1294. love.graphics.setColor(255, 255, 255, 255)
  1295. cursor_y = cursor_y + (BUTTON_HEIGHT + margin)
  1296. end
  1297. end
  1298. end
  1299. function love.draw()
  1300. simpleScale.set()
  1301. baseDraw()
  1302. if (globalState == "nettest" or globalState == "clienttest") and confirmation == "D" then
  1303. love.graphics.clear(50 / 255, 50 / 255, 50 / 255, 255)
  1304. love.graphics.printf("WAIT FOR PLAYER 2", 0, VIRTUAL_HEIGHT / 2, VIRTUAL_WIDTH, "center")
  1305. end
  1306. if (globalState == "nettest" or globalState == "clienttest") and confirmation == "U" then
  1307. love.graphics.clear(50 / 255, 50 / 255, 50 / 255, 255)
  1308. love.graphics.printf("LOBBY FULL OR WRONG MODE CHOSEN", 0, VIRTUAL_HEIGHT / 2, VIRTUAL_WIDTH, "center")
  1309. end
  1310. if (globalState == "nettest" or globalState == "clienttest") and confirmation == "L" then
  1311. love.graphics.clear(50 / 255, 50 / 255, 50 / 255, 255)
  1312. love.graphics.printf("POOR CONNECTION TO SERVER", 0, VIRTUAL_HEIGHT / 2, VIRTUAL_WIDTH, "center")
  1313. end
  1314. simpleScale.unSet()
  1315. end
  1316. --Check if controls are duplicating
  1317. function controllerSer()
  1318. for i = 1, maxBalls do
  1319. if (ball[i].dy == 0) then
  1320. hitNum[i] = hitNum[i] + 1
  1321. if hitNum[i] >= 10 then
  1322. ball[i].dy = 1
  1323. hitNum[i] = 0
  1324. end
  1325. else
  1326. hitNum[i] = 0
  1327. end
  1328. end
  1329. end
  1330. function palleteController() --!!!!LEGACY CODE, MIGRATED TO Paddle.lua!!!!
  1331. if (areanuclear == 0) then
  1332. player1.RED = 1
  1333. player1.GREEN = 1
  1334. player1.BLUE = 1
  1335. end
  1336. if (areanuclear == 0) then
  1337. player2.RED = 1
  1338. player2.GREEN = 1
  1339. player2.BLUE = 1
  1340. end
  1341. if (areanuclear == 1) then
  1342. player1.RED = 0
  1343. player1.GREEN = 0
  1344. player1.BLUE = 0
  1345. end
  1346. if (areanuclear == 1) then
  1347. player2.RED = 0
  1348. player2.GREEN = 0
  1349. player2.BLUE = 0
  1350. end
  1351. end
  1352. function love.wheelmoved(x, y)
  1353. if (y < 0 and wall1width > 0) then
  1354. wall1width = wall1width - 5
  1355. elseif y > 0 and wall1width < 900 then
  1356. wall1width = wall1width + 5
  1357. end
  1358. end
  1359. function serveBot() --THIS IS USED TO CHANGE TEXT/BALL DIRECTION ON DIFFERENT SERVES
  1360. --print("servebot called")
  1361. if (gameState == "1serve") then
  1362. updateTEXT = ""
  1363. if (gameMode ~= "practice") then
  1364. TEXT = "PLAYER 1, serve!(q)"
  1365. end
  1366. if ((globalState ~= "clienttest" and love.keyboard.isDown("q")) or (globalState == "clienttest" and lastSentKeyP1 == "q")) then
  1367. TEXT = "Lets Begin!"
  1368. ball_DIR = 1
  1369. for i = 1, maxBalls do
  1370. ball[i]:reset(i)
  1371. end
  1372. gameState = "play"
  1373. end
  1374. end
  1375. if (gameState == "2serve") then
  1376. TEXT = "PLAYER 2, serve!(p)"
  1377. if (AGAINST_AI == 1) then
  1378. TEXT = ""
  1379. ball_DIR = -1
  1380. for i = 1, maxBalls do
  1381. ball[i]:reset(i)
  1382. end
  1383. gameState = "play"
  1384. end
  1385. if (((globalState == "nettest" and lastSentKeyClient == "p") or ((globalState ~= "nettest") and love.keyboard.isDown("p")))and AGAINST_AI == 0) then
  1386. TEXT = "Lets Begin"
  1387. ball_DIR = -1
  1388. for i = 1, maxBalls do
  1389. ball[i]:reset(i)
  1390. end
  1391. --love.window.setTitle("An atttttttt")
  1392. gameState = "play"
  1393. end
  1394. end
  1395. end
  1396. function mapChanger()
  1397. if (gameState == "editor") then
  1398. MAP_TYPE = 2
  1399. end
  1400. if (MAP_TYPE > 2) then
  1401. MAP_TYPE = 0
  1402. end
  1403. end
  1404. function resolutionChanger()
  1405. if (RESOLUTION_SET > 1) then
  1406. RESOLUTION_SET = 0
  1407. end
  1408. if (RESOLUTION_SET == 0) then
  1409. if (isFullscreen == 1) then
  1410. DIFFERENCE_X = 1
  1411. DIFFERENCE_Y = 1
  1412. simpleScale.updateWindow(WINDOW_WIDTH, WINDOW_HEIGHT, {fullscreen = false})
  1413. isFullscreen = 0
  1414. end
  1415. end
  1416. if (RESOLUTION_SET == 1) then
  1417. if (isFullscreen == 0) then
  1418. simpleScale.updateWindow(WINDOW_WIDTH, WINDOW_HEIGHT, {fullscreen = true})
  1419. local newWidth = love.graphics.getWidth()
  1420. local newHeight = love.graphics.getHeight()
  1421. DIFFERENCE_X = VIRTUAL_WIDTH / newWidth
  1422. DIFFERENCE_Y = VIRTUAL_HEIGHT / newHeight
  1423. isFullscreen = 1
  1424. end
  1425. end
  1426. end
  1427. function resettinggenius()
  1428. maxBalls = 1
  1429. for i = 1, maxBalls do
  1430. ball[i]:reset(i)
  1431. end
  1432. paddle_SPEED = 20
  1433. nuclearanimation = 3
  1434. timeIsSlow = false
  1435. timeIsSlow2 = false
  1436. originalSpeed = 200
  1437. gameState = "menu"
  1438. globalState = "menu"
  1439. gameMode = "normal"
  1440. player1.height = 100
  1441. player2.height = 100
  1442. ballSet = 200
  1443. ballSpeed = ballSet
  1444. player2.GREEN = 255
  1445. player2.BLUE = 255
  1446. player1.GREEN = 255
  1447. player1.BLUE = 255
  1448. player1score = 0
  1449. player2score = 0
  1450. potentialnuke1 = 0
  1451. potentialnuke2 = 0
  1452. striken = 0
  1453. areanuclear = 0
  1454. potentialstrike1 = 0
  1455. potentialstrike2 = 0
  1456. player1nukescore = 0
  1457. player2nukescore = 0
  1458. player1reverbav = 0
  1459. player2reverbav = 0
  1460. selecting = 0
  1461. AGAINST_AI = 0
  1462. end
  1463. function love.mousereleased(x, y, button)
  1464. love.keyboard.mouseisReleased = true
  1465. if (gameState == "editor") then
  1466. if (#walls < 1000 and button == 1 and blockinput ~= true) then
  1467. table.insert(walls, newWall(x * DIFFERENCE_X, y * DIFFERENCE_Y, 10, wall1width))
  1468. end
  1469. end
  1470. end
  1471. function ballsAlive()
  1472. for i = 1, maxBalls do
  1473. if ball[i].disabled == false then
  1474. print("Ball " .. i .. " is not disabled")
  1475. return true
  1476. end
  1477. end
  1478. return false
  1479. end
  1480. function split(s, delimiter)
  1481. result = {}
  1482. for match in (s..delimiter):gmatch("(.-)"..delimiter) do
  1483. table.insert(result, match)
  1484. end
  1485. return result
  1486. end