Page 1 of 2
Writing the result of a function on a scroll ?
Posted: Thu Nov 13, 2014 10:52 pm
by cromcrom
I all, I would like to have the list of my custom skills, and their values, appear on a scroll (from a function that would return this, to make things easier). However, ScrollText doesn"t seem to allow this. I also tried to make the scroll usable, but it disappears when used. Any idea please ?
Re: Writing the result of a function on a scroll ?
Posted: Thu Nov 13, 2014 11:35 pm
by QuintinStone
You would do it like this:
scroll_1.scrollitem:setScrollText(myscript.getSkillInfo())
Re: Writing the result of a function on a scroll ?
Posted: Thu Nov 13, 2014 11:43 pm
by cromcrom
Thanks. But so, I cannot create an object like that,
Code: Select all
defineObject{ name = "skills_scroll_crom",
baseObject = "scroll",
components = {
{
class="ScrollItem",
ScrollText = (cromlibrary.scrolltextfunc()),
},
}
}
I would have to spawn it first, i guess.
Re: Writing the result of a function on a scroll ?
Posted: Fri Nov 14, 2014 12:03 am
by QuintinStone
Okay, if your code doesn't work as is, maybe you could set the text in the component's onInit()?
I'm new to Grimrock modding and lua, but...
Code: Select all
defineObject
{
name = "skills_scroll_crom",
baseObject = "scroll",
components = {
{
class="ScrollItem",
onInit = function (self)
self.scrollItem:setScrollText(cromlibrary.scrolltextfunc())
end
},
}
}
Then you'd just need to spawn one. Assuming onInit works like I think it does (I have not done any testing with it yet).
Re: Writing the result of a function on a scroll ?
Posted: Fri Nov 14, 2014 12:18 am
by cromcrom
Thanks for trying. The onInit hook is not a scrollItem class hook. I will give it a try with on equip.
Re: Writing the result of a function on a scroll ?
Posted: Fri Nov 14, 2014 12:19 am
by QuintinStone
cromcrom wrote:Thanks for trying. The onInit hook is not a scrollItem class hook. I will give it a try with on equip.
Doh, sorry, the scripting reference says it's part of the Component base class.
Re: Writing the result of a function on a scroll ?
Posted: Fri Nov 14, 2014 12:36 am
by Jgwman
What do you mean by "scrollText doesn't seem to allow this"? It doesn't seem very difficult, just set the text on the scroll to the function return value. Shouldn't need a custom asset. If it involves numbers pass the return to tostring() first. What am I missing here?
Re: Writing the result of a function on a scroll ?
Posted: Fri Nov 14, 2014 12:43 am
by cromcrom
No its me, I am not good at all this. Nothing worked. The closest I came was calling the function with scrollItem = (funct()), but I have to press F5 for the text to appear.
so if i put this function on top of the object.lua
Code: Select all
function scrolltextfunc()
return "blah blah blah"
end
and then create a skill scroll like that:
Code: Select all
defineObject{ name = "skills_scroll_crom",
baseObject = "scroll",
components = {
{
class="ScrollItem",
ScrollText = (scrolltextfunc())
},
}
}
and I add the scroll to the dungeon in the editor, "blah blah blah" will appear on the scroll, but only once I reload the dungeon by pressing F5. I would like it to appear right from the start, just like in good ol' LoG1 ^^
Re: Writing the result of a function on a scroll ?
Posted: Fri Nov 14, 2014 6:09 pm
by QuintinStone
cromcrom wrote:No its me, I am not good at all this. Nothing worked. The closest I came was calling the function with scrollItem = (funct()), but I have to press F5 for the text to appear.
...
and I add the scroll to the dungeon in the editor, "blah blah blah" will appear on the scroll, but only once I reload the dungeon by pressing F5. I would like it to appear right from the start, just like in good ol' LoG1 ^^
Well you have to hit F5 to reload the changes into the preview window.
Re: Writing the result of a function on a scroll ?
Posted: Fri Nov 14, 2014 9:37 pm
by cromcrom
Sure, but this doesn't work ingame. I am pretty pissed at these cumbersome gui contexts...
+ impossible to call functions from onuse, that makes items dissappeared, while it was so "easy" in log 1. it feels like a step backwards