User:Erorr404/Editor/pseudocode

From Multi Theft Auto: Wiki
< User:Erorr404
Revision as of 23:50, 10 March 2007 by Erorr404 (talk | contribs)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigation Jump to search

CLIENT:

// NEEDED CLIENT FUNCTIONS:
// setFreeCam(bool on)
// mountElementToCam(element theElem, float distance)
// unMountElementToCam()
// moveElement(element theElem, float x, float y, float z, int milliseconds)
// stopElementMoving(element theElem)
// rotateElement(element theElem, float rx, float ry, float rz, int milliseconds)

local selectedElement = nil

function onClientResourceLoad
	setFreeCam(true)
	bindKeys()
end

function bindKeys()
	// bind selection keys
	bindKey("mouse1", "onPlayerLeftClick")
	bindKey("mouse2", "onPlayerRightClick")
	// bind movement keys
	bindKey("up", "moveElementUp")
	bindKey("down", "moveElementDown")
	bindKey("left", "moveElementLeft")
	bindKey("right", "moveElementRight")
end

//sets selectedElement if a player clicks on one
function onPlayerLeftClick()
	if (selectedElem) then
		unMountElementToCam()
		selectedElem = nil
	else
		x1, y1, z1 = getCamPos()
		r = getCamRot()
		x2, y2, z2 = some trig stuff
		elem = processLineOfSite(x1, y1, z1, x2, y2, z2)
		if (elem) then
			mountElementToCam(elem, 10)
			selectedElement = elem
		end
	end
end

function onPlayeRightClick()
end

function moveElementUp(key, keySTate)
	if (selectedElement) then
		if (keyState == "down") then
			moveElement(selectedElement, ...) // move up
		else
			stopElementMoving(selectedElement)
		end
	end
end

function moveElementDown(key, keySTate)
	// similar to above
	...
end

function moveElementRight(key, keySTate)
	// similar to above
	...
end

function moveElementLeft(key, keySTate)
	// similar to above
	...
end


SERVER: