Debian Codegraph @

data/storyline/act2/dialogs/Friend.lua

raw
1 ---------------------------------------------------------------------
2 -- This file is part of Freedroid
3 --
4 -- Freedroid is free software; you can redistribute it and/or modify
5 -- it under the terms of the GNU General Public License as published by
6 -- the Free Software Foundation; either version 2 of the License, or
7 -- (at your option) any later version.
8 --
9 -- Freedroid is distributed in the hope that it will be useful,
10 -- but WITHOUT ANY WARRANTY; without even the implied warranty of
11 -- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 -- GNU General Public License for more details.
13 --
14 -- You should have received a copy of the GNU General Public License
15 -- along with Freedroid; see the file COPYING. If not, write to the
16 -- Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston,
17 -- MA 02111-1307 USA
18 ----------------------------------------------------------------------
19 --[[WIKI
20 PURPOSE = "$$NAME$$ is a character used for Debug purposes"
21 WIKI]]--
22
23 local Npc = FDrpg.get_npc()
24 local Tux = FDrpg.get_tux()
25
26 local function dude_dialog_name(filename)
27 return string.sub(filename, 1, -(string.len(".lua") + 1))
28 end
29
30 local function dude_create_node(dialogname)
31 return {
32 id = dialogname,
33 text = dialogname,
34 enabled = true,
35 code = function()
36 Tux:says("Starting " .. dialogname)
37 start_chat(dialogname)
38 end,
39 }
40 end
41
42 local function dude_choose_action(this_dialog)
43 local actionname = user_input_string("Please enter the dialog name of the desired NPC (Colemak, Yadda...) " ..
44 "or other action to jump to (craft, upgrade, switchact or exit). " ..
45 "If the input is invalid, the game will crash! To abort, enter " ..
46 "'continue' or press enter or escape.")
47 if (not (actionname == "continue" or actionname == "")) then
48 local actionnode = this_dialog:find_node(actionname)
49 if (actionnode and actionnode.code) then
50 actionnode:code(this_dialog)
51 end
52 end
53 end
54
55 return {
56 FirstTime = function()
57 Dude_exit_node_count = 0
58 end,
59
60 EveryTime = function(this_node, this_dialog)
61 Npc:says("Hello.")
62 Npc:says("Are multi-act variables supported: [b]false[/b]")
63 Npc:says("Here you'll be able to access all dialogs that are available ingame.", "NO_WAIT")
64 Npc:says("Take care, this may be a little buggy.", "NO_WAIT")
65 Npc:says("Don't do this if you are just normally playing.", "NO_WAIT")
66 Npc:says("These dialogs can currently be accessed:", "NO_WAIT")
67 local node_list = ""
68 for idx,node in ipairs(this_dialog.nodes) do
69 if (node.id ~= "node0") then
70 node_list = node_list .. node.id .. ", "
71 end
72 end
73 Npc:says(string.sub(node_list, 1, -2))
74
75 dude_choose_action(this_dialog)
76 end,
77
78 {
79 id = "node0",
80 enabled = true,
81 text = "Show input field again.",
82 code = function(this_node, this_dialog)
83 dude_choose_action(this_dialog)
84 hide("node0")
85 show("node0") -- done on purpose
86 end,
87 },
88
89 {
90 id ="switchact",
91 enabled = true,
92 text = "Test Game Act switching",
93 code = function()
94 jump_to_game_act("act1")
95 Npc:says("Will switch back to Act 1. Closing...")
96 end_dialog()
97 end,
98 },
99
100 {
101 id = "craft",
102 enabled = true,
103 text = "Craft addons",
104 code = function()
105 craft_addons()
106 end,
107 },
108
109 {
110 id = "upgrade",
111 enabled = true,
112 text = "Upgrade items",
113 code = function()
114 upgrade_items()
115 end,
116 },
117
118 --[[{
119 id = "shop",
120 enabled = true,
121 text = "Shop",
122 code = function()
123 trade_with("Dude")
124 end,
125 },]]
126
127 {
128 id = "spam",
129 enabled = true,
130 text = "Spam",
131 code = function()
132 for spam_number=1,10000 do
133 Npc:says(spam_number, "NO_WAIT")
134 end
135 end,
136 },
137
138 {
139 generator = function()
140 local nodes = {}
141 local exclude = {
142 -- "subdialogs" can not be run solely
143 --"sub.lua",
144 -- dialog of terminals can not be run, currently, because they have no associated 'bot'
145 "ArenaTerminal", "Act2-Vending-Machine.lua", "CryonicsBlock-Terminal.lua",
146 "FactoryTerminal.lua", "IcePass-Terminal.lua",
147 "RRF-ManagmentTerminal.lua", "RRGateTerminal.lua", "TerminalColemak.lua",
148 "Terminal.lua", "TerminalDenied.lua",
149 }
150
151 local dircontent = FDutils.system.scandir(FDdialog.dialogs_dirs, ".*%.lua", exclude)
152 if (dircontent) then
153 for none,filename in ipairs(dircontent) do
154 nodes[#nodes + 1] = dude_create_node(dude_dialog_name(filename))
155 end
156 end
157
158 return nodes
159 end
160 },
161
162 {
163 id = "exit",
164 enabled = true,
165 text = function()
166 return string.format( "Exit this dialog for the %sth time", Dude_exit_node_count + 1)
167 end,
168 code = function()
169 Npc:says("Closing...")
170 Dude_exit_node_count = Dude_exit_node_count + 1 -- do the computation of the var now
171 end_dialog()
172 end,
173 },
174 }