Simple question about scrolls
Simple question about scrolls
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.
- Zo Kath Ra
- Posts: 944
- Joined: Sat Apr 21, 2012 9:57 am
- Location: Germany
Re: Simple question about scrolls
Use \n to include newlines in a string: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.
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)
endI 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
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:
*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