Simple question about scrolls

Talk about creating Grimrock 1 levels and mods here. Warning: forum contains spoilers!
Post Reply
Pandru
Posts: 3
Joined: Sun Feb 28, 2016 7:35 am

Simple question about scrolls

Post by Pandru »

I know this is a pretty dumb question but I can't find the answer anywhere I look. I'm using script_entity to spawn a scroll in a container, but what I can't figure out is how to split up the scroll's text into separate lines so it isn't one long run-on sentence. If someone could help with this I'd be very grateful.
User avatar
Zo Kath Ra
Posts: 944
Joined: Sat Apr 21, 2012 9:57 am
Location: Germany

Re: Simple question about scrolls

Post by Zo Kath Ra »

Pandru wrote:I know this is a pretty dumb question but I can't find the answer anywhere I look. I'm using script_entity to spawn a scroll in a container, but what I can't figure out is how to split up the scroll's text into separate lines so it isn't one long run-on sentence. If someone could help with this I'd be very grateful.
Use \n to include newlines in a string:

Code: Select all

local sack = findEntity("sack_1")

if (sack) and (sack.containeritem) then
	local scroll = spawn("scroll", party.level, party.x, party.y, party.facing, party.elevation)
	scroll.scrollitem:setScrollText("this\nis\na\nmulti-line\ntext")
	
	sack.containeritem:addItem(scroll.item)
end
edit:
I just noticed that your question was for LoG1.
The code probably won't work in LoG1, but \n for newline will.

http://www.grimrock.net/modding_log1/sc ... reference/
Item:setScrollText(text)
Sets the text for a scroll item. Lines are separated with ‘\n’ characters.
User avatar
Isaac
Posts: 3191
Joined: Fri Mar 02, 2012 10:02 pm

Re: Simple question about scrolls

Post by Isaac »

LoG1 doesn't have the component model; so there is no .containeritem; and addItem() does not accept an item component.
*Also, if the script first spawns an item at a location, then adds it to the sack, it will appear on the ground as well as inside the sack.
(This makes two identical items, and will crash the game if the player puts both on the ground.)

Adjusted:

Code: Select all

	local sack = findEntity("sack_1")
	if sack then  
		sack:addItem(spawn("scroll"):setScrollText("this\nis\na\nmulti-line\ntext"))
	end
Post Reply