-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathFMP-template.js
More file actions
197 lines (166 loc) · 6.39 KB
/
Copy pathFMP-template.js
File metadata and controls
197 lines (166 loc) · 6.39 KB
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
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
// ==UserScript==
// @name FlatMMO+ SamplePlugin
// @namespace com.dounford.flatmmo.sample
// @version 0.0.2
// @description FlatMMO+ Template Script
// @author Anwinity ported by Dounford
// @license MIT
// @match *://flatmmo.com/play.php*
// @grant none
// @require https://update.greasyfork.org/scripts/544062/FlatMMOPlus.js
// ==/UserScript==
(function() {
'use strict';
class SamplePlugin extends FlatMMOPlusPlugin {
constructor() {
super("sample", {
about: {
name: GM_info.script.name,
version: GM_info.script.version,
author: GM_info.script.author,
description: GM_info.script.description
},
config: [
{
type: "label",
label: "Section Label:"
},
{
id: "MyCheckbox",
label: "Yes / No",
type: "boolean",
default: true
},
{
id: "MyInteger",
label: "Pick a Integer Number",
type: "integer",
min: 1,
max: 10,
type: "integer",
default: 1
},
{
id: "MyNumber",
label: "Pick a Float Number",
type: "number",
min: 0,
max: 10,
step: 0.1,
default: 1.5
},
{
id: "myRange",
label: "Choose a volume",
type: "range",
min: 0,
max: 100,
step: 1,
default: 100,
},
{
id: "MyString",
label: "Enter a Thing",
type: "string",
max: 20,
default: "x"
},
{
id: "MySelect",
label: "Pick One",
type: "select",
options: [
{value: "opt1", label: "Option 1"},
{value: "opt2", label: "Option 2"},
{value: "opt3", label: "Option 3"}
],
default: "opt2"
},
{
id: "myColor",
label: "Pick a color",
type: "color"
},
{
id: "inventoryPanel",
label: "Go to Inventory",
type: "panel",
panel: "inventory"
}
]
});
}
onConfigsChanged() {
console.log("SamplePlugin.onConfigsChanged");
}
//Run this function when the login is completed, if the plugin is loaded after login it will run as soon as possible
onLogin() {
console.log("SamplePlugin.onLogin");
}
//Receives all messages sent by the game server
onMessageReceived(data) {
// Will spam the console, uncomment if you want to see it
//console.log("SamplePlugin.onMessageReceived: ", data);
}
//This is called on pm, local and global chat messages
onChat(data) {
//This is how data is passed:
const chatData = {
username: "felipe",
tag: "investor",
sigil: "images/ui/gift_sigil.png",
color: "white",
message: "This is a message",
yell: false
}
// Could spam the console, uncomment if you want to see it
//console.log("SamplePlugin.onChat", data);
}
//Called on UI panel switches
onPanelChanged(panelBefore, panelAfter) {
console.log("SamplePlugin.onPanelChange", panelBefore, panelAfter);
}
//Called when the player changes map
onMapChanged(mapBefore, mapAfter) {
// console.log("SamplePlugin.onMapChange", mapBefore, mapAfter);
}
//Called everytime something changes in the inventory
onInventoryChanged(inventoryBefore, inventoryAfter) {
//It sends the full inventory even if you just got one item
//It spams the console each time any modification happens
// console.log("SamplePlugin.onInventoryChange", inventoryBefore, inventoryAfter);
}
//Called when the player engages in a fight
onFightStarted() {
}
//Called when the player was fighting but starts doing other action, this can have a little delay
onFightEnded() {
}
//Called when the player animation changes
onActionChanged() {
console.log(FlatMMOPlus.currentAction);
}
//Called every frame after every other paint
onPaint() {
}
//Called every frame between paint_layer_1 and paint_map_objects_lower_shadows
onPaintObjects() {
}
//Called every frame between paint_ground_items and paint_npcs
onPaintNpcs() {
}
//These are used inside functions instead of being called directly by FMP
additionalMethods() {
//content can be html text or a function that returns html text
FlatMMOPlus.addPanel("id","Title","content");
//Sends messages to game server
FlatMMOPlus.sendMessage("message");
//You can have screen notifications
//FlatMMOPlus.addNotification(notificationName, imageSrc, title, text, ticks, textColor);
FlatMMOPlus.addNotification("test", "https://flatmmo.com/images/ui/hp_med.png", "TEST", "I'm a message", 18000, "blue");
const sheet = new AnimationSheetPlus("name", 5, "", 50, ["url.png","url2.png", "..."])
}
}
const plugin = new SamplePlugin();
FlatMMOPlus.registerPlugin(plugin);
})();