• LuaServer
    467 replies, posted
[QUOTE=Pecius;31189065]You forgot to put error handlers on script loading! Put them both for Java equivalents of lua_pcall and luaL_loadfile/lua_load.[/QUOTE] I dont understand what you mean? Script loading is error handled as are the pcalls and the loadfiles. [editline]18th July 2011[/editline] [QUOTE=Saccn;31189166][lua] function OnScriptStart() Server.AddHook( "player.connect", "OnPlayerConnect" ) end[/lua][/QUOTE] Ah. If you have a look at the wiki at the Server.AddHook function you should notice that with the latest version theres a third parameter. You need to pass the name of your script as a third parameter.
Oh. Now it works.
[QUOTE=Saccn;31189211]Oh. Now it works.[/QUOTE] Glad that it wasnt me screwing up the behind the scenes code. :) Cause that happens quite a lot. :P
[QUOTE=Genesis999;31189189]I dont understand what you mean? Script loading is error handled as are the pcalls and the loadfiles. [/QUOTE] Strange, because it's not printing any errors in console on start when I'm running a code with syntax/runtime errors.
[QUOTE=Pecius;31189300]Strange, because it's not printing any errors in console on start when I'm running a code with syntax/runtime errors.[/QUOTE] What code you trying to run?
[QUOTE=Genesis999;31189311]What code you trying to run?[/QUOTE] Um, any bad code such as [lua]How did I get here I'm not good with computers[/lua] or [lua]string.sub(false, 1, 1)[/lua] It just doesn't give any errors about this.
The console is printing out "[WARNING] LUA: Error at OnPlayerPlaceBlock" when I right click with an empty hand. It's nothing game breaking, but it should be fixed anyway. [editline]18th July 2011[/editline] Also, can you make TeleportTo() not change the angle at which the player is looking at?
Can you make all timers stop when you reload a script without restarting the server? Damn automerge.
Couldn't get it to work, the lib name was supposed to be luajava-1.1.dll, not luajava-1.1-x86.dll When I got it to work, it worked amazingly! Please keep this going, as I believe it has more potential than bukkit!
still hoping for a single player edition
[QUOTE=ruarai;31205404]If you make a SP version allow the clients and servers to communicate both using luaserver and luaclient[/QUOTE] When I do make a SP version that will definitely be on the list of features. :P
Okay my lovely facepunchers. Another day has passed by and at the end of it after much head scratching Ive gone and version up'ped. :) Rewrote the player.placeblock hook code so that it works better and neater. Rewrote the Sql.SelectFromTable function code, now hell easier to get your results. Moved all the global SQL functions inside a global "Sql" object for neatness. Renamed global "PropertyManager" to "Files" to facilitate later updates. Renamed property file functions Reworked the PrintToChat function a little Timers reload when the script reloads Commands require the scriptname being passed in as a third parameter. Note: It'd be best to get a clean minecraft_server.jar as otherwise things could get messy as I have also done some cleaning. :) Second note: In advance for when you curse my name for changing the PrintToChat parameters order around a bit im sorry but i felt it was necessary to make things better. :)
[QUOTE=Genesis999;31207314]Okay my lovely facepunchers. Another day has passed by and at the end of it after much head scratching Ive gone and version up'ped. :)[/QUOTE] I told you to put error handlers BOTH for script loading and script executing functions. You didn't put anything that would receive loader's result and stop from further operations. Right now, when there's a syntax error, user doesn't receive any useful information, only this: [img]http://i51.tinypic.com/20u3nlc.png[/img] [editline]0[/editline] And "attempt to call a string value" message is printed, because loader pushed string with error message at top of the stack.
[QUOTE=Genesis999;31207314]Okay my lovely facepunchers. Another day has passed by and at the end of it after much head scratching Ive gone and version up'ped. :) Rewrote the player.placeblock hook code so that it works better and neater. Rewrote the Sql.SelectFromTable function code, now hell easier to get your results. Moved all the global SQL functions inside a global "Sql" object for neatness. Renamed global "PropertyManager" to "Files" to facilitate later updates. Renamed property file functions Reworked the PrintToChat function a little Timers reload when the script reloads Commands require the scriptname being passed in as a third parameter. Note: It'd be best to get a clean minecraft_server.jar as otherwise things could get messy as I have also done some cleaning. :) Second note: In advance for when you curse my name for changing the PrintToChat parameters order around a bit im sorry but i felt it was necessary to make things better. :)[/QUOTE] Uhm how would I go about running the .jar file as 32bit? (since I'm on 64bit Win7)
I keep getting this [code] [INFO] Starting minecraft server version Beta 1.7.3 [WARNING] **** NOT ENOUGH RAM! [WARNING] To start the server with more ram, launch it as "java -Xmx1024M -Xms1024M -jar minecraft_server.jar" [INFO] Loading properties [INFO] Starting Minecraft server on -ip- [INFO] Preparing level "world" [INFO] Preparing start region for level 0 [INFO] Preparing spawn area: 85% [INFO] Preparing start region for level 1 [INFO] Preparing spawn area: 77% [WARNING] Failed to load script: Admin. [INFO] Done (2337317033ns)! For help, type "help" or "?" [/code] I even reverted back to a working version and I'm still getting this.
Did you not get my PM, Genesis? I'd PM you on the mincraft forums, but it's not letting me create an account. I made an account before they switched to Curse, and now it says my email is in use, but when I try to log on using my old account details, it says that logon doesn't exist.
[QUOTE=Divran;31210844]Did you not get my PM, Genesis? I'd PM you on the mincraft forums, but it's not letting me create an account. I made an account before they switched to Curse, and now it says my email is in use, but when I try to log on using my old account details, it says that logon doesn't exist.[/QUOTE] I got your PM, you just sent it when Id gone to bed. :P
how do i make a script that kills creepers when they spawn
Now I keep getting disconnected from the server when I right click with an empty hand. [code] [WARNING] Failed to handle packet: java.lang.NullPointerException java.lang.NullPointerException at ha.a(NetServerHandler.java:372) at eo.a(SourceFile:57) at jl.b(SourceFile:279) at ha.a(NetServerHandler.java:49) at cu.a(SourceFile:105) at net.minecraft.server.MinecraftServer.h(MinecraftServer.java:400) at net.minecraft.server.MinecraftServer.run(MinecraftServer.java:303) at bq.run(SourceFile:422) [/code] And the client is getting "Internal server error"
[QUOTE=Saccn;31224150]Now I keep getting disconnected from the server when I right click with an empty hand. [code] [WARNING] Failed to handle packet: java.lang.NullPointerException java.lang.NullPointerException at ha.a(NetServerHandler.java:372) at eo.a(SourceFile:57) at jl.b(SourceFile:279) at ha.a(NetServerHandler.java:49) at cu.a(SourceFile:105) at net.minecraft.server.MinecraftServer.h(MinecraftServer.java:400) at net.minecraft.server.MinecraftServer.run(MinecraftServer.java:303) at bq.run(SourceFile:422) [/code] And the client is getting "Internal server error"[/QUOTE] Mmm. Bugs. I threw up a new version that fixes that and some more little changes.
Why is the console always writing "[WARNING] LUA: Error handling command." when I enter a command? The command executes properly, so I don't see what's the problem.
[QUOTE=Saccn;31224837]Why is the console always writing "[WARNING] LUA: Error handling command." when I enter a command? The command executes properly, so I don't see what's the problem.[/QUOTE] Is this from the console that its doing that? EDIT: Also I should mention that along with the fix of the place block thing i also changed a lot of the objects GetUser to return a player object and added a GetUsername to return just the name.
Client and console.
[QUOTE=Saccn;31224926]Client and console.[/QUOTE] Ive just been experimenting. It seems that if you dont use Command:SetReturn(255) that it says there was an error. :S weird
Discussing vectors [code]12:55 - Divran: you should remove GetPositionX, GetPositionY, and GetPositionZ 12:55 - Divran: and replace it with GetPos or GetPosition 12:56 - Divran: which would return a table looking either like this {x,y,z} (number indexes) or like this {x=x,y=y,z=z} (string indexes) 12:56 - Divran: and then make SetPosition accept that table (Or 3 numbers, too, maybe) 12:56 - Divran: Or you could even make a Vector class 12:57 - thegenesis999: Yea. Im going to bunch them up some way soon. 12:57 - Divran: a vector class would be very useful if you gave it functions such as rotate [/code] Discussing the use of classes all over the place [code]01:03 - Divran: this one thing I noticed that was really strange 01:03 - Divran: SetReturn(255) whats up with that 01:04 - Divran: the command hook should just send player, rawtext, table with exploded text 01:04 - Divran: as its arguments 01:04 - Divran: no need to use an entire class to do it 01:04 - Divran: Same thing with the chat hook 01:05 - thegenesis999: Yea. Using a class for it does simplify some things though. 01:05 - Divran: what things 01:06 - thegenesis999: well... 01:07 - thegenesis999: the backcode for one[/code] Discussing the removal of RegisterCommand & the adding of the command hook [code]01:07 - Divran: Why do you have a function called RegisterCommand when you already have a command hook 01:08 - thegenesis999: what do you mean? 01:08 - Divran: you only need the hook 01:08 - Divran: oh wait 01:08 - Divran: you removed the command hook 01:09 - thegenesis999: by command hook do you mean the CommandHandler function? 01:09 - Divran: yes 01:09 - Divran: you dont have functions for that anymore 01:09 - Divran: remember 01:09 - thegenesis999: Yea i removed that. :P 01:09 - Divran: you use hooks now 01:09 - Divran: so I call it hooks 01:10 - Divran: why do you not use your hook system, then? 01:10 - Divran: its perfect for this 01:10 - thegenesis999: hold on. ive lost track of what this is. 01:10 - Divran: a command hook called whenever anyone types /something 01:11 - Divran: actually you could just as easily use the chat hook for it 01:11 - thegenesis999: i like the seperation of commands from hooks. it feels neater. 01:11 - Divran: but then it wouldnt work if the console types /something 01:11 - Divran: no it doesnt 01:12 - thegenesis999: well it does for me. 01:12 - Divran: then you have to spam RegisterCommand 01:12 - thegenesis999: :) 01:12 - Divran: if I were to make an admin mod 01:12 - Divran: I would now be forced to spam RegisterCommands which all called the same function 01:12 - Divran: just to make it work like hooks 01:13 - Divran: because otherwise my Lua code would be ugly as fuck 01:13 - Divran: because I would store my command functions in a table 01:13 - Divran: Wait 01:13 - Divran: let me explain how Id do it 01:13 - Divran: First I would make a table to store all the commands 01:14 - thegenesis999: so im guessing you feel one big function is better than a lot of little ones? 01:14 - Divran: Then I would store each command similar to this Commands = {} Commands["tp"] = { Allowed = { "op", "admin", "superadmin", "whatever other rank" }, Function = function() something end } 01:14 - Divran: And then I would need a hook to check if that command existed in the table 01:15 - Divran: And compare ranks to see if the user is allowed to use it 01:15 - Divran: else print error 01:15 - Divran: 01:14 - thegenesis999: so im guessing you feel one big function is better than a lot of little ones? Yes. 01:15 - thegenesis999: mmk 01:16 - Divran: because 99.99% of the times, when making commands such as this, you want to make the exact same comparisons for every single command 01:16 - Divran: before running its unique function 01:16 - Divran: such as allowances 01:16 - Divran: and maybe if the owner of the server disabled it 01:16 - Divran: if your mod supports command disabling 01:16 - Divran: the list goes on 01:18 - thegenesis999: hmmm 01:21 - Divran: going to post some of our discussion on FP 01:21 - thegenesis999: ok then 01:22 - thegenesis999: so you want something like the old command hook back? 01:22 - Divran: yep [/code] What do you guys think?
[QUOTE=Divran;31225528]What do you guys think?[/QUOTE] I can just agree, the whole project started nice and small but right now it's kind of messy. I was even thinking of writing a wrapper class to make the lua part act like it does in GMod.. €dit: Like this: [QUOTE=Genesis999;31224896]Also I should mention that along with the fix of the place block thing i also changed a lot of the objects GetUser to return a player object and added a GetUsername to return just the name.[/QUOTE] [lua]-- i'm assuming that you did this... GetUser() GetUsername() -- ... so why create another global function when you can do this instead (player obj):GetName() [/lua]
[QUOTE=The-Stone;31226192]I can just agree, the whole project started nice and small but right now it's kind of messy. I was even thinking of writing a wrapper class to make the lua part act like it does in GMod.. €dit: Like this: [lua]-- i'm assuming that you did this... GetUser() GetUsername() -- ... so why create another global function when you can do this instead (player obj):GetName() [/lua][/QUOTE] The getuser and getusername functions arent global functions. In fact there are only two global functions ( PrintToChat and PrintToConsole) and three global variables(Server, Files and Sql).
I can't get Chat:GetName() to work anymore. [lua] function OnScriptStart() Server.AddHook( "game.chat", "OnPlayerChat", "Test" ) end function OnPlayerChat( Chat ) PrintToChat( Chat:GetName()..": "..Chat:GetMessage(), 15, "#all" ) Chat:SetReturn( 255 ) end [/lua] This works if I take it out. [b]Edit:[/b] Nevermind. Found out how to make this work.
[QUOTE=The-Stone;31087749][lua] function file.Find() fh = io.popen("dir") local dir = fh:read("*a") local tbl = string.Explode(dir, "\n") local files = {} for k, line in pairs(tbl) do if line:match("[%d%p]%s([%w%p]+)") then table.insert(files, line:match("[%d%p]%s([%w%p]+)")) end end table.remove(files, #files) table.remove(files, #files) return files end [/lua] [code] > table.Print(file.Find()) 1 = file.lua 2 = lua.exe 3 = lua5.1.dll 4 = math.lua 5 = string.lua 6 = table.lua [/code] Played a little with standard Lua today.. :P[/QUOTE] Thanks, but that doesn't work. io.popen returns nil no matter what file path I give it.
[QUOTE=Divran;31230989]Thanks, but that doesn't work. io.popen returns nil no matter what file path I give it.[/QUOTE] That'd could be because in the latest version I dont make the call to open the io.
Sorry, you need to Log In to post a reply to this thread.