Jump to content




Lua math error?


  • You cannot reply to this topic
4 replies to this topic

#1 moomoomoo3O9

  • Members
  • 82 posts
  • LocationPork roll land

Posted 22 January 2014 - 03:58 PM

I am using coordinates in a for loop for setting blocks, and it seems that lua does not understand in this program that -227>-251. It should always use the lower number as the first number in the for loop, and then the higher one. (as otherwise it wouldn't work because for loops work in a range!)
(More fun with the worldedit program, I just implemented /pos1 from worldedit instead!)
Relevant code:
Spoiler
Full Program for the curious:
Spoiler


#2 Lyqyd

    Lua Liquidator

  • Moderators
  • 8,465 posts

Posted 22 January 2014 - 05:05 PM

What arguments are you using to run this program?

#3 moomoomoo3O9

  • Members
  • 82 posts
  • LocationPork roll land

Posted 22 January 2014 - 05:26 PM

Arguments for this program are:

set [username of the player to send chat message] x, y, z of first corner, x, y, z of second corner, block type, and metadata.

everything but the username is a number.
an example of running it would be:
shell.run("set", "moomoomoo309", -277, 5, 32, -255, 10, 48, 1, 0)
What comes out of this would be (on the lines where it prints x3-4, y3-4, z3-4)
x: -255 - -277
y: 10 - 5
z: 32 - 48
Meaning the entire huge block of "if" statements making sure that x3, y3, and z3 is less than x4, y4, and z4 did nothing.

#4 Lyqyd

    Lua Liquidator

  • Moderators
  • 8,465 posts

Posted 22 January 2014 - 05:30 PM

You should probably tonumber() the arguments when you assign the variables from the table. Otherwise, they'll be sorted alphabetically instead of numerically. For example,

local x1 = tonumber(tArgs[2])


#5 moomoomoo3O9

  • Members
  • 82 posts
  • LocationPork roll land

Posted 22 January 2014 - 05:31 PM

That worked. Thanks!





3 user(s) are reading this topic

0 members, 3 guests, 0 anonymous users