Skip to content

Posts from Question regarding code behavior.

No ratings yet — be the first to rate!
3 years ago
Auto-translated
function get_x() return 42 end function test_1() local x = get_x() return x end function test_2() return get_x() end x1 = test_1() x2 = test_2() print(x1, " ", x2) -- 42 nil Is this a bug or a feature, or am I missing something?
User Avatar
3 years ago
Auto-translated
Robb
Is this a bug or a feature, or am I missing something?

It's more likely a bug, as online Lua compilers output "42 42".
User Avatar
3 years ago
Auto-translated
If the issue is still relevant, then the problem lies in the behavior of the game's scripts. Returning a variable that is not local to the function will always result in nil.

Statistics

Welcome our newest member: recijeb