# Reading private variables

Reading private variables is clearly necessary when modding raft. Let's see how easy it is!

To access private variables we need to use **Harmony**. You can visit the Harmony wiki by clicking [here](https://github.com/pardeike/Harmony/wiki).\
\&#xNAN;*`Harmony is a library for patching, replacing and decorating .NET and Mono methods during runtime.`*\
\
To use harmony you simply need to add the `Harmony` namespace by adding `using Harmony;` at the top of your class.

\
To access a **non-static private variable** you use Traverse.Create() with the object instance and .Field() with the field name.

```csharp
string myvalue = Traverse.Create(ScriptInstance).Field("fieldname").GetValue() as string;

// For example to get the value "m_MinFallingHeight" of the class Player we can do that :
float val = Traverse.Create(Player.Get()).Field("m_MinFallingHeight").GetValue() as float;
```

\
To access a **static private variable** you also use Traverse.Create() but with the class type and .Field() with the field name.

```csharp
string myvalue = Traverse.Create(typeof(classname)).Field("fieldname").GetValue() as string;

// For example to get the value "s_Initialized" of the class ItemIDHelpers we can do that :
bool myvalue = Traverse.Create(typeof(ItemIDHelpers)).Field("s_Initialized").GetValue() as bool;
```


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.greenhellmodding.com/client-code-examples/reading-private-variables.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
