It still lacks basic features for hooks that are already added in. I mean, I don't even know how to get the block's material type ID (wood/sand, etc.) First add easy-to-use (or replace existing) functions to create/break/place blocks and other stuff. Nevertheless, if you keep it up, I'm sure it will become a Bukkit alternative.
[code][INFO] Testing hooks...
[INFO] Failed to hook 'game.tick'! (java.lang.NullPointerException)
[INFO] Failed to hook 'game.chat'! (java.lang.NullPointerException)
[INFO] Failed to hook 'player.disconnect'! (java.lang.NullPointerException)
[INFO] Failed to hook 'player.connect'! (java.lang.NullPointerException)
[INFO] Failed to hook 'player.breakblock'! (java.lang.NullPointerException)
[INFO] Failed to hook 'player.digblock'! (java.lang.NullPointerException)
[INFO] Failed to hook 'player.dropblock'! (java.lang.NullPointerException)
[INFO] Failed to hook 'player.placeblock'! (java.lang.NullPointerException)
[INFO] Failed to hook 'player.death'! (java.lang.NullPointerException)
[INFO] Failed to hook 'player.itempickup'! (java.lang.NullPointerException)
[INFO] Failed to hook 'player.useitem'! (java.lang.NullPointerException)
[INFO] Failed to hook 'player.placesign'! (java.lang.NullPointerException)
[INFO] Failed to hook 'player.respawn'! (java.lang.NullPointerException)
[INFO] Failed to hook 'mob.death'! (java.lang.NullPointerException)[/code]
[lua]print( "Testing hooks..." )
local hooks = {
"game.tick", "game.chat",
"player.disconnect", "player.connect", "player.breakblock", "player.digblock", "player.dropblock", "player.placeblock",
"player.death", "player.itempickup", "player.useitem", "player.placesign", "player.respawn", "mob.death" }
local function Dummy() end
for _, name in pairs( hooks ) do
local b, res = pcall( Hooks.Add, name, "dummyhook", Dummy )
if (not b) then
print( "Failed to hook '" .. name .. "'! (" .. res .. ")" )
else
print( "Hooked '" .. name .. "' successfully." )
end
end[/lua]
Hmm...
[editline]15th August 2011[/editline]
Nevermind I had the file in the wrong place.
For some reason setting userdata gives an error "cannot set DiamondDelay userdata", where DiamondDelay is the userdata I want to set.
Also, you should add in a function (or modify AddItem) that would check if an item is stackable, and add the item to a stack if possible or add to another slot.
Oh, and, please add the block entity in the player.digblock hook.
[lua]function DIAMONDS(ply, block, face)
print(block.Id)
local maxnum = 50 + block.Y
print(maxnum)
local RandChance = math.random(1, maxnum) -- the deeper we are - the higher the chance that we will get a diamond
if block.Id == 12 then -- sand, for now.
if RandChance <= 10 then
ply:GetInventory():AddItem(264, 1)
Server.Chat("You found a diamond after digging through the sand!", 2, ply)
end
print(RandChance)
end
end
Hooks.Add("player.breakblock", "DIAMONDS", DIAMONDS)[/lua]
:D
P.S. You should also add a function that drops an item. Something like CreateItem(x, y, z, ItemID)
Very interesting, but it's very buggy.
[lua]player = {}
function player.GetAll()
return Server.GetPlayers( "#all" )
end
function player.FindByName( name )
local name = string.lower( name )
for _,v in pairs( player.GetAll() ) do
if v ~= NULL then
local username = string.lower( v:GetUsername() ) -- This line will error no matter what, and found that using any method on the player will error too
if string.find( username, name, 1, true ) or username == name then
return v
end
end
end
return NULL
end
local target = player.FindByName( "someone" )[/lua]
When I loop though all the players, it errors whenever I try to run a method on the player in the loop no matter what. It also results in other random errors that have nothing to do with the actual error.
Example.
[code]2011-08-16 21:36:45 [LUA] lua/JAdmin/JAdmin.lua:17: vm error: java.lang.NullPointerException
2011-08-16 21:36:45 [INFO] blackops7799 issued server command: bring jet
2011-08-16 21:36:45 [LUA] Error running function.
2011-08-16 21:36:45 [LUA] lua/JAdmin-Commands/JAdmin-Commands.lua:101: attempt to index ? (a nil value)[/code]
Line 17 is
[lua]local username = string.lower( v:GetUsername() )[/lua]
Line 101 is
[lua]if ply:IsOp() then[/lua]
of
[lua]chatcommand.Add("bring", function(ply, cmd, args)
if ply:IsOp() then
if args[2] then
local target = player.FindByName( args[2] ) -- this errors first, but causes the first line, "if ply:IsOp() then", to error also.
if target == NULL then
ply:Print("Player name not found")
else
player.SetPos(target, player.GetPos(ply))
end
else
ply:Print( string.format( "/%s <name>", cmd ) )
end
end
end)[/lua]
What the fuck?
For now I circumvent this by using
[lua]local target = Server.GetPlayer( args[2] )[/lua]
But I hate having to type their whole name out.
ply:IsOp()
Why you so error on us?
Make sure your using the wiki at [url]http://wiki.luaserver.org[/url] because the other wiki is no longer kept up to date.
[QUOTE=Genesis999;31779189]Make sure your using the wiki at [url]http://wiki.luaserver.org[/url] because the other wiki is no longer kept up to date.[/QUOTE]
Doesn't fix the fact that there's lots of bugs. :/
As of build 20 I am aware of maybe 3 or 4 bugs in my code. Anything else is due to your script having errors.
[QUOTE=Genesis999;31780222]As of build 20 I am aware of maybe 3 or 4 bugs in my code. Anything else is due to your script having errors.[/QUOTE]
Is the "cannot set userdata SomeVar" a bug? Oh, and, are you going to add in those functions I suggested?
[QUOTE=LEETNOOB;31780263]Is the "cannot set userdata SomeVar" a bug? Oh, and, are you going to add in those functions I suggested?[/QUOTE]
Yes that is one of them. And yes im adding some of the functions you suggested.
[QUOTE=Genesis999;31779189]Make sure your using the wiki at [url]http://wiki.luaserver.org[/url] because the other wiki is no longer kept up to date.[/QUOTE]
My code is fine. I even added mass amount of prints to make sure I wasn't going insane. There's some odd shit happening for almost no reason. Also, the documentation is pretty much useless or incomplete.
[url]http://www.breakpointservers.com/blackops/luaminecraft.rar[/url]
Here's my current code. In JAdmin-Commands I am currently using my custom find player thing which will just refuse to work because while looping through the players, it seems to think the player class has no methods to it at all.
[lua]
for _,v in pairs( Server.GetPlayers( "#all" ) ) do
if v ~= NULL then
v:Print( "This will not print because it will error for no reason" )
end
end
[/lua]
That's the most simple example I can show. I really like where this LuaServer is going, I'm just trying to help.
[QUOTE=BlackAwps;31782278]My code is fine. I even added mass amount of prints to make sure I wasn't going insane. There's some odd shit happening for almost no reason. Also, the documentation is pretty much useless or incomplete.
[url]http://www.breakpointservers.com/blackops/luaminecraft.rar[/url]
Here's my current code. In JAdmin-Commands I am currently using my custom find player thing which will just refuse to work because while looping through the players, it seems to think the player class has no methods to it at all.
[lua]
for _,v in pairs( Server.GetPlayers( "#all" ) ) do
if v ~= NULL then
v:Print( "This will not print because it will error for no reason" )
end
end
[/lua]
That's the most simple example I can show. I really like where this LuaServer is going, I'm just trying to help.[/QUOTE]
Dont pull your hair out I made a mistake. Sorry about that. ( its only the 20th build atm its still got a long way to go before its near perfect ).
Although I should mention that when I looked at your scripts you were using things like Player:GetUsername() which if you look at the wiki on the Player page you would see that the username is accessed through Player.Username. ( make sure your using the new wiki )
[QUOTE=Genesis999;31781207]Yes that is one of them. And yes im adding some of the functions you suggested.[/QUOTE]
Yay! Thanks a lot! I am definitely migrating from Bukkit to this!
Hmm... Build 21
== Changelog ==
Fixed Server.GetPlayers("#all")
Player X Y and Z values update.
"game.command" hook now only handles console commands.
Added "player.command" hook for player commands.
Players in game can no longer access the default console commands.
Added a lever object.
Added a door object.
Added a World:GetLever() function.
Added a World:GetDoor() function.
Added a World:SpawnTNT() function.
Added a World:SpawnItem() function.
Added a World:SpawnFallingBlock() function.
Added lever.toggle hook ( cancellable )
Added door.toggle hook. ( cancellable )
Added button.toggle hook. ( cancellable )
Added chest.open hook ( cancellable )
Added dispenser.open hook ( cancellable )
Added furnace.open hook ( cancellable )
Added workbench.open hook ( cancellable )
Added tnt.prime hook ( cancellable )
Added bed.use hook ( cancellable )
Added cake.activate hook ( cancellable )
Added sign.activate hook.
[QUOTE=Genesis999;31783889][b]Added a World:SpawnItem() function.[/b][/QUOTE]
Fuck yeah! By the way, did you fix the userdata bug?
Could you post an example on how to use SpawnItem()? I'm doing this
[lua]SpawnItem(block.X, block.Y, block.Z, 264, 1)[/lua]
And it gives me "attempt to call nil".
[lua][INFO] lua/RandomShitScript/RandomShitScript.lua:6: cannot set asdpenis for userdata[/lua]
Oh for fuck's sake.
I downloaded the newest version and the default commands doesnt work anymore. I tried to say "/time set 0" and nothing happened.
Figured out what was wrong with SpawnItem. Userdata's still broken, though.
[QUOTE=Funley;31786090]I downloaded the newest version and the default commands doesnt work anymore. I tried to say "/time set 0" and nothing happened.[/QUOTE]
Type it directly into the server console. Build 21 stops you being able to use op commands from the client.
[editline]17th August 2011[/editline]
Released a plugin called SvFrame. Read about it [url=http://forums.luaserver.org/showthread.php?tid=13]here[/url].
[QUOTE=thomasfn;31787931]Type it directly into the server console. Build 21 stops you being able to use op commands from the client.
[editline]17th August 2011[/editline]
Released a plugin called SvFrame. Read about it [url=http://forums.luaserver.org/showthread.php?tid=13]here[/url].[/QUOTE]
I posted there but i'll say it again, good job.
Funley if you read the changelof you'll see that that is intentional. Players can no longer access the default console commands.
And Leetnoob player userdata is not so
Much broken rather it's just not supported yet.
Ah. In that case, could you add in a hook that would get called when a block is destroyed/removed? Not player.breakblock, but another hook, like, block.remove or block.destroyed or something like that.
P.S. I tried registering on your forum, but I didn't receive the verification email, and it's been around half an hour since I registered. Could you manually send it? My nickname there is "LEETNOOB".
[QUOTE=Genesis999;31792460]Funley if you read the changelof you'll see that that is intentional. Players can no longer access the default console commands.
And Leetnoob player userdata is not so
Much broken rather it's just not supported yet.[/QUOTE] Well then, must get to coding of my own time setting!
Released my first plugin! Basically, a plugin that adds additional drops to 5 types of blocks, at the moment.
You can read about it here:
[url]http://forums.luaserver.org/showthread.php?tid=20[/url]
Hey there people.
Ive setup a minecraft server on the luaserver.org site.
Come have a look. Nothing spectacular in the way of scripts yet but ill be adding to it as I go.
see below
[QUOTE=Nemesis036;31841213][url]http://pastie.org/2401478[/url]
Can anyone tell me what I'm doing wrong here?[/QUOTE]
You haven't told us what the error is, but I think it goes att:GetType() rather than GetType( att ).
My bad, ive already done that, this is my current code
[code]
function PlayerDeath( ply, att )
if att:GetType() == "fall" then
Server.Chat( ply.Username .. " fell to his death.", 12, "#all" )
elseif att:GetType() == "fire" then
Server.Chat( ply.Username .. " burned to death in a fire.", 12, "#all" )
elseif att:GetType() == "water" then
Server.Chat( ply.Username .. " is sleeping with the fishies.", 12, "#all" )
elseif att:GetType() == "lava" then
Server.Chat( ply.Username .. " fell into lava and died.", 12, "#all" )
elseif att:GetType() == "player" then
Server.Chat( ply.Username .. " was killed in pvp by " .. att.Username .. ".", 12, "#all" )
else
Server.Chat( ply.Username .. " was killed by a " .. att:GetType() .. ".", 12, "#all" )
end
end
Hooks.Add("player.death", "Player Death Message", PlayerDeath)
[/code]
[code]
[INFO] lua/SimpleAdmin/SimpleAdmin.lua:2: attempt to call nil
[/code]
[QUOTE=Nemesis036;31842498]My bad, ive already done that, this is my current code
[code]
function PlayerDeath( ply, att )
if att:GetType() == "fall" then
Server.Chat( ply.Username .. " fell to his death.", 12, "#all" )
elseif att:GetType() == "fire" then
Server.Chat( ply.Username .. " burned to death in a fire.", 12, "#all" )
elseif att:GetType() == "water" then
Server.Chat( ply.Username .. " is sleeping with the fishies.", 12, "#all" )
elseif att:GetType() == "lava" then
Server.Chat( ply.Username .. " fell into lava and died.", 12, "#all" )
elseif att:GetType() == "player" then
Server.Chat( ply.Username .. " was killed in pvp by " .. att.Username .. ".", 12, "#all" )
else
Server.Chat( ply.Username .. " was killed by a " .. att:GetType() .. ".", 12, "#all" )
end
end
Hooks.Add("player.death", "Player Death Message", PlayerDeath)
[/code]
[code]
[INFO] lua/SimpleAdmin/SimpleAdmin.lua:2: attempt to call nil
[/code][/QUOTE]
Thats my bad for missing something in the wiki that needed to be updated.
You can get the type by using the Type parameter instead of GetType()
Eg:
<code>if att.Type == "creeper" then</code>
[QUOTE=Genesis999;31842646]Thats my bad for missing something in the wiki that needed to be updated.
You can get the type by using the Type parameter instead of GetType()
Eg:
<code>if att.Type == "creeper" then</code>[/QUOTE]
Perfect, thank you.
[code]
block:SetId()
[/code]
seems to be doing the same thing, is that me being stupid?
[code]
function SuperPickaxe( ply, block, face )
if ply:IsOp() and ply:GetHeldItem() == 278 then
block:SetId(0)
end
end
[/code]
[editline]20th August 2011[/editline]
also theres no "type" for sufforcation
[code]
world:SpawnMob(mob id, ply.X, ply.Y, ply.Z)
[/code]
what is the "mob id"
-it seems I broke automerge-
Sorry, you need to Log In to post a reply to this thread.