[lua]chatcommand.Add( "give", function( ply, cmd, args )
if ply:IspP() then
if args[1] then
local target = player.GetByName( args[1] )
if target ~= nil then
local id = item[ args[2] ] or tile[ args[2] ] or tonumber( args[2] )
local stack = Item( id, args[3], args[4] )
if ply ~= target then
ply:Msg( color.White, "You gave", color.LightBlue, " " .. stack:GetSize(), color.White, " of ", color.Red, stack:GetName(), color.White, " to ", color.Green, target:Name() )
target:Msg( color.White, "You recieved", color.LightBlue, " " .. stack:GetSize(), color.White, " of ", color.Red, stack:GetName(), color.White, " from ", color.Green, ply:Name() )
else
ply:Msg( color.White, "You recieved", color.LightBlue, " " .. stack:GetSize(), color.White, " of ", color.Red, stack:GetName() )
end
target:GetContainer():Give( stack )
else
ply:Msg( "Player not found" )
end
else
ply:Msg( string.format( "/%s <name> <item> [amount]", cmd ) )
end
end
end )[/lua]
I get a "rawget not implemented for nil" error.
[lua]hook.Add("console.command", "hook", function(args,cmd)
if args[1]=="give" then
local player=Player("evan2013")
local stack = Item(tonumber(args[2]),tonumber(args[3]),tonumber(args[4]))
player:GetContainer():Give(stack)
end
end)[/lua]
[QUOTE=SomeFaggot;34568433]I get a "rawget not implemented for nil" error.[/QUOTE]
We found the issue and fixed it. We have a little work to do before the next update but it should be there in a few days!
I fixed this. Our _R.Container meta table was never getting created on the client.
[editline]6th February 2012[/editline]
:ninja:
Can anybody explain in brief how I could use the NBTTag related stuff?
Any news on the next release?
[url=forum.luacraft.com]Check the addons section on their forum[/url]
[QUOTE=SomeFaggot;34641740]Any news on the next release?[/QUOTE]
I was working the last couple of days but I've got 3 free ones ahead. I should get a nice update out.
[QUOTE=LuaStoned;34662195]I was working the last couple of days but I've got 3 free ones ahead. I should get a nice update out.[/QUOTE]
I'm back Wednesday, have you done much on the addon central?
The only thing we did was include the changes that the HD Texture patcher does.
I've changed some of the base code, the fps counter won't impact performance and will actually count the real fps. We've also fixed tons of null pointers and other tiny optimisations.
Bit of a bump but, if installed Serverside is it required for client's to have it for them to be able to join? I love this so much, because I don't know heck all about Javascript but I know quite a bit about Lua!
[QUOTE=MattJeanes;34789424]Bit of a bump but, if installed Serverside is it required for client's to have it for them to be able to join? I love this so much, because I don't know heck all about Javascript but I know quite a bit about Lua![/QUOTE]
No, you can mix LuaCraft (Client and Server) with Minecraft as long as it is v1.1
Any news on the next release?
So I'm basically loving this server - it's really easy to set up, the lua integrates really well, and it's pretty identical to garrysmod lua. The two questions I'm having at the moment for this are
1) what ARE some of the objects? This is probably because I've never modded minecraft and I'm not too familiar with the structures, but I have no idea what an NBTTag is, and the propertymanager seems to just be for storing key value structures in files - is that all?
2) Is the wiki still being added to and are there more functions than are listed? For example the only GUI function listed is to create an empty panel, and the player contains a get dimension/world but no way to set it.
also if there's any way I can contribute to this I'd donate any time I could (even if it's just editing the wiki) - I've got more than 11 years of C++ behind me and quite a bit of lua - but unfortunately no java.
[QUOTE=Elspin;34813765]1) what ARE some of the objects? This is probably because I've never modded minecraft and I'm not too familiar with the structures, but I have no idea what an NBTTag is, and the propertymanager seems to just be for storing key value structures in files - is that all?[/QUOTE]
Yeah, propertymanager is what is used for the server.properties file. Pretty much a key->value structure for files. I THINK NBTags are like NWString/Int/Bools in garrysmod, but I'm not 100% sure on that.
[QUOTE=Elspin;34813765]2) Is the wiki still being added to and are there more functions than are listed? For example the only GUI function listed is to create an empty panel, and the player contains a get dimension/world but no way to set it.[/QUOTE]
Yeah, we are a bit lacking with filling in the wiki. For the most part we parse all of our java files to automatically create some of the wiki pages, so all methods/class pages should be 100% up to date.
There is a Player:SetDimension()
[lua]chatcommand.Add( "goto", function( ply, cmd, args )
if ply:IsOp() then
if args[1] then
local target = player.GetByName( args[1] )
if target ~= nil then
ply:SetDimension( target:Dimension() ) -- :D
ply:SetPos( target:GetPos() )
else
ply:Msg( "Player not found" )
end
else
ply:Msg( string.format( "/%s <name>", cmd ) )
end
end
end )[/lua]
Also, here's a GUI example.
[lua]hook.Add( "client.initialize", "Create Test Window", function()
local panel = gui.Create("Panel")
function panel:Init()
local testBut = gui.Create("Button",panel)
testBut:SetPos( ScrW() / 2 - testBut:GetWide() / 2, ScrH() / 2 + testBut:GetTall() )
testBut:SetText( "This is a test button" )
function testBut:Paint()
end
function testBut:MousePressed( x, y )
end
function testBut:MouseReleased( x, y )
panel:Remove()
end
local testSlider = gui.Create("Slider",panel)
testSlider:SetPos( ScrW() / 2 - testSlider:GetWide() / 2, ScrH() / 2 + testSlider:GetTall() * 2 + 4 )
testSlider:SetText( "This is a test slider" )
function testSlider:Paint()
end
function testSlider:MousePressed( x, y )
print( self, "MousePressed", x, y )
end
function testSlider:MouseReleased( x, y )
print( self, "MouseReleased", x, y )
end
function testSlider:ValueChanged( v )
print( self, "ValueChanged", v )
end
end
function panel:Paint()
surface.SetDrawColor( color_black )
surface.DrawRect( 0, 0, ScrW(), ScrH() )
surface.SetDrawColor( color_white )
local message = "This is a black screen panel thing"
local w,h = font:GetTextSize( message )
font:DrawTextShadow( message, ScrW() / 2 - w / 2, ScrH() / 2 )
end
function panel:keyTyped( a, b )
end
function panel:MouseClicked( a, b, c )
end
panel:MakePopup()
end )[/lua]
[QUOTE=Elspin;34813765]also if there's any way I can contribute to this I'd donate any time I could (even if it's just editing the wiki) - I've got more than 11 years of C++ behind me and quite a bit of lua - but unfortunately no java.[/QUOTE]
We are always looking for people to help. Just contact Stoned about it. I didn't know anything about java when I first joined, but my knowledge in other areas allowed me to get used to it quickly.
NBT is a binary file format for storing data.
[url]http://www.wiki.vg/NBT[/url]
(NBTTag is redundant, since NBT stands for Named Binary Tag)
[QUOTE=raBBish;34843720]NBT is a binary file format for storing data.
[url]http://www.wiki.vg/NBT[/url]
(NBTTag is redundant, since NBT stands for Named Binary Tag)[/QUOTE]
Thanks for the info, only problem is the constructor info is missing.
May be a bug here but I'm not sure - I moved some definitely repeatably working code into an addon format, and it is no longer working. It confirms on startup and reloadlua that it is loaded, but none of the code is run (hooks not printing etc), no errors are posted.
Also - is there any way to create support for parallel running worlds like in the bukkit waypoint mod?
NBT is metadata per object from what I was told, so you could have books contain different text that the user set, for example, if I understand it correctly.
I think it was added when I asked irZilla for metatable persistence on items so I could do something like item.NextRepair = blah + meh, and got this instead which seems a lot more powerful.
[QUOTE=Kogitsune;34861936]I think it was added when I asked irZilla for metatable persistence on items so I could do something like item.NextRepair = blah + meh, and got this instead which seems a lot more powerful.[/QUOTE]
However, it's not currently setup on all entities. ( I think it only works on entities of the Item class. )
[QUOTE=Kogitsune;34861936]NBT is metadata per object from what I was told, so you could have books contain different text that the user set, for example, if I understand it correctly.
I think it was added when I asked irZilla for metatable persistence on items so I could do something like item.NextRepair = blah + meh, and got this instead which seems a lot more powerful.[/QUOTE]
Ah, so will the NBT object be pre-attached to the item? I was wondering about things like adding persistent affects to blocks and items, and it's good to know that there's at least a way for it already on items. I suppose blocks could be tracked by position, and checking when a block is destroyed could note that the block at that position is no longer the same block.
[QUOTE=Elspin;34860112]Thanks for the info, only problem is the constructor info is missing.
May be a bug here but I'm not sure - I moved some definitely repeatably working code into an addon format, and it is no longer working. It confirms on startup and reloadlua that it is loaded, but none of the code is run (hooks not printing etc), no errors are posted.
Also - is there any way to create support for parallel running worlds like in the bukkit waypoint mod?[/QUOTE]
That book thing is exactly what I want to do.
I actually have a problem with the include function.
Here is my code for init.lua :
[CODE]include("commands.lua")
hook.Add("console.command", "OnConsoleCommand", DoConCommand( args, cmd ) )[/CODE]
And for commands.lua :
[CODE]include("init.lua")
function DoConCommand( args, cmd )
local command = args[1]
if command == "help+" then
print("Console+ Help")
print("----------------------------")
Warning("help+ - Shows this menu")
elseif command == "ExplodeEnt" then
for k,v in pairs(ents.GetByClass(args[2])) do
Explosion(v:GetPos(), args[3])
end
end
end[/CODE]
And it gives me two errors, both the same :
[CODE]addons/Console+/lua/commands.lua:1: vm error: java.lang.ArrayIndexOutOfBoundsException : 256[/CODE]
Anyone has an idea why ?
[QUOTE=Fleskhjerta;34952129]I actually have a problem with the include function.
Here is my code for init.lua :
[CODE]include("commands.lua")
hook.Add("console.command", "OnConsoleCommand", DoConCommand( args, cmd ) )[/CODE]
And for commands.lua :
[CODE]include("init.lua")
function DoConCommand( args, cmd )
local command = args[1]
if command == "help+" then
print("Console+ Help")
print("----------------------------")
Warning("help+ - Shows this menu")
elseif command == "ExplodeEnt" then
for k,v in pairs(ents.GetByClass(args[2])) do
Explosion(v:GetPos(), args[3])
end
end
end[/CODE]
And it gives me two errors, both the same :
[CODE]addons/Console+/lua/commands.lua:1: vm error: java.lang.ArrayIndexOutOfBoundsException : 256[/CODE]
Anyone has an idea why ?[/QUOTE]
...you're telling each file to include each other, where will that stop? This is what you're doing to the script essentially:
>including "commands.lua" into "init.lua"
>including "init.lua" into "commands.lua"
>repeat infinitely
I'm guessing what you want to do is drop the include from commands.lua
[img]http://i.imgur.com/zaHSG.png[/img]
This seems new.
Yep, we fixed a few bugs (SendLua works now) and had to include the soon-to-be addon central.
Right now you have the same functionality as before (enable / disable addons) but we are adding more stuff soon!
Also 1.2 when MCP comes out.. :v:
[QUOTE=LuaStoned;34955909]Yep, we fixed a few bugs (SendLua works now) and had to include the soon-to-be addon central.
Right now you have the same functionality as before (enable / disable addons) but we are adding more stuff soon!
Also 1.2 when MCP comes out.. :v:[/QUOTE]
That's great news - I've shown some friends the luacraft client and they're pretty into it, especially with this new addon central idea being added.
We're also thinking about switching over to LuaJava which would basically be Java interfacing with Lua in C which would be a lot better speed wise.
[QUOTE=BlackAwps;34956319]We're also thinking about switching over to LuaJava which would basically be Java interfacing with Lua in C which would be a lot better speed wise.[/QUOTE]
Do it.
[QUOTE=BlackAwps;34956319]We're also thinking about switching over to LuaJava which would basically be Java interfacing with Lua in C which would be a lot better speed wise.[/QUOTE]
Already started. :v: ( Might try and make it work with LuaJIT too. )
Sorry, you need to Log In to post a reply to this thread.