Ask for help about creating mods and scripts for Grimrock 2 or share your tips, scripts, tools and assets with other modders here. Warning: forum contains spoilers!
I'm doing a mod whereby the party start off with some items. The items are spawned in their hands at the start of the game as I intended, but this is the strange bit. At first, in the editor screen, you cant use them (clicking on them doesn't do anything). If you refresh the editor, then they work as intended. If you pick the said items up and put them in their hands, rather than spawning them, it works. I've exported the mod to test, and the items don't do anything in their hands. Clicking doesn't work. Any ideas? My code is below:
You should not insert the same item twice as in this code. Even if you need 2 "baton" items, you should spawn one for each champion's slot where you want to place it.
local startwep1 = spawn("baton");
party.party:getChampion(1):insertItem(1,startwep1.item);
local startwep2 = spawn("baton");
party.party:getChampion(2):insertItem(1,startwep2.item);
local startwep1 = spawn("baton");
party.party:getChampion(1):insertItem(1,startwep1.item);
local startwep2 = spawn("baton");
party.party:getChampion(2):insertItem(1,startwep2.item);
Nothing works. If you load up the mod first time into the editor, the items are there but nothing happens if you click on them. It is the same if you export it, they don't work. But if you load the mod into the editor, then refresh it a couple of times, they do work. Totally baffled.
function startItems()
local i = 1
repeat
if party.party:getChampion(1):getEnabled() then
party.party:getChampion(1):removeItemFromSlot(i)
end
if party.party:getChampion(2):getEnabled() then
party.party:getChampion(2):removeItemFromSlot(i)
end
if party.party:getChampion(3):getEnabled() then
party.party:getChampion(3):removeItemFromSlot(i)
end
if party.party:getChampion(4):getEnabled() then
party.party:getChampion(4):removeItemFromSlot(i)
end
i = i + 1
until i == 33
if party.party:getChampion(1):getEnabled() then
party.party:getChampion(1):insertItem(2,spawn("torch").item)
party.party:getChampion(1):insertItem(4,spawn("lurker_vest").item)
party.party:getChampion(1):insertItem(5,spawn("voyager_pants").item)
party.party:getChampion(1):insertItem(6,spawn("voyager_boots").item)
party.party:getChampion(1):insertItem(7,spawn("voyager_cloak").item)
party.party:getChampion(1):insertItem(9,spawn("voyager_gloves").item)
party.party:getChampion(1):insertItem(13,spawn("bread").item)
party.party:getChampion(1):insertItem(14,spawn("water_flask").item)
party.party:getChampion(1):insertItem(15,spawn("water_flask").item)
party.party:getChampion(1):insertItem(16,spawn("turtle_eggs").item)
party.party:getChampion(1):insertItem(17,spawn("secret_key").item)
end
if party.party:getChampion(2):getEnabled() then
party.party:getChampion(2):insertItem(4,spawn("voyager_valor").item)
party.party:getChampion(2):insertItem(5,spawn("silk_hose").item)
party.party:getChampion(2):insertItem(6,spawn("voyager_boots").item)
party.party:getChampion(2):insertItem(7,spawn("voyager_cloak").item)
party.party:getChampion(2):insertItem(9,spawn("voyager_gloves").item)
end
if party.party:getChampion(3):getEnabled() then
party.party:getChampion(3):insertItem(4,spawn("voyager_valor").item)
party.party:getChampion(3):insertItem(5,spawn("voyager_pants").item)
party.party:getChampion(3):insertItem(6,spawn("shoes").item)
party.party:getChampion(3):insertItem(7,spawn("voyager_cloak").item)
party.party:getChampion(3):insertItem(9,spawn("voyager_gloves").item)
end
if party.party:getChampion(4):getEnabled() then
party.party:getChampion(4):insertItem(4,spawn("doublet").item)
party.party:getChampion(4):insertItem(5,spawn("silk_hose").item)
party.party:getChampion(4):insertItem(6,spawn("shoes").item)
party.party:getChampion(4):insertItem(7,spawn("voyager_cloak").item)
party.party:getChampion(4):insertItem(9,spawn("voyager_gloves").item)
end
end
put it in a script entity and connect a timer to it, where your party start.
The timer should be running when you start the map and disable itself right after.
Thanks for that. Didn't realise that I had to delay the script first. Not like LOG1. Working fine now. Thanks again for all your help (as always!)
George