Page 1 of 1

Spawm a item into, Sack rename it, add text

Posted: Sat Sep 14, 2013 11:59 pm
by Eleven Warrior
Hi guys'...

I am trying to spawn a tome into a sack, rename the tome, and then setscrolltext.

Ie:

s3:addItem(spawn("the_king", "The_King_Volume_1")):setScrollText([[

Onec apon a time, long ago etc.........................

]]))

I tried the above code but it wants a number..I think it wants the Spawn location..

s3: Is the sack name..
the_king: Is the tome name.. and I want to rename it to The King Volume 1

Thxs for any help, I did do this before but I cant remember how I did it.....

Re: Spawm a item into, Sack rename it, add text

Posted: Sun Sep 15, 2013 12:09 am
by Dr.Disaster
Eleven Warrior wrote: I am trying to spawn a tome into a sack, rename the tome, and then setscrolltext.

Ie:

s3:addItem(spawn("the_king", "The_King_Volume_1")):setScrollText([[

Onec apon a time, long ago etc.........................

]]))
from Scripting reference:

Item:setScrollText(text)
Sets the text for a scroll item. Lines are separated with ā€˜\n’ characters.

Item:addItem(item)
Adds a given item to a free container slot.


Seems you need to prepare the item you want to add before actually adding it i.e.
first
cloneObject{
name = "The_King_Volume_1",
baseObject = "the_king",
description = "Once upon a time .."
}
then s3:addItem("The_King_Volume_1")

Yet i don't think that setScrollText() will work with a book ...

Re: Spawm a item into, Sack rename it, add text

Posted: Sun Sep 15, 2013 12:14 am
by Eleven Warrior
Hii Doc...

This my Object

defineObject{
name = "the_king",
baseObject = "scroll",
uiName = "King Of Humans",
class = "Item",
model = "assets/models/items/tome.fbx",
gfxIndex = 30,
scroll = true,
weight = 0.3,
description = "This book was written by a king.",
}

At the end of this can I just add setScrollText(([[ ]])) I tried this and had a error of sorts

defineObject{
name = "the_king",
baseObject = "scroll",
uiName = "King Of Humans",
class = "Item",
model = "assets/models/items/tome.fbx",
gfxIndex = 30,
scroll = true,
weight = 0.3,
setScrollText([[ Once long ago etc..............
]]))
description = "This book was written by a king.",
}

Would this work, I think I tried this and it crashed
THXS

Re: Spawm a item into, Sack rename it, add text

Posted: Sun Sep 15, 2013 12:34 am
by Eleven Warrior
This is one I have already done.. I made a object called (gludo's_recipe_boof_1) and did the below script..
Recipe2 Is the name of the Sack...

All I want to do is rename gludo's_recipe_book_1 to gludo's_recipe_book_3

Recipe2:addItem(spawn("gludo's_recipe_book_1"new name here):setScrollText([[

Sage Gludo's: Famous Alchemy. Volume 1

Potion Healing
ingredients :
1 Flask
1 Night Bead or Tar Bead

Potion Energy
ingredients:
1 Flask
1 Blooddrop Blossom or Dewdroop Root
]]))

Re: Spawm a item into, Sack rename it, add text

Posted: Sun Sep 15, 2013 12:37 am
by Dr.Disaster
As said above you can't rename an item in an inline-statement. Clone a copy with the right name and place that one. setScrollText() works with scroll items only and you set "scroll = true" as needed so all you need to do is the cloneObject to rename your book.

Re: Spawm a item into, Sack rename it, add text

Posted: Sun Sep 15, 2013 1:13 am
by Eleven Warrior
Thanks Doc it works..