[poll] Behaviour of piece function in LUS
Posted: 27 Jul 2013, 15:02
[13:51:46] <[S44]FLOZi> who thinks that piece should just return nil in LUS if the model does not have that piece rather than throw an error?
[13:52:46] <[LCC]jK> make it print a LOG.ERROR
[13:52:55] <[S44]FLOZi> atm there's no easy way to check if a piece exists other than using main API functions like GetUnitPieceMap
[13:53:11] <[S44]FLOZi> i would prefer it is just nil and leave it to the gamedev to check
[13:53:20] <[LCC]jK> bad
[13:53:23] <[S44]FLOZi> no
[13:53:24] <[S44]FLOZi> good
[13:53:25] <[LCC]jK> always print errors
[13:53:27] <[S44]FLOZi> No
[13:53:49] <[S44]FLOZi> 1 script is no longer for 1 unit
[13:54:01] <[S44]FLOZi> we need a neat way to detect if a unit has such a piece
[13:54:12] <[S44]FLOZi> what is neater than it being nil
[13:54:49] <[LCC]jK> add a: ispiece""?
[13:55:45] <[S44]FLOZi> so you get "local foo if ispiece ("foo") then foo = piece("foo") end
[13:55:49] <[LCC]jK> it's always better to not hide debug messages, cause you can be sure ppl will run in errors then
[13:55:54] <[S44]FLOZi> instead of just local foo = piece ("foo")
[13:56:26] <[LCC]jK> no first you will encapsule many of those
[13:56:55] <[S44]FLOZi> fine I'll just go edit unit_script in my own game and let everyone else suffer this inanity
[13:57:01] <[LCC]jK> 2nd you can use: local foo = ispiece"foo" and piece"foo"
[13:58:13] <[S44]FLOZi> still ugly
[13:58:28] <[S44]FLOZi> this is as stupid as 'unit costs very little metal!' warning
[13:58:49] <[LCC]jK> doesn't matter as long as it prevents user errors
[13:59:02] <[LCC]jK> it's the job of a language to prevent errors from the start
[13:59:44] <KingRaptor> it throws an error if the game tries to perform an operation on a nil piece, I think that's more than enough to identify the problem
[14:00:18] <[LCC]jK> noobs need 2days first to find out that the piece is nil
[13:52:46] <[LCC]jK> make it print a LOG.ERROR
[13:52:55] <[S44]FLOZi> atm there's no easy way to check if a piece exists other than using main API functions like GetUnitPieceMap
[13:53:11] <[S44]FLOZi> i would prefer it is just nil and leave it to the gamedev to check
[13:53:20] <[LCC]jK> bad
[13:53:23] <[S44]FLOZi> no
[13:53:24] <[S44]FLOZi> good
[13:53:25] <[LCC]jK> always print errors
[13:53:27] <[S44]FLOZi> No
[13:53:49] <[S44]FLOZi> 1 script is no longer for 1 unit
[13:54:01] <[S44]FLOZi> we need a neat way to detect if a unit has such a piece
[13:54:12] <[S44]FLOZi> what is neater than it being nil
[13:54:49] <[LCC]jK> add a: ispiece""?
[13:55:45] <[S44]FLOZi> so you get "local foo if ispiece ("foo") then foo = piece("foo") end
[13:55:49] <[LCC]jK> it's always better to not hide debug messages, cause you can be sure ppl will run in errors then
[13:55:54] <[S44]FLOZi> instead of just local foo = piece ("foo")
[13:56:26] <[LCC]jK> no first you will encapsule many of those
[13:56:55] <[S44]FLOZi> fine I'll just go edit unit_script in my own game and let everyone else suffer this inanity
[13:57:01] <[LCC]jK> 2nd you can use: local foo = ispiece"foo" and piece"foo"
[13:58:13] <[S44]FLOZi> still ugly
[13:58:28] <[S44]FLOZi> this is as stupid as 'unit costs very little metal!' warning
[13:58:49] <[LCC]jK> doesn't matter as long as it prevents user errors
[13:59:02] <[LCC]jK> it's the job of a language to prevent errors from the start
[13:59:44] <KingRaptor> it throws an error if the game tries to perform an operation on a nil piece, I think that's more than enough to identify the problem
[14:00:18] <[LCC]jK> noobs need 2days first to find out that the piece is nil