This site has been archived and made available for preservation purposes. No edits can be made.
-
Item lists
Code cpp:
Void VAULTSCRIPT OnServerInit() noexcept
{
auto containers = Container::GetList();
for (const auto& container : containers)
AddItemList(container, static_cast<ID>(0));
}
Item lists can be created / modified with a script. They can be added to a container (effectively adding all the items on the list to the container). The above code initializes all containers in the game world with their default item lists, which have the ID zero and are made up of the same items which can be found in singleplayer by default.
-
Code cpp:
Void VAULTSCRIPT OnServerInit() noexcept
{
auto containers = Container::GetList();
for (const auto& container : containers)
{
auto list = ItemList::Create(GetBase(container));
RemoveItem(list, ALCH::NukaCola, UINT_MAX);
AddItemList(container, list);
DestroyObject(list);
}
}
All container operations (plus actor equip / unequip) work on item lists. Item lists can be constructed from a container or item list (copy). Item lists can be added to a container or other item lists. This code is the same as above, except it removes all Nuka Cola's from the default contents.
You can, for example, build static item lists which can be added as needed to a player by just using AddItemList.
Last edited by foxtacles; 04-04-2013 at 02:23 AM.
-
Initializer lists:
Code cpp:
Void VAULTSCRIPT OnSpawn(ID object) noexcept
{
Player player(object);
if (player)
{
player.UIMessage("Hello, " + player.GetBaseName() + "!");
auto ID = ItemList::Create({
{ALCH::NukaCola, 100}, // 100x Nuka Cola
{WEAP::Weap32CaliberPistol, 1, 80.0, True, True}, // .32 pistol, 80% health, equipped
{AMMO::Ammo32Caliber, 300}, // 300x .32 ammo
});
player.AddItemList(ID);
DestroyObject(ID);
}
}
Last edited by foxtacles; 04-04-2013 at 02:53 AM.
-
Code cpp:
Void VAULTSCRIPT OnSpawn(ID object) noexcept
{
Player player(object);
if (player)
{
player.UIMessage("Hello, " + player.GetBaseName() + "!");
player.AddItem({
{ALCH::NukaCola, 100}, // 100x Nuka Cola
{WEAP::Weap32CaliberPistol, 1, 80.0, True, True}, // .32 pistol, 80% health, equipped
{AMMO::Ammo32Caliber, 300}, // 300x .32 ammo
});
}
}
Works as well
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules