Jump to content

View more

Image of the Day

#ld38 #screenshotsaturday Mimosa Fizz action gif #2 https://t.co/TUzdppvfUL
IOTD | Top Screenshots

The latest, straight to your Inbox.

Subscribe to GameDev.net Direct to receive the latest updates and exclusive content.


Sign up now

lua multiple return values

4: Adsense

Old topic!

Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.


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

#1 O-san   Members   

1863
Like
0Likes
Like

Posted 03 February 2012 - 08:19 AM

function foo(a)
-- ...
return a, b
end
I got this function which returns a and b. Is it possible to register a C function using lua_register() that returns multiple values the same way? Or should I resort to push a table to the stack instead?
Posted Image Posted Image Posted Image Posted Image Posted Image Posted Image Posted Image

#2 Kristoffer   Members   

966
Like
2Likes
Like

Posted 03 February 2012 - 08:31 AM

Yes,

leave the arguments that you want to return on the stack and let the C function return the numbers of arguments you want to return to lua

// psudeo
int cfunction(lua_State * state)
{
	 push(arg1)
	 push(arg2)

	 return 2;
}

Blekinge Institute of Technology
Twitter @devmoon
Homepage http://devmoon.se
Stream http://twitch.tv/devmoon

#3 O-san   Members   

1863
Like
0Likes
Like

Posted 03 February 2012 - 08:46 AM

Ah! it worked, tackar så mkt :-)
Posted Image Posted Image Posted Image Posted Image Posted Image Posted Image Posted Image




Old topic!

Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.