Writing the result of a function on a scroll ?
- cromcrom
- Posts: 549
- Joined: Tue Sep 11, 2012 7:16 am
- Location: Chateauroux in a socialist s#!$*&% formerly known as "France"
Writing the result of a function on a scroll ?
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 ?
A trip of a thousand leagues starts with a step.
- QuintinStone
- Posts: 72
- Joined: Sat Nov 01, 2014 9:58 pm
Re: Writing the result of a function on a scroll ?
You would do it like this:
scroll_1.scrollitem:setScrollText(myscript.getSkillInfo())
scroll_1.scrollitem:setScrollText(myscript.getSkillInfo())
- cromcrom
- Posts: 549
- Joined: Tue Sep 11, 2012 7:16 am
- Location: Chateauroux in a socialist s#!$*&% formerly known as "France"
Re: Writing the result of a function on a scroll ?
Thanks. But so, I cannot create an object like that,
I would have to spawn it first, i guess.
Code: Select all
defineObject{ name = "skills_scroll_crom",
baseObject = "scroll",
components = {
{
class="ScrollItem",
ScrollText = (cromlibrary.scrolltextfunc()),
},
}
}
A trip of a thousand leagues starts with a step.
- QuintinStone
- Posts: 72
- Joined: Sat Nov 01, 2014 9:58 pm
Re: Writing the result of a function on a scroll ?
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...
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).
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
},
}
}
Crypt of Zulfar
- cromcrom
- Posts: 549
- Joined: Tue Sep 11, 2012 7:16 am
- Location: Chateauroux in a socialist s#!$*&% formerly known as "France"
Re: Writing the result of a function on a scroll ?
Thanks for trying. The onInit hook is not a scrollItem class hook. I will give it a try with on equip.
A trip of a thousand leagues starts with a step.
- QuintinStone
- Posts: 72
- Joined: Sat Nov 01, 2014 9:58 pm
Re: Writing the result of a function on a scroll ?
Doh, sorry, the scripting reference says it's part of the Component base class.cromcrom wrote:Thanks for trying. The onInit hook is not a scrollItem class hook. I will give it a try with on equip.
Crypt of Zulfar
Re: Writing the result of a function on a scroll ?
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?
- cromcrom
- Posts: 549
- Joined: Tue Sep 11, 2012 7:16 am
- Location: Chateauroux in a socialist s#!$*&% formerly known as "France"
Re: Writing the result of a function on a scroll ?
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
and then create a skill scroll like that:
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 ^^
so if i put this function on top of the object.lua
Code: Select all
function scrolltextfunc()
return "blah blah blah"
end
Code: Select all
defineObject{ name = "skills_scroll_crom",
baseObject = "scroll",
components = {
{
class="ScrollItem",
ScrollText = (scrolltextfunc())
},
}
}
A trip of a thousand leagues starts with a step.
- QuintinStone
- Posts: 72
- Joined: Sat Nov 01, 2014 9:58 pm
Re: Writing the result of a function on a scroll ?
Well you have to hit F5 to reload the changes into the preview window.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 ^^
Crypt of Zulfar
- cromcrom
- Posts: 549
- Joined: Tue Sep 11, 2012 7:16 am
- Location: Chateauroux in a socialist s#!$*&% formerly known as "France"
Re: Writing the result of a function on a scroll ?
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
+ impossible to call functions from onuse, that makes items dissappeared, while it was so "easy" in log 1. it feels like a step backwards
A trip of a thousand leagues starts with a step.