RoboMat Posted September 20, 2013 Share Posted September 20, 2013 Well yeah I've run into a problem I can't find a solution to: I call TimedActions from my context menus like this: UI-ScriptISTimedActionQueue.add(TABreakDoorLock:new(player, door, time, primItem)); Construtor in the timed actionTABreakDoorLock = ISBaseTimedAction:derive("TABreakDoorLock"); ... function TABreakDoorLock:new(_character, _object, _time, _primItem) local o = {}; setmetatable(o, self); self.__index = self; o.character = _character; o.object = _object; o.storedPrim = _primItem; o.stopOnWalk = false; o.stopOnRun = false; o.maxTime = _time; return o;end It throws the following error:-----------------------------------------STACK TRACE-----------------------------------------function: breakLock -- file: UIDoorMenu.lua line # 73function: onMouseUp -- file: ISContextMenu.lua line # 70attempted index: new of non-table: null Any ideas? Link to comment Share on other sites More sharing options...
RoboMat Posted September 20, 2013 Author Share Posted September 20, 2013 I took another look at my scripts and noticed a slight difference. UIDoorMenu:local function pickLock(...) local function breakLock(...) local function isValid(...) local function createMenuEntries(...)=> call order in createMenuEntries: 3, 1, 2 UIWindowMenu:local function isValid(...) local function breakLock(...) local function createMenuEntries(...)=> call order in createMenuEntries: 1, 2 I didn't think that this mattered to lua, but apparently it does, because after changing the call order of the createMenuEntries(...) function in UIDoorMenu to 1, 2, 3 it worked like a charm. Hope my explanation is understandable. If not just post a reply. Okay I can't help but come to the conclusion that it is a problem with khalua itself. I have two UI scripts. One for the opening of doors and one for the opening of windows. Both only use local functions, e.g.: -- Does not Worklocal function breakLock(_worldObjects, _door, _player) local player = _player; local door = _door; local modData = door:getModData(); local time = 50; -- Traits affect the length of the lockbreaking. if player:HasTrait("Strong") or player:HasTrait("Handy") then time = time - ZombRand(40); elseif player:HasTrait("Weak") or player:HasTrait("Nimble") then time = time + ZombRand(50); end -- Add time depending on the lock level. time = time + modData.lockLevel * 10; -- Walk to the door and start the Timed Action. if Utility.walkToObject(player, door) then local primItem = Utility.equipItems(player, "Base.Crowbar"); ISTimedActionQueue.add(TABreakDoorLock:new(player, door, time, primItem)); endend-- Does worklocal function forceWindow(_worldobjects, _window, _player) local time = 25; if Utility.walkToObject(_player, _window) then local storePrim = Utility.equipItems(_player, "Base.Crowbar"); ISTimedActionQueue.add(TABreakWindowLock:new(_player, _window, time, storePrim)); endendIf I change the functions in UIDoorMenu to global it suddenly works though... This made me think that the problem is maybe that the local functions can't call the TimedAction because they aren't "there" when they are compiled but that doesn't explain why the "forceWindow" function works without problems. Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now