What are slots?

Currently viewing this thread:

Status
Not open for further replies.

Emogma

Sergeant
I searched the forums already but most of the questions regarding slot leads to the 2009 module system tutorial which i'm pretty sure is outdated so can anyone explain what slots are?
 
Not outdated, just hard to understand.

Long story short, a slot is like a variable, you assign it with stuff. They are found in module constants
 

kt0

Knight
A slot is an ID where you can get/set a value on an object in the module system.  Operators typically take the form of *_get_slot and *_set_slot where * is your favorite party/troop/faction/whatever.  The value will stay that way until it's set again.  Hilarity can ensue if you use a slot that someone else is already using. 

edit>  CutContent beat me to it.
 

Tama

Veteran
Emogma said:
I searched the forums already but most of the questions regarding slot leads to the 2009 module system tutorial which i'm pretty sure is outdated so can anyone explain what slots are?

Actually, it shouldn't be outdated since as far as i remember slot operations didn't change all that time. Slots are basically advanced variables for the module system. When you want to assign a variable to something, you use slots. You can assign slots to troops, agents, multiplayer players, parties and the list goes on and on. Imagine it's a variable inside a class of some gameobject. And when you assign it that troop will have that variable.

(agent_slot_eq, ":player_agent", slot_agent_happy, 0),  #You can make conditions like this one. This checks if the player_agent's slot_agent_happy variable is 0.
(agent_get_slot,":some_value",":player_agent",slot_agent_happy), #This stores the slot_agent_happy's variable into ":some_value"
(agent_set_slot,":player_agent",slot_agent_happy,":some_value"), #This assigns slot_agent_happy with the value inside the variable ":value"

Also check out module_constants for existing slots or making new ones like the guy above me suggested^^ Good luck.
 
whats the difference between slots and variables that start with :?
like ":cur_scene" I think the :variables compared to slots is like what quick strings is compared to normal strings right?
 

Tama

Veteran
CutContent said:
whats the difference between slots and variables that start with :?
like ":cur_scene" I think the :variables compared to slots is like what quick strings is compared to normal strings right?
You should really check the modüle_system introduction threads for this. But to simply answer you question.

":cur_scene" is a local variable. You can't Access this beyond the brackes where it was asigned because its deleted from the memory after the scripts inside the brackets run.
"$cur_scene" is a global variable. You can Access these variables from anywhere, anytime. They are never deleted once created. But they are slower than local variables but you shouldn't bother with it.

However every town is a party. And every town has slot_party_town_center and slot_party_town_tavern like slots(close enough) that stores the information about certain town scenes. This is used to load the proper scenes when we visit.

Basically slots are variables that you can assign to things like troops, parties and agents. And you can call them global I guess. Once you create a slot for a party for example. You can assign different values to each party using that slot. instad of doing something like $party1_variable, $party2_variable,...... partyN_variable.
 
EDIT: Tama was faster  :grin:

Variables like ":dasd" are only for the script part means like:

("script_blablabla",
[(assign, ":dasd", 5),

]),

means you can use ":dasd" only in this "blablabla" part of the scripts. It`s like a cached variable. You could also use reg1-64 here but well the way of doing it with ":" is more faster, it gives more overview and it is just the best way what I learned. It`s not like a quick string due to quick strings can basically be used everywhere (see quick_strings.txt of the compiled module). They are actual strings & saved down. These ":" are like cached variables in which you can only put integers.
And yes slots are like "saved" variables. They are saved until the server/client shuts down. Depends on serverside/clientside slots. If you start the server all slots will have "0" as the standard input.
 

Tama

Veteran
domipoppe said:
EDIT: Tama was faster  :grin:
you can only put integers.

You don't have to worry about that. Because everything has an integer number troops, agents, players everything equals to some integer. You don't have to understand it, at least yet. And you can't use float numbers anyway. So don't worry about integers or anything. You can perfectly store troop id's, agent id's into these  : variables because almost everything has an integer equivalent.
 
Tama said:
domipoppe said:
EDIT: Tama was faster  :grin:
you can only put integers.

You don't have to worry about that. Because everything has an integer number troops, agents, players everything equals to some integer. You don't have to understand it, at least yet. And you can't use float numbers anyway. So don't worry about integers or anything. You can perfectly store troop id's, agent id's into these  : variables because almost everything has an integer equivalent.

Well I meant only numbers as he maybe could try to put a string inside it.
 

Tama

Veteran
kalarhan said:
:arrow: http://forums.taleworlds.com/index.php/topic,142422.0.html

there is a section dedicated to slots in that guide, and it is still relevant today (works the same)

Thank you good sir.


domipoppe said:
Tama said:
domipoppe said:
EDIT: Tama was faster  :grin:
you can only put integers.

You don't have to worry about that. Because everything has an integer number troops, agents, players everything equals to some integer. You don't have to understand it, at least yet. And you can't use float numbers anyway. So don't worry about integers or anything. You can perfectly store troop id's, agent id's into these  : variables because almost everything has an integer equivalent.

Well I meant only numbers as he maybe could try to put a string inside it.

Ah, sorry. I got a little bit carried away :smile:
 

Emogma

Sergeant
Tama said:
Emogma said:
I searched the forums already but most of the questions regarding slot leads to the 2009 module system tutorial which i'm pretty sure is outdated so can anyone explain what slots are?

Actually, it shouldn't be outdated since as far as i remember slot operations didn't change all that time. Slots are basically advanced variables for the module system. When you want to assign a variable to something, you use slots. You can assign slots to troops, agents, multiplayer players, parties and the list goes on and on. Imagine it's a variable inside a class of some gameobject. And when you assign it that troop will have that variable.

(agent_slot_eq, ":player_agent", slot_agent_happy, 0),  #You can make conditions like this one. This checks if the player_agent's slot_agent_happy variable is 0.
(agent_get_slot,":some_value",":player_agent",slot_agent_happy), #This stores the slot_agent_happy's variable into ":some_value"
(agent_set_slot,":player_agent",slot_agent_happy,":some_value"), #This assigns slot_agent_happy with the value inside the variable ":value"

Also check out module_constants for existing slots or making new ones like the guy above me suggested^^ Good luck.

So if i'm correct, I can have multiple slots act as parameters for something like
Bob has 3 slots, Age, Weight, and Favorite Color and I can change them?
 
Yes.

A slot is like a on a agent/player/scene prop assigned integer/number.
You have several operations like agent_set_slot, player_set_slot etc. and you will set the slot specificely for the agent or player or etc.

The important thing here is to difference between agents and players.
Players are players yes but in the truth they are also agents. The server spawns agents for the players.
Agents are everything (horses, bots, the from the player controlled agents) and players are more like the "player" in the "scoretable".

Player slots exist as long as the player is on the server/game.
Agent slot exist as long as the agent is actually existing.

If you take now a example like Bob. He's a bot. You could set through slot his gear, gold etc.
 

Tama

Veteran
Emogma said:
Tama said:
Emogma said:
I searched the forums already but most of the questions regarding slot leads to the 2009 module system tutorial which i'm pretty sure is outdated so can anyone explain what slots are?

Actually, it shouldn't be outdated since as far as i remember slot operations didn't change all that time. Slots are basically advanced variables for the module system. When you want to assign a variable to something, you use slots. You can assign slots to troops, agents, multiplayer players, parties and the list goes on and on. Imagine it's a variable inside a class of some gameobject. And when you assign it that troop will have that variable.

(agent_slot_eq, ":player_agent", slot_agent_happy, 0),  #You can make conditions like this one. This checks if the player_agent's slot_agent_happy variable is 0.
(agent_get_slot,":some_value",":player_agent",slot_agent_happy), #This stores the slot_agent_happy's variable into ":some_value"
(agent_set_slot,":player_agent",slot_agent_happy,":some_value"), #This assigns slot_agent_happy with the value inside the variable ":value"

Also check out module_constants for existing slots or making new ones like the guy above me suggested^^ Good luck.

So if i'm correct, I can have multiple slots act as parameters for something like
Bob has 3 slots, Age, Weight, and Favorite Color and I can change them?

Glad I could help ^^
 

Emogma

Sergeant
Lol I was gonna say thank you. So thank you for helping me, warband modding is quite harder than KAG modding.

I don't know how to remove extra quotes though so I'm not gonna reply to you to make this thread a bit cleaner.
 
Status
Not open for further replies.
Top Bottom