Page 1 of 1
Simple question about scrolls
Posted: Fri Dec 30, 2016 8:02 pm
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.
Re: Simple question about scrolls
Posted: Fri Dec 30, 2016 8:33 pm
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.
Re: Simple question about scrolls
Posted: Sat Dec 31, 2016 5:51 am
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