· 8 years ago · Mar 04, 2018, 10:52 PM
1
2<?xml version="1.0" encoding="iso-8859-1"?>
3<!DOCTYPE muclient>
4<!-- Saved on dimanche, mars 04, 2018, 10:01 -->
5<!-- MuClient version 5.06-pre -->
6
7<!-- Plugin "RoomsAndMobs" generated by Plugin Wizard -->
8
9<muclient>
10<plugin
11 name="RoomsAndMobs"
12 id="acb4277943a45b208163d8f5"
13 language="Lua"
14 date_written="2018-03-04 21:59:53"
15 requires="5.06"
16 version="1.0"
17 >
18
19</plugin>
20
21
22<!-- Get our standard constants -->
23
24<include name="constants.lua"/>
25
26<!-- Script -->
27
28
29<script>
30<![CDATA[
31require "tprint"
32require "gmcphelper" -- adds the gmcp() function for simplifying data access
33
34DatabaseOpen ("db", GetInfo (66) .. "RoomsMobsDB.sqlite", 6)
35
36rc = DatabaseExec ("db", [[
37-- DROP TABLE IF EXISTS RoomsMobs;
38CREATE TABLE IF NOT EXISTS RoomsMobs (
39 RoomsMobs_id INTEGER NOT NULL PRIMARY KEY autoincrement NOT NULL,
40 Room_uid TEXT NOT NULL,
41 Mob_desc TEXT NOT NULL,
42 Mob_con TEXT NOT NULL,
43 RM_DateTime DATETIME NOT NULL DEFAULT (DATETIME ('now', 'localtime'))
44 );
45 ]])
46
47
48 DatabaseExec ("db",
49 [[
50 INSERT INTO RoomsMobs ( Room_uid, Mob_desc, Mob_con ) VALUES (000,'zero', 'grosminet');
51 ]])
52
53
54-- prepare a query
55DatabasePrepare ("db", "SELECT * from RoomsMobs ORDER BY Mob_desc")
56
57-- find the column names
58names = DatabaseColumnNames ("db")
59tprint (names)
60
61-- execute to get the first row
62rc = DatabaseStep ("db") -- read first row
63
64-- now loop, displaying each row, and getting the next one
65
66 print ("")
67 values = DatabaseColumnValues ("db")
68 tprint (values)
69-- finished with the statement
70DatabaseFinalize ("db")
71
72DatabaseClose ("db") -- close it
73
74
75function OnPluginBroadcast(msg, id, name, text)
76 if id == "3e7dedbe37e44942dd46d264" then -- message from the GMCP Handler
77 if (text == "room.info") then -- the GMCP Handler plugin says "I got a new room.info!"
78 print("id v 0.10")
79 print(id)
80 print("text")
81 print(text)
82 roominfo = gmcp("room.info")
83 roomnum= roominfo.num
84 roomnum= "'" .. roomnum .. "'"
85 print(roomnum)
86 -- put some data into the database
87 DatabaseOpen ("db", GetInfo (66) .. "RoomsMobsDB.sqlite", 6)
88 DatabaseExec ("db",
89 [[
90 INSERT INTO RoomsMobs ( Room_uid, Mob_desc, Mob_con ) VALUES (roomnum,'Ugly mob v0.10', 'U mob');
91 ]])
92 DatabaseExec ("db",
93 [[
94 INSERT INTO RoomsMobs ( Room_uid, Mob_desc, Mob_con ) VALUES ("'" .. roominfo.num .. "'",'Ugly mob', 'U mob');
95 ]])
96
97 DatabaseExec ("db",
98 [[
99 INSERT INTO RoomsMobs ( Room_uid, Mob_desc, Mob_con ) VALUES (999,'titi V0.10', 'grosminet');
100 ]])
101
102
103 DatabaseFinalize ("db")
104 DatabaseClose ("db")
105 end
106 end
107end
108
109
110function OnPluginInstall()
111 print("You've installed the Room Mob plugin.")
112end
113
114
115]]>
116</script>
117
118
119</muclient>