-- LUA Script - precede every function and global member with lowercase name of script + '_main' -- DESCRIPTION: Ladder Climbing Script -- DESCRIPTION: This script is to be attached to the ladder? local P = require "scriptbank\\physlib" local ladderactive = {} local moveup = {} local playeratx = {} local playeratz = {} local ladderheight = {} function ladder_init(e) Include( "physlib.lua" ) ladderactive[e] = 0 moveup[e] = 0 ladderheight[e] = 0 end -- init function ladder_main(e) playeratx[e] = 0 playeratz[e] = 0 if math.abs(g_PlayerPosX - g_Entity[e]['x']) < 25 then --Prompt("Press 'W' to climb up 'S' to climb down") playeratx[e] = 1 if math.abs(g_PlayerPosZ - g_Entity[e]['z']) < 25 then playeratz[e] = 1 if ladderactive[e] == 0 then --Set ladder height-------------------------------------- local dims = P.GetObjectDimensions ( e ) Prompt( "Object height=" .. dims.h * 2) ladderheight[e] = dims.h * 2 --End Set ladder height---------------------------------- moveup[e] = g_PlayerPosY ladderactive[e] = 1 end end end if playeratx[e] + playeratz[e] < 2 then ladderactive[e] = 0 end if ladderactive[e] == 1 then --------- on ladder so activate climb --Prompt("Press 'A,X,D' to exit ladder") if g_Scancode == 17 then if moveup[e] < g_Entity[e]['y'] + ladderheight[e] then moveup[e] = moveup[e] + 2 end -- 'W' up end if g_Scancode == 31 then if moveup[e] > g_Entity[e]['y'] + 35 then moveup[e] = moveup[e] - 2 end -- 'S' down end if g_Scancode == 45 then ForcePlayer( g_PlayerAngY + 180, 1) end -- 'X' to exit ladder if g_Scancode == 30 then ForcePlayer( g_PlayerAngY - 90, 1) end -- 'A' left if g_Scancode == 32 then ForcePlayer( g_PlayerAngY + 90, 1) end -- 'D' right SetFreezePosition(g_PlayerPosX, moveup[e], g_PlayerPosZ) TransportToFreezePositionOnly() end --------- on ladder so activate climb end -- main