Function Creating
#1
Reply
Thanks given by:
#2
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
Reply
Thanks given by:
#3
Hmmm, I didn't see that for the motd one. Is that one coded into the server itself?
Reply
Thanks given by:
#4
Reply
Thanks given by:
#5
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.
Reply
Thanks given by:
#6
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?
Reply
Thanks given by:
#7
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.
Reply
Thanks given by:
#8
Reply
Thanks given by:
#9
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.
Reply
Thanks given by:




Users browsing this thread: 1 Guest(s)