To Game-Devs: The "n" entry in array-like tables was removed - Page 2

To Game-Devs: The "n" entry in array-like tables was removed

Discuss game development here, from a distinct game project to an accessible third-party mutator, down to the interaction and design of individual units if you like.

Moderator: Moderators

User avatar
smoth
Posts: 22309
Joined: 13 Jan 2005, 00:46

Re: To Game-Devs: The "n" entry in array-like tables was removed

Post by smoth »

Forboding Angel wrote:
hoijui wrote:necessary changes
Instead of reading the "n" member of tables to get their size, you have to use the # operator now.
This change is backwards compatible; if you apply it to your Lua, it will also work in current release.
-> do it asap! ;-)
This is as clear as fresh horseshit.

so this: arg.n
becomes: arg
or: arg.#
or:#arg
or...

How about some proper explanations. Also, was this really freaking necessary? Perhaps just one freaking release without you guys breaking lua for no damn good reason.
#arg
# returns the count.

if you see anything doing a arg.n = nil just comment out that line, you don't need it.

also be on the look out for [n]
User avatar
Forboding Angel
Evolution RTS Developer
Posts: 14673
Joined: 17 Nov 2005, 02:43

Re: To Game-Devs: The "n" entry in array-like tables was removed

Post by Forboding Angel »

Code: Select all

-      for i=1,ud.weapons.n do
+      for i=1,#ud.weapons do
This is what I saw on github. I'm going to assume that it should be done this way for every instance, and maybe they should stick this on the first post. Don't come telling me to do shit and assuming I know what the hell you're talking about. I'm tired of having to fix shit that you guys break every goddamn engine release.

Code: Select all

if (not arg) then arg = {...}; arg.n = #arg end
^^ What about that? Looks to me like the problem solves itself. Amirong?
User avatar
smoth
Posts: 22309
Joined: 13 Jan 2005, 00:46

Re: To Game-Devs: The "n" entry in array-like tables was removed

Post by smoth »

the # is the proper way to get a count on something man.
2.5.5
2.5.5 - The Length Operator

The length operator is denoted by the unary operator #. The length of a string is its number of bytes (that is, the usual meaning of string length when each character is one byte).

The length of a table t is defined to be any integer index n such that t[n] is not nil and t[n+1] is nil; moreover, if t[1] is nil, n can be zero. For a regular array, with non-nil values from 1 to a given n, its length is exactly that n, the index of its last value. If the array has "holes" (that is, nil values between other non-nil values), then #t can be any of the indices that directly precedes a nil value (that is, it may consider any such nil value as the end of the array).
User avatar
Forboding Angel
Evolution RTS Developer
Posts: 14673
Joined: 17 Nov 2005, 02:43

Re: To Game-Devs: The "n" entry in array-like tables was removed

Post by Forboding Angel »

Engine devs need to provide clear instructions on what to change without me having to spend any time at all to figure out what they are talking about. If I have to spend hours figuring out what to change on a case by case basis this shit isn't going to work.

Also, backwards compatible, my fucking ass.
User avatar
Forboding Angel
Evolution RTS Developer
Posts: 14673
Joined: 17 Nov 2005, 02:43

Re: To Game-Devs: The "n" entry in array-like tables was removed

Post by Forboding Angel »

Obviously, I tried, and a bunch of shit broke.
User avatar
hoijui
Former Engine Dev
Posts: 4344
Joined: 22 Sep 2007, 09:51

Re: To Game-Devs: The "n" entry in array-like tables was removed

Post by hoijui »

indeed it is bad if every game dev has to figure out how to do it himself.
but then again, any engine devs time is X times more valuable then yours, forb (X > ~10). so it is your duty to find out how to do it, and then tell other game devs, and you may praise us in the meantime, for the glory of the idea for the change plus its implementation.

... does not make sense?
in stupid mans english then, especially for you (just remember how nice of me that is, remember: ~10!):
instead of chewing on your hourly horseshit talk and spitting it at us, insulting and rambling for your inability in basic Lua, your post could have looked like this:
please include this in the first post:
example:

Code: Select all

-      for i=1,ud.weapons.n do
+      for i=1,#ud.weapons do
you are the only time waster here.

... big sorry from me for not being perfect, by the way!!1 REALLY SORRY!
Last edited by hoijui on 06 Jul 2011, 10:12, edited 1 time in total.
Google_Frog
Moderator
Posts: 2464
Joined: 12 Oct 2007, 09:24

Re: To Game-Devs: The "n" entry in array-like tables was removed

Post by Google_Frog »

Code: Select all

-      for i=1,ud.weapons.n do
+      for i=1,#ud.weapons do
Blindly doing this for all .n's you find doesn't work all the time. Some lua code has local arrays which have a n element so if you find a .n you have to backtrack and find it's source to decide whether it needs changing. Basically you have not know a bit of lua.
User avatar
Forboding Angel
Evolution RTS Developer
Posts: 14673
Joined: 17 Nov 2005, 02:43

Re: To Game-Devs: The "n" entry in array-like tables was removed

Post by Forboding Angel »

hoijui wrote:any engine devs time is X times more valuable then yours, forb (X > ~10).
Edit: Removed. You're a dick. You are quite mistaken.

However, it was not my intention to start a pissing match. Abma is all over the evo bugtracker trying to motivate me to do this so that he and anyone else can test with evo. Ok, I'm down with that, but tell me what I have to do. Don't make me beg and grovel for help fixing something that you broke.
User avatar
hoijui
Former Engine Dev
Posts: 4344
Joined: 22 Sep 2007, 09:51

Re: To Game-Devs: The "n" entry in array-like tables was removed

Post by hoijui »

unlike common understanding of physics, engine devs also get wet when you piss at them. so next time you try to not start a pissing match, try to keep that in mind.
the other important rule is quite commonly known, but as not everybody knows basic stuff i will repeat it here anyway:
if one gets wet, he pisses back

you made me get so wet, forb!
User avatar
Forboding Angel
Evolution RTS Developer
Posts: 14673
Joined: 17 Nov 2005, 02:43

Re: To Game-Devs: The "n" entry in array-like tables was removed

Post by Forboding Angel »

Engine Devs: ohay, we broke yer shit!
Me: ok
Engine Devs: Fix yer shit!
Me: looks for any and all documentation to find essentially, nothing. Yells at engine devs
Engine Devs: we broke your shit and it's your fault that we broke your shit and you're a douchebag for complaining about it because our time is worth more than yours and we're still not going to tell you how to fix it.

That about right hoijui? Yeah, that's what I thought. Also, I get paid $35 bucks an hour for my time. How much do you make? I have also sunk 10x as much time into working on spring as you have. Just because you work on the engine doesn't mean you're better.
User avatar
hoijui
Former Engine Dev
Posts: 4344
Joined: 22 Sep 2007, 09:51

Re: To Game-Devs: The "n" entry in array-like tables was removed

Post by hoijui »

first reference from this thread where somebody defines his time to be more valuable then somebody elses time:
Forboding Angel wrote:Engine devs need to provide clear instructions on what to change without me having to spend any time at all to figure out what they are talking about.
Pretty much every sane human would say, that a second of Ghandis live was more valuable then your entire live worth of existence. Yet i guess he did not get 35$ per hour.
your weltbild is insane, and fails hard.
but even if it would not... you remember that i live in switzerland, right? not sweden, not swaziland, not the independent republic of the Kongo, but switzerland. the cheese, chocolate and banks thing, you know. (beware! only one of the three matters here!).

an other part of your weltbild that fails hard:
game devs are not the center of the spring world, because...
there is no center!
wait.. woahh... here! grab that handle!

documentation:
nobody except you had a problem so far, and you are by far not the first to do this. as was mentioned, it is basic Lua, so... yes, there was documentation.

Something that you might find interesting too:
before doing this change, it was discussed with game devs if it would be good or not, and we did what they wanted. but it is of course our fault that you were not included in the discussion.. should have sent you a PM for invitation, even though you obviously do not understand what it is about... it is of course our #1 duty to make sure that forb knows about everything we do, and gets asked for every change personally. so far, we took special measures that other game devs are included in such decisions and get to know about changes, and get good docu (in contrast to the dedicated forb docu we produce, to make your live harder. HAR, HAR!). from now on, we will change that, and we will stop working on anything that could possible cause extra work for you, even if the rest of the world wants it, and will instead focus on features that evo would benefit from, and we will make them so evo benefits from them without you doing extra work, Oh sir!
And if i ever get to have a first born .. something, it will be all yours, whether you wish it dead or alive, Oh omega.
and may any traitor never forget:
http://www.youtube.com/watch?v=-IVQ-UP8yyY#t=22s
User avatar
Forboding Angel
Evolution RTS Developer
Posts: 14673
Joined: 17 Nov 2005, 02:43

Re: To Game-Devs: The "n" entry in array-like tables was removed

Post by Forboding Angel »

That quote is a misunderstanding by you.

I was drawing a direct parallel in reverse of what you guys saddle us with. Telling us to do something but providing no worthwhile documentation.

So, the exact opposite of that is me saying that. You're the one that decided to turn it into a crapstorm. I boiled the pot with righteous indignation, but you're the one that started stirring it.

The easy answer to all of this would have been more info, hell even direct links to the wiki. It's obvious I don't know wtf is going on here, so wtf would I search for?

Just because I am the only one speaking up doesn't mean that I'm the only one having a problem. You know better than to make that statement.

Also, when is the last time that I asked for an Evo specific feature of the engine? Oh yeah, that would be never.
User avatar
FLOZi
MC: Legacy & Spring 1944 Developer
Posts: 6240
Joined: 29 Apr 2005, 01:14

Re: To Game-Devs: The "n" entry in array-like tables was removed

Post by FLOZi »

Unacceptable, Forb.

The change is minor, easy to keep fix for both current spring and 0.83, and should have always been that way.

If you can't behave, you really should take a time-out like Smoth did.
User avatar
smoth
Posts: 22309
Joined: 13 Jan 2005, 00:46

Re: To Game-Devs: The "n" entry in array-like tables was removed

Post by smoth »

Google_Frog wrote:

Code: Select all

-      for i=1,ud.weapons.n do
+      for i=1,#ud.weapons do
Blindly doing this for all .n's you find doesn't work all the time. Some lua code has local arrays which have a n element so if you find a .n you have to backtrack and find it's source to decide whether it needs changing. Basically you have not know a bit of lua.
Care to expand on that? Most cases were not this but an example would be cool. Anything in zk have this gotcha?
Google_Frog
Moderator
Posts: 2464
Joined: 12 Oct 2007, 09:24

Re: To Game-Devs: The "n" entry in array-like tables was removed

Post by Google_Frog »

smoth wrote:Care to expand on that? Most cases were not this but an example would be cool. Anything in zk have this gotcha?
Some people have used n as a count tracker in lua code. For example in gui_transporting the function SortedTransportedUnits returns an array with n as an element. It would be reasonably easy to remove that n with a bit of modification but that isn't really the point. If you are unsure where an array originates you don't know whether removing n is required or valid.

Here is some documentation for Forboding Angel on the # operator http://lua-users.org/wiki/TablesTutorial
User avatar
smoth
Posts: 22309
Joined: 13 Jan 2005, 00:46

Re: To Game-Devs: The "n" entry in array-like tables was removed

Post by smoth »

I linked him to the lua docs already he still raged on :/
User avatar
Forboding Angel
Evolution RTS Developer
Posts: 14673
Joined: 17 Nov 2005, 02:43

Re: To Game-Devs: The "n" entry in array-like tables was removed

Post by Forboding Angel »

FLOZi wrote:Unacceptable, Forb.

The change is minor, easy to keep fix for both current spring and 0.83, and should have always been that way.

If you can't behave, you really should take a time-out like Smoth did.
Orly? Then why does it all epicly break when I make this "easy" fix, huh?

What is absolutely unacceptable is lua being broken on every Fucking engine release.

It isn't so minor when the change breaks the game in current version of spring.
abma
Spring Developer
Posts: 3798
Joined: 01 Jun 2009, 00:08

Re: To Game-Devs: The "n" entry in array-like tables was removed

Post by abma »

@Forb:

its minor because the change is backwards-compatible. if you fix the "n"'s, it will work in the old engine, too.
User avatar
smoth
Posts: 22309
Joined: 13 Jan 2005, 00:46

Re: To Game-Devs: The "n" entry in array-like tables was removed

Post by smoth »

Forboding Angel wrote: It isn't so minor when the change breaks the game in current version of spring.
it doesn't though and if it does, do tell.

Forb if your stuff is still broken after the fix of .n to # make links to you svn showing chagesets so we can see how you applied said fix and to what.

Raging doesn't get yer shit fixt. These changes are the easy part like I said last night. You have not gotten to the "fun" stuff yet. And most of that the rest of us are working at.


Speaking of that... Zwzsg would you care to update the menu code for win/lose in the svn or do I need to
Post Reply

Return to “Game Development”