Facebook
From Adelka, 2 Weeks ago, written in Lua.
Embed
Download Paste or View Raw
Hits: 104
  1. -- cheat_menu.lua
  2.  
  3. -- Define a table to store the cheat codes
  4. local cheats = {
  5.     ["god_mode"] = false,
  6.     ["infinite_ammo"] = false,
  7.     ["level_select"] = false
  8. }
  9.  
  10. -- Define a function to toggle the cheat codes
  11. function toggle_cheat(cheat)
  12.     cheats[cheat] = not cheats[cheat]
  13.     print("Cheat '" .. cheat .. "' is now " .. (cheats[cheat] and "enabled" or "disabled"))
  14. end
  15.  
  16. -- Define a function to display the cheat menu
  17. function show_cheat_menu()
  18.     print("Cheat Menu:")
  19.     print("1. God Mode")
  20.     print("2. Infinite Ammo")
  21.     print("3. Level Select")
  22.     print("Enter the number of the cheat to toggle it")
  23. end
  24.  
  25. -- Define a function to handle user input
  26. function handle_input()
  27.     local input = io.read()
  28.     if input == "1" then
  29.         toggle_cheat("god_mode")
  30.     elseif input == "2" then
  31.         toggle_cheat("infinite_ammo")
  32.     elseif input == "3" then
  33.         toggle_cheat("level_select")
  34.     else
  35.         print("Invalid input. Please enter the number of the cheat to toggle it.")
  36.     end
  37. end
  38.  
  39. -- Show the cheat menu and handle user input in a loop
  40. while true do
  41.     show_cheat_menu()
  42.     handle_input()
  43. end