SetSignLines does not work - Printable Version +- Cuberite Forum (https://forum.cuberite.org) +-- Forum: Plugins (https://forum.cuberite.org/forum-1.html) +--- Forum: Plugin Discussion (https://forum.cuberite.org/forum-8.html) +--- Thread: SetSignLines does not work (/thread-2319.html) Pages:
1
2
|
SetSignLines does not work - nixi - 01-16-2016 Hi, I have started using lua yesterday and I just can not get past this problem. I need to update all lines of a specific sign. "World:SetSignLines()" Either does nothing (if called in a function started by a hook) or it throws out an error (if started in an independent function). How can I use this properly? function poiMain(Split, Player) World:SetSignLines(58, 64, 42, "test", "test", "test", "test") return true end Code: [15:34:37] LUA: Plugins/PointsOfInterest/functions.lua:52: attempt to index global 'World' (a nil value) RE: SetSignLines does not work - NiLSPACE - 01-16-2016 Hello and welcome to the forum. Your World variable is empty, but you can get it from the player: function poiMain(Split, Player) Player:GetWorld():SetSignLines(58, 64, 42, "test", "test", "test", "test") return true end RE: SetSignLines does not work - nixi - 01-16-2016 Yes, that works. Thank You. What if I wanted to GetSignLines and assign Line4 into a variable? I tried this: lines = Player:GetWorld():GetSignLines(BlockX, BlockY, BlockZ) Player:SendMessage(lines[4]) That, of course, did not work. RE: SetSignLines does not work - ThuGie - 01-16-2016 Is it not 0-3 ? instead 1-4 ? RE: SetSignLines does not work - NiLSPACE - 01-16-2016 Try this: local IsValid, Line1, Line2, Line3, Line4 = World:GetSignLines(PosX, PosY, PosZ) RE: SetSignLines does not work - nixi - 01-16-2016 (01-16-2016, 03:21 AM)ThuGie Wrote: Is it not 0-3 ? instead 1-4 ? As far as I know, lua starts counting from 1. It does not work even when I change it to 3. (01-16-2016, 04:06 AM)NiLSPACE Wrote: Try this: This works! Tahnk you very much. My code: local IsValid, Line1, Line2, Line3, Line4 = Player:GetWorld():GetSignLines(BlockX, BlockY, BlockZ) RE: SetSignLines does not work - xoft - 01-16-2016 You'd need to make an array out of the "lines" variable. Lua has bit different syntax rules: local a, b, c = 1, 2, 3, 4 --> a == 1; b == 2; c == 3; 4 gets forgotten -- In this same fashion: local lines = "line1", "line2", "line3", "line4" --> lines = "line1"; Lua discards "line2" - "line4" -- You probably want this: local lines = { World:GetSignLines(PosX, PosY, PosZ) } --> lines[1] == "line1"; lines[2] == "line2" etc. RE: SetSignLines does not work - xoft - 01-16-2016 Ahele, se stim smiĆ? RE: SetSignLines does not work - Seadragon91 - 01-16-2016 @xoft The function also returns at first position a IsValid variable. The lines would then start at index 2. RE: SetSignLines does not work - xoft - 01-16-2016 Yea, that's right. |