Spawn Scroll and setScrollText

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!
OGDA
Posts: 115
Joined: Tue Oct 28, 2014 5:07 pm

Spawn Scroll and setScrollText

Post 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
User avatar
Lark
Posts: 178
Joined: Wed Sep 19, 2012 4:23 pm
Location: Springfield, MO USA

Re: Spawn Scroll and setScrollText

Post by Lark »

You almost had it...

Code: Select all

local message = spawn("scroll")
message.scrollitem:setScrollText("This is an important\nmessage!")
OGDA
Posts: 115
Joined: Tue Oct 28, 2014 5:07 pm

Re: Spawn Scroll and setScrollText

Post 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
User avatar
Lark
Posts: 178
Joined: Wed Sep 19, 2012 4:23 pm
Location: Springfield, MO USA

Re: Spawn Scroll and setScrollText

Post 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
OGDA
Posts: 115
Joined: Tue Oct 28, 2014 5:07 pm

Re: Spawn Scroll and setScrollText

Post by OGDA »

Works perfectly and thank you again for all the information! :)
User avatar
THOM
Posts: 1274
Joined: Wed Nov 20, 2013 11:35 pm
Location: Germany - Cologne
Contact:

Re: Spawn Scroll and setScrollText

Post 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?
THOM formaly known as tschrage
_______________________________________________
My MOD (LoG1): Castle Ringfort Thread
My MOD (LoG2): Journey To Justice Thread | Download
User avatar
JohnWordsworth
Posts: 1397
Joined: Fri Sep 14, 2012 4:19 pm
Location: Devon, United Kingdom
Contact:

Re: Spawn Scroll and setScrollText

Post 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!
Last edited by JohnWordsworth on Sun Feb 01, 2015 8:47 pm, edited 1 time in total.
My Grimrock Projects Page with links to the Grimrock Model Toolkit, GrimFBX, Atlas Toolkit, QuickBar, NoteBook and the Oriental Weapons Pack.
User avatar
THOM
Posts: 1274
Joined: Wed Nov 20, 2013 11:35 pm
Location: Germany - Cologne
Contact:

Re: Spawn Scroll and setScrollText

Post 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);
THOM formaly known as tschrage
_______________________________________________
My MOD (LoG1): Castle Ringfort Thread
My MOD (LoG2): Journey To Justice Thread | Download
User avatar
JohnWordsworth
Posts: 1397
Joined: Fri Sep 14, 2012 4:19 pm
Location: Devon, United Kingdom
Contact:

Re: Spawn Scroll and setScrollText

Post by JohnWordsworth »

Ooops - well spotted THOM. I wrote my reply on my iPad. I've updated my post so it's correct :).
My Grimrock Projects Page with links to the Grimrock Model Toolkit, GrimFBX, Atlas Toolkit, QuickBar, NoteBook and the Oriental Weapons Pack.
User avatar
Drakkan
Posts: 1318
Joined: Mon Dec 31, 2012 12:25 am

Re: Spawn Scroll and setScrollText

Post 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
Breath from the unpromising waters.
Eye of the Atlantis
Post Reply