Function Creating
|
10-03-2014, 09:43 PM
Hey,
Okay, I miss the Initialize function. For an example plugin take a look here http://mc-server.xoft.cz/LuaAPI/Writing-...lugin.html Good luck, Seadragon91
10-03-2014, 09:46 PM
Hmmm, I didn't see that for the motd one. Is that one coded into the server itself?
10-03-2014, 09:48 PM
10-03-2014, 09:50 PM
Each plugin needs to have exactly one Initialize function, if you're adding code to an existing plugin, then you shouldn't provide another one, there's already one in the plugin.
The Initialize function is the first thing that the server calls after it loads the plugin.
10-03-2014, 10:02 PM
Thanks for moving it to the appropriate area and I apologize for that. For the color processing code I didn't modify that, maybe that's the issue? Also would the LOG() function need anything to be passed and where could I find syntax (if needed) for it?
10-03-2014, 10:46 PM
No problem.
After reading the color processing over once again, I think it may work, although it's extremely poorly written. The LOG function takes a single string as the argument and outputs the string into the server's console and logfile. Similar with LOGINFO, LOGWARNING and LOGERROR, each used for the appropriate severity of the logged message. They're documented in the API docs in the Globals section: http://mc-server.xoft.cz/LuaAPI/Globals.html#functions Oh wait. Who calls the LoadRules() function? Someone needs to call it once on server initialization - most likely in the Initialize function. Without it, the messages are not initialized so they won't display. Also, you'll need to initialize the Messages variable. As it stands, Lua parses it as "global variable", thus it has the value nil by default, and using it as an (array-)table will crash the plugin. I recommend making as much stuff as possible local: local Rules = {} -- the container for the rules, empty array by default local function ShowRulesTo(Player) ... function HandleRulesCommand(...) -- must be global because it's called from another file ... function LoadRules(...) -- must be global because it's called from another file.
10-04-2014, 12:01 AM
10-04-2014, 12:49 AM
That's because you're reading the text into a global variable Messages which is then overwritten by the motd.lua file. Read the texts into Rules (the one at the top) and display those. This is exactly the reason for making everything local - to avoid silent collisions with other files.
|
« Next Oldest | Next Newest »
|
Users browsing this thread: 1 Guest(s)