summaryrefslogtreecommitdiff
path: root/example/scripts/npcs/debugger.lua
blob: 390f8f29a230b8726d377e0db4236c41d7e41e4b (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
----------------------------------------------------------
-- Seller Function Sample                                      --
----------------------------------------------------------------------------------
--  Copyright 2009-2010 The Mana World Development Team                              --
--                                                                              --
--  This file is part of The Mana World.                                        --
--                                                                              --
--  The Mana World  is free software; you can redistribute  it and/or modify it --
--  under the terms of the GNU General  Public License as published by the Free --
--  Software Foundation; either version 2 of the License, or any later version. --
----------------------------------------------------------------------------------

function npc1_talk(npc, ch)
  on_remove(ch, function() print "Player has left the map." end);
  say("Hello! I am the testing NPC.")
  local rights = ch:rights();

  if (rights >= 128) then
    say("Oh mighty server administrator, how can I avoid your wrath?")
  elseif (rights >= 8) then
    say("How can I be of assistance, sir gamemaster?")
  elseif (rights >= 4) then
    say("What feature would you like to debug, developer?")
  elseif (rights >= 2) then
    say("How can I assist you in your testing duties?")
  elseif (rights >= 1) then
    say("What do you want, lowly player?")
  else
    say("...aren't you supposed to be banned??")
  end

  local v = ask("Guns! Lots of guns!",
                "A Christmas party!",
                "To make a donation.",
                "Slowly count from one to ten.",
                "Tablepush Test")
  if v == 1 then
    say("Sorry, this is a heroic-fantasy game, I do not have any gun.")

  elseif v == 2 then
    local n1, n2 = ch:inv_count(524, 511)
    if n1 == 0 or n2 ~= 0 then
      say("Yeah right...")
    else
      say("I can't help you with the party. But I see you have a fancy hat. I could change it into Santa's hat. Not much of a party, but it would get you going.")
      v = ask("Please do.", "No way! Fancy hats are classier.")
      if v == 1 then
        ch:inv_change(524, -1, 511, 1)
      end
    end

  elseif v == 3 then
    if chr_money_change(ch, -100) then
      say(string.format("Thank you for you patronage! You are left with %d GP.", chr_money(ch)))
      local g = tonumber(chr_get_quest(ch, "001_donation"))
      if not g then g = 0 end
      g = g + 100
      chr_set_quest(ch, "001_donation", g)
      say(string.format("As of today, you have donated %d GP.", g))
    else
      say("I would feel bad taking money from someone that poor.")
    end

  elseif v == 4 then
    npc:say("As you wish...")
    schedule_in(2, function() npc:say("One") end)
    schedule_in(4, function() npc:say("Two") end)
    schedule_in(6, function() npc:say("Three") end)
    schedule_in(8, function() npc:say("Four") end)
    schedule_in(10, function() npc:say("Five") end)
    schedule_in(12, function() npc:say("Six") end)
    schedule_in(14, function() npc:say("Seven") end)
    schedule_in(16, function() npc:say("Eight") end)
    schedule_in(18, function() npc:say("Nine") end)
    schedule_in(20, function() npc:say("Ten") end)

  elseif v == 5 then
    function printTable (t)
      for k,v in pairs(t) do
        print (k, ":", v)
      end
    end
    local t1, t2, t3, t4, t5 = test_tableget();
    print("---------------");
    print ("Table 1:");
    printTable (t1)
    print ("Table 2:");
    printTable (t2)
    print ("Table 3:");
    printTable (t3)
    print ("Table 4:");
    printTable (t4)
    print ("Table 5:");
    printTable (t5)
    print("---------------");
  end

  say("See you later!")
end