Page 1 of 1

New Lua Function: UseWidget(Spawn)

Posted: Tue Jul 31, 2012 5:11 pm
by Jabantiz
I added this to help me test the acorn lift and realised it could be used to make the lifts work on their own. This is the spawn script I used and it works great, if the widget is set up properly.

Code: Select all

function spawn(NPC)
	AddTimer(NPC, 15, "LiftUse")
end

function respawn(NPC)
	spawn(NPC)
end

function LiftUse(NPC, Spawn)
	UseWidget(NPC)
	AddTimer(NPC, 15, "LiftUse")
end
It is set to 15 secs right now but should probably be bumped up, it worked great for me though. Just assign this script to the lift and watch it go.

Re: New Lua Function: UseWidget(Spawn)

Posted: Wed Aug 01, 2012 9:27 pm
by John Adams
That's cool, Jab. Always wanted lifts to actually... lift :)

Consider this for long-term design, since Lifts/elevators have previously been considered "doors" of one type or another (levers, buttons, widgets, etc), think about how to design a parameter maybe in spawn_widgets to tie the LUA Script to that widget entry, and either use open/close timers or create a new field "delay" or something to push to the LUA. This way, we're not having to hard-code timers in a LUA file, it can be a parameter.

No hurry, just think about it.

Re: New Lua Function: UseWidget(Spawn)

Posted: Fri Jul 10, 2015 10:36 pm
by Jabantiz
UseWidget() will now also trigger a linked widget, just like if you clicked on it.