Spawing a custom letter into inventory

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!
Post Reply
User avatar
TheStoryteller01
Posts: 20
Joined: Wed Dec 31, 2014 3:29 am
Contact:

Spawing a custom letter into inventory

Post by TheStoryteller01 »

So far I can manage to spawn a stock letter into a hero's inventory

Code: Select all

function getlitem()
	if party.party:getChampion(1):getEnabled() then
   party.party:getChampion(1):insertItem(32,spawn("letter").item)
   end
end
but I can't incorporate the custom text. I tried

Code: Select all

setScrollText("Test")
but I can't get the syntax right

Any help would be appreciated.
User avatar
JohnWordsworth
Posts: 1397
Joined: Fri Sep 14, 2012 4:19 pm
Location: Devon, United Kingdom
Contact:

Re: Spawing a custom letter into inventory

Post by JohnWordsworth »

Here is a sample script_entity that will give you an example of what you want to do. Note, in this case, I have done it in a delayedCall because the party's inventory seems to be wiped (reloaded) after the script_entities are loaded, but as long as you run "doIt" after the game has started (or probably even in the real game), it doesn't need to be delayed.

Code: Select all

function doIt()
	if party.party:getChampion(1):getEnabled() then
		local letter = spawn("letter");
		letter.scrollitem:setScrollText("TEST");
		party.party:getChampion(1):insertItem(32, letter.item);
	end
end

delayedCall("test", 0.01, "doIt");
My Grimrock Projects Page with links to the Grimrock Model Toolkit, GrimFBX, Atlas Toolkit, QuickBar, NoteBook and the Oriental Weapons Pack.
User avatar
TheStoryteller01
Posts: 20
Joined: Wed Dec 31, 2014 3:29 am
Contact:

Re: Spawing a custom letter into inventory

Post by TheStoryteller01 »

It works perfectly, thank you!

Actually I run it triggered from a floor trigger as the second script in a row. The first one cleans the inventory and adds starting equipment and so far the whole setup works with or without the delay.
Post Reply