Page 1 of 2
Spawn Scroll and setScrollText
Posted: Tue Oct 28, 2014 11:21 pm
by OGDA
Hello,
I'm trying to spawn a scroll in front of the party and set the text written on the scroll (long text) in Grimrock 2.
local message = spawn("scroll")
message:setScrollText("This is an important\nmessage!")
According to the search this seems to have worked in the editor of Grimrock 1 (have not used that editor).
Unfortunately in Grimrock 2 I get the error message: attempt to call method setScrollText (a nil value).
Does anyone know the solution to this error?
Kind regards,
Joerg
Re: Spawn Scroll and setScrollText
Posted: Wed Oct 29, 2014 6:20 am
by Lark
You almost had it...
Code: Select all
local message = spawn("scroll")
message.scrollitem:setScrollText("This is an important\nmessage!")
Re: Spawn Scroll and setScrollText
Posted: Wed Oct 29, 2014 12:11 pm
by OGDA
Thank you very much!
I'll try it as soon as I get home.
Is there any reference source where I can check the objects? (how did you know the solution?)
Kind regards,
Jörg
Re: Spawn Scroll and setScrollText
Posted: Wed Oct 29, 2014 5:25 pm
by Lark
Check out this thread:
viewtopic.php?f=22&t=7882. JKos did a fantastic job of finding classes and methods using a hex editor! I copied the text to an editor, searched for "scroll" and found the section:
Code: Select all
class ScrollItemComponent
setScrollText(string)
setScrollImage(string)
setTextAlignment(string)
getScrollText
getScrollImage
getTextAlignment
enable
disable
isEnabled
addConnector(string,string,string)
Note the
setScrollText(string) entry. I suspected, from the heading of "ScrollItemComponent" that I really needed just
scrollitem, but I verified this by placing a scroll manually, selecting it, and noting the component list. If you do so, you will see
model,
item, and
scrollitem. Also note that you can set the text under
scrollitem. So the code simply became
<object name>.<component>:<methdod>(<arguments>) - specifically in your case,
message.scrollitem:setScrollText("This is an important\nmessage!")
I hope this helps, -Lark
Re: Spawn Scroll and setScrollText
Posted: Wed Oct 29, 2014 7:29 pm
by OGDA
Works perfectly and thank you again for all the information! :)
Re: Spawn Scroll and setScrollText
Posted: Sun Feb 01, 2015 5:28 pm
by THOM
I am trying to spawn a Note (in a socket) at gamestart. Spawning the note is not the problem - but the text is.
I am trying something like
Code: Select all
dungeon_socket_wall_1.socket:addItem(spawn("note").item).scrollitem:setScrollText("This is an important message!")
..but doesn't seem to be right. Does anyone know, how to do this?
Re: Spawn Scroll and setScrollText
Posted: Sun Feb 01, 2015 7:09 pm
by JohnWordsworth
You might want to unroll your script to make it more readable.
Code: Select all
local note = spawn("note");
note.scrollitem:setScrollText(...);
dungeon_socket_wall_1.socket:addItem(note.item);
Note. The word local is important here to prevent save game issues!
Re: Spawn Scroll and setScrollText
Posted: Sun Feb 01, 2015 7:59 pm
by THOM
Ah . thanks, John.
I still got some errors but could figure out how to manage it:
local note = spawn("note");
note.scrollitem:setScrollText("important note");
dungeon_socket_wall_1.socket:addItem(note.item);
Re: Spawn Scroll and setScrollText
Posted: Sun Feb 01, 2015 8:47 pm
by JohnWordsworth
Ooops - well spotted THOM. I wrote my reply on my iPad. I've updated my post so it's correct
.
Re: Spawn Scroll and setScrollText
Posted: Mon Feb 02, 2015 2:32 pm
by Drakkan
guys how can i spawn some item directly to the "cursor" (like if I grab some item) ? it is possible ? Also it could somehow check that party is not already holding some item (if yes, than spawn the object on the floor before party instead). thanks for any advice