Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

Bug Reports / [Unity] very strange lua return values

Author
Message
Escaped Ape
19
Years of Service
User Offline
Joined: 25th Jul 2006
Location: Germany
Posted: 30th Mar 2007 18:57 Edited at: 30th Mar 2007 20:19
well, the following code-snippet produces an output of:
0
1.10000002384
1



i tried to put the function in a lua file, but it's the same.
i fiddled around with the return values and everything - allways very strange results.
My copy of the lua dll is the newst v. 3.0 and i got 1.063 update of dbpro.

EDIT: When i only return one value it returns the correct result (1)
The problem only seems to occur with multiple return values

Torrey
21
Years of Service
User Offline
Joined: 20th Aug 2004
Location: New Jersey
Posted: 31st Mar 2007 02:27 Edited at: 31st Mar 2007 02:28
This isn't a bug from what I can see. Think of the multiple return like a stack of papers. In your example code you have 3 papers. You put down 1 first, then lay 1.1 on top of the first one, and then lastly you put "test" on top of the last one. Now when you go to remove those items from the stack, you start with the top most one, and that would be "test".

I guess a term for that method would be LIFO (last in first out). So for your example just do this:



Then everything should come out alright. Doesn't it?

Escaped Ape
19
Years of Service
User Offline
Joined: 25th Jul 2006
Location: Germany
Posted: 31st Mar 2007 02:52 Edited at: 31st Mar 2007 04:28
Sadly no.
I also thought about the stack thing, but the manual describes it like the way i wrote the code above.
Your code returns
test
0
1

EDIT: when i only use one variable type to return (3 times a string or 3 times an int) the values are correct...

Escaped Ape
19
Years of Service
User Offline
Joined: 25th Jul 2006
Location: Germany
Posted: 31st Mar 2007 18:24
any other unity user who experience this problem as well?
please don't tell me that my case is hopeless...

Escaped Ape
19
Years of Service
User Offline
Joined: 25th Jul 2006
Location: Germany
Posted: 1st Apr 2007 18:08
i hate multi-postings, but i really need somebodys help here..please.
this problem is not a tiny thing i can go round, it keeps me from using unity

dark coder
23
Years of Service
User Offline
Joined: 6th Oct 2002
Location: Japan
Posted: 2nd Apr 2007 15:04
This is correct, because floats aren't stored like Integers or Dwords, they are fractions and so you cannot have exactly 1.1 or so I'm told, some values like 1.5 may work, however things like your 1.1 or 5.4817 will not display exactly the same, also this is faster than having accurate floats as floats are probably the most used data type in game programming so I see no problems.

Escaped Ape
19
Years of Service
User Offline
Joined: 25th Jul 2006
Location: Germany
Posted: 2nd Apr 2007 16:56 Edited at: 2nd Apr 2007 17:30
well i don't know if you got my problem.
my problem is not the 1.10000002384 instead of 1.1, my problem is that this

is displayed instead of

this.
this IS a problem, because the string i wanted to return is 0.
or in torreys snippet

instead of


EDIT: I have attached a little test program, which simply calls the function "test()" of the included lua file and prints its results.
It would be very cool, if some of you could test it and post the results here.

David T
Retired Moderator
23
Years of Service
User Offline
Joined: 27th Aug 2002
Location: England
Posted: 6th Apr 2007 23:29
Quote: "EDIT: when i only use one variable type to return (3 times a string or 3 times an int) the values are correct..."


Indicated that there isn't something wrong with the code that fetches strings / ints / floats from the stack. Good.

Try something like this:



See what sort of data comes out, whether all the data comes out, and what order it is. You should get something like (assuming you return 1,1.1,"test")

0
1
1

0.000000
1.100001
1.000001

test
0
0

Post what you get.

Escaped Ape
19
Years of Service
User Offline
Joined: 25th Jul 2006
Location: Germany
Posted: 7th Apr 2007 00:02 Edited at: 7th Apr 2007 00:11
first of all using the command "lua next()" to return the stack values produces no output in my case.
I used the following code:


and got the results:
0
1
1

0
1.1
1

test
test
test

And this is what works:


output:
1.3
1.2
1.1

Escaped Ape
19
Years of Service
User Offline
Joined: 25th Jul 2006
Location: Germany
Posted: 9th Apr 2007 13:10
So? Anything I can do?

Escaped Ape
19
Years of Service
User Offline
Joined: 25th Jul 2006
Location: Germany
Posted: 12th Apr 2007 00:53
another bump..i really want to use that set of commands

Login to post a reply

Server time is: 2026-06-09 19:04:22
Your offset time is: 2026-06-09 19:04:22