# debug.getupvalue

- **Ortam:** İstemci, Sunucu, Menü
- **İngilizce aslı:** https://wiki.facepunch.com/gmod/debug.getupvalue
- **Çeviri tarihi:** 2025-09-08

```lua
string, any debug.getupvalue( function func, number index )
```

## Açıklama

> **KULLANIMDAN KALKTI:** Bunu kullanmamanızı tavsiye ederiz. Gelecekteki bir güncellemede değiştirilebilir veya kaldırılabilir.

Belirtilen fonksiyondaki bir indeksten değişken değerlerini almak için kullanılır. Bu, C fonksiyonları için hiçbir şey yapmaz.

## Argümanlar

1. [function](https://gmod.tr/wiki/function) **func**: İndekslenmiş upvalue'nun alınacağı fonksiyon.
2. [number](https://gmod.tr/wiki/number) **index**: Upvalue dizisindeki indeks. Maksimum giriş sayısı [debug.getinfo](https://gmod.tr/wiki/debug.getinfo)'nun "[nups](https://gmod.tr/wiki/Structures/DebugInfo)" anahtarında bulunabilir.

## Dönüşler

1. [string](https://gmod.tr/wiki/string): Upvalue'nun adı. Eğer indeks aralık dışındaysa (< 1 veya > [debug.getinfo](https://gmod.tr/wiki/debug.getinfo).nups) veya fonksiyon C'de tanımlanmışsa nil olacaktır.
2. [any](https://gmod.tr/wiki/any): Upvalue'nun değeri.

### Örnek

Bazı yerel fonksiyonların upvalue'larını yazdırır.

```lua
local foo = 5
local bar = "hello"
local test = { "table", true, "variable" }

local function DoSomethingWithFoo()
	-- Bu kod çalıştırılmayacak ancak fonksiyonun
	-- bir upvalue olarak sayılabilmesi için
	-- değişkene referans vermesi gerekir
	foo = foo + 1
end

local function DoSomethingWithFooAndBar()
	foo = foo / 2
	bar = bar .. " world"
end

local function DoSomethingWithBarAndTest()
	test[1] = bar .. "reader!"
end

-- level = yerel değişkenlerin alınacağı yığın seviyesi
-- değişken adını temsil eden string anahtarlı bir tablo döndürür
local function GetUpvalues( func )
	local info = debug.getinfo( func, "uS" )
	local variables = {}

	-- Upvalue'lar C fonksiyonlarından alınamaz
	if ( info != nil && info.what == "Lua" ) then
		local upvalues = info.nups

		for i = 1, upvalues do
			local key, value = debug.getupvalue( func, i )
			variables[ key ] = value
		end
	end

	return variables
end

print( "DoSomethingWithFoo:" )
PrintTable( GetUpvalues( DoSomethingWithFoo ) )

print( "\nDoSomethingWithFooAndBar:" )
PrintTable( GetUpvalues( DoSomethingWithFooAndBar ) )

print( "\nDoSomethingWithBarAndTest:" )
PrintTable( GetUpvalues( DoSomethingWithBarAndTest ) )
```

**Çıktı:**

```lua
DoSomethingWithFoo:
foo	=	5

DoSomethingWithFooAndBar:
bar	=	hello
foo	=	5

DoSomethingWithBarAndTest:
bar	=	hello
test:
		1	=	table
		2	=	true
		3	=	variable
```

- [GMod Wiki ana sayfası](https://gmod.tr/wiki)

---

[Tüm sunucular](https://gmod.tr/) · [GmodTR Launcher](https://gmod.tr/launcher) · [Rehber](https://gmod.tr/rehber) · [GMod Wiki](https://gmod.tr/wiki) · [GmodTR nedir?](https://gmod.tr/hakkinda) · [Sunucu ekle](https://gmod.tr/sunucu-ekle) · [Discord](https://discord.gg/gmodtr)

Kaynak: https://gmod.tr/wiki/debug.getupvalue
