Page 37 of 376

Re: Ask a simple question, get a simple answer

Posted: Fri Dec 26, 2014 8:50 pm
by Slade
minmay wrote:Check the box that says "disableSelf".
Thanks, god damn i feel stupid :lol:

Re: Ask a simple question, get a simple answer

Posted: Sat Dec 27, 2014 6:33 pm
by cameronC
I don't suppose anyone has an answer/work around to get addConnector to work with item hooks yet?
(Related to this thread and some others...)

Re: Ask a simple question, get a simple answer

Posted: Sat Dec 27, 2014 9:29 pm
by NutJob
cameronC wrote:I don't suppose anyone has an answer/work around to get addConnector to work with item hooks yet?
(Related to this thread and some others...)
I haven't seen an update yet to the software so I don't think we can yet. It was my primary reason to set LoG2 coding aside and just lurk around the forums.

Re: Ask a simple question, get a simple answer

Posted: Sun Dec 28, 2014 12:06 am
by minmay
What? Of course there is a workaround, you have scripting access to all the hooks that connectors do. In fact, all of the work has already been done for you, over a month ago.

Re: Ask a simple question, get a simple answer

Posted: Sun Dec 28, 2014 12:48 am
by NutJob
minmay wrote:What? Of course there is a workaround, you have scripting access to all the hooks that connectors do. In fact, all of the work has already been done for you, over a month ago.
So you can make this work...

Code: Select all

function myTestSpawn()
   local o = spawn("rope", party.level, party.x, party.y, 0, party.elevation)
   o.item:addConnector("onEquipItem", "lib", "aaa")
   o.item:addConnector("onUnequipItem", "lib", "bbb")
end

function aaa()
   print("A")
end

function bbb()
   print("B")
end

...without an error?

Re: Ask a simple question, get a simple answer

Posted: Sun Dec 28, 2014 1:56 am
by minmay
NutJob wrote:
minmay wrote:What? Of course there is a workaround, you have scripting access to all the hooks that connectors do. In fact, all of the work has already been done for you, over a month ago.
So you can make this work...

Code: Select all

function myTestSpawn()
   local o = spawn("rope", party.level, party.x, party.y, 0, party.elevation)
   o.item:addConnector("onEquipItem", "lib", "aaa")
   o.item:addConnector("onUnequipItem", "lib", "bbb")
end

function aaa()
   print("A")
end

function bbb()
   print("B")
end

...without an error?
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).

Re: Ask a simple question, get a simple answer

Posted: Sun Dec 28, 2014 8:16 am
by instablemonster
How do I put a delay in between the activate and deactivate ?

Code: Select all

function teleporterrotation()
	teleporter_13.controller:activate() 
	teleporter_13.controller:deactivate()
end

Re: Ask a simple question, get a simple answer

Posted: Sun Dec 28, 2014 8:37 am
by minmay
Since the teleporter object has a ControllerComponent named "controller", you can use the global delayedCall function:

Code: Select all

function teleporterrotation()
   teleporter_13.controller:activate()
  delayedCall("teleporter_13",1.5,"deactivate")
end
to deactivate the teleporter after 1.5 seconds.

Re: Ask a simple question, get a simple answer

Posted: Sun Dec 28, 2014 9:03 am
by instablemonster
minmay wrote:Since the teleporter object has a ControllerComponent named "controller", you can use the global delayedCall function:

Code: Select all

function teleporterrotation()
   teleporter_13.controller:activate()
  delayedCall("teleporter_13",1.5,"deactivate")
end
to deactivate the teleporter after 1.5 seconds.
Thank you !

Re: Ask a simple question, get a simple answer

Posted: Sun Dec 28, 2014 10:53 am
by Mentok
Here's a simple question: I was trying to use setAiState to shift a monster from guard to its default ai state, but I really have no idea what i'm doing. Any help would be greatly appreciated. :D