Page 38 of 396
Re: Ask a simple question, get a simple answer
Posted: Sun Dec 28, 2014 10:54 am
by JKos
minmay wrote:
...
Well, you cannot overwrite the native addConnector method as far as I know, so you can't use that
exact code. You would use something like this:
Code: Select all
function myTestSpawn()
local o = spawn("rope", party.level, party.x, party.y, 0, party.elevation)
fw.script:set(o.id..'@item.whateverNamespaceYouWant.onEquipItem',aaa)
fw.script:set(o.id..'@item.whateverNamespaceYouWant.onUnequipItem',bbb)
end
function aaa()
print("A")
end
function bbb()
print("B")
end
Also if the hook framework works similarly to how it does in LoG1 (I haven't tested) function ownership will change from this script component to the fw script if the game is saved and reloaded, so you need to account for that (only reference the global environment in the function).
Yes, that should work, but you should be aware that functions aaa and bbb will be copied when the game is saved, so every item will have their own copies of those functions, I think this is what you meant by "function ownership will change from this script component to the fw script". It's an effect of the serialization method of LoG, references can not be serialized instead the referenced object/fuction will be copied.
If you want to avoid that you should define those hooks like this:
Code: Select all
function myTestSpawn()
local o = spawn("rope", party.level, party.x, party.y, 0, party.elevation)
fw.script:set(o.id..'@item.whateverNamespaceYouWant.onEquipItem',function(hook,item,champion,slot)
your.script.aaa(item,champion,slot)
end)
fw.script:set(o.id..'@item.whateverNamespaceYouWant.onUnequipItem',function(hook,item,champion,slot)
your.script.bbb(item,champion,slot)
end)
end
Tip: With cloneObject you can easily register framework hooks to all items.
Code: Select all
modifyObjects{
filter = {
hasComponents = {"item"}
},
components = {
fw_addHooks{
class = 'Item',
}
}
}
This may be a wrong thread for this discussion, so if you have more questions about the framework, we should continue in the framework thread:
viewtopic.php?f=22&t=8345
Re: Ask a simple question, get a simple answer
Posted: Sun Dec 28, 2014 6:08 pm
by Ciccipicci
There's a way to implement a particle effect like the first LoG when a quake is happening?
Re: Ask a simple question, get a simple answer
Posted: Mon Dec 29, 2014 5:53 pm
by AndakRainor
Is there a way to see all the icons and spell icons available (in their numeric codes order) ? I have a lot of custom spells (with the same icons for now) and I would like to choose their icons without testing every code number with the editor ^^
Also, if no icon matches the spell theme, is there a way to add custom icons ?
Re: Ask a simple question, get a simple answer
Posted: Sun Jan 04, 2015 7:52 am
by TheLastOrder
What am I doing wrong?
Code: Select all
for i in alcove1:containedItems() do
weight = weight + i:getWeight()
returns a nil value for containedItems.
If i put alcove1.surface, same thing.
Thanks in advance!
Re: Ask a simple question, get a simple answer
Posted: Sun Jan 04, 2015 8:55 am
by minmay
There is no containedItems() method on any object or component in Grimrock 2.
Instead you want the contents() method of SurfaceComponent.
Code: Select all
for i in alcove1.surface:contents() do
Re: Ask a simple question, get a simple answer
Posted: Sun Jan 04, 2015 10:02 am
by TheLastOrder
minmay wrote:There is no containedItems() method on any object or component in Grimrock 2.
Instead you want the contents() method of SurfaceComponent.
Code: Select all
for i in alcove1.surface:contents() do
Credited!
Re: Ask a simple question, get a simple answer
Posted: Sun Jan 04, 2015 4:55 pm
by Ixnatifual
How do I setup a default party for a mod? The old method of creating a default_party.dat file from a save and putting it in the mod_assets folder doesn't appear to work for LoG2.
Re: Ask a simple question, get a simple answer
Posted: Mon Jan 05, 2015 10:08 am
by TheStoryteller01
This works fine for the displayed text "Shadow earns 200 XP from the Scholar's Quest"
Code: Select all
hudPrint(party.party:getChampion(1):getName().." earns 200 XP from the Druid's Quest")
Ultimately I would prefer the text to be "DRUID QUEST: Shadow earns 200 XP for discovering a stone circle" but I can't manage to make
Code: Select all
party.party:getChampion(1):getName()..
work inside the " ".
Is this possible at all and if yes, how?
Re: Ask a simple question, get a simple answer
Posted: Mon Jan 05, 2015 10:19 am
by cameronC
TheStoryteller01 wrote:This works fine for the displayed text "Shadow earns 200 XP from the Scholar's Quest"
Code: Select all
hudPrint(party.party:getChampion(1):getName().." earns 200 XP from the Druid's Quest")
Ultimately I would prefer the text to be "DRUID QUEST: Shadow earns 200 XP for discovering a stone circle" but I can't manage to make
Code: Select all
party.party:getChampion(1):getName()..
work inside the " ".
Is this possible at all and if yes, how?
Code: Select all
hudPrint("DRUID'S QUEST: "..party.party:getChampion(1):getName().." earns 200 XP for discovering a stone circle.")
Re: Ask a simple question, get a simple answer
Posted: Mon Jan 05, 2015 10:30 am
by TheStoryteller01
cameronC wrote:Code: Select all
hudPrint("DRUID'S QUEST: "..party.party:getChampion(1):getName().." earns 200 XP for discovering a stone circle.")
Tested it and it works perfectly - thanks a lot!