Jump to content

VicToMeyeZR

Members
  • Posts

    570
  • Joined

  • Last visited

Posts posted by VicToMeyeZR

  1.        function object:Update()
                   if GetGlobalString("mode") == "GAME_MODE" then
                           if MouseHit(1) == 1 then
                                   if MouseX() > object.location.x and MouseX() < object.location.x + object.size.x and MouseY() > object.location.y and MouseY() < object.location.y + object.size.y then
                                           object.color = Vec4(0, 1, 0, 1)
                                   end
                           end
                   else
                   end
           end
    

     

    This part right there. Thats what sets the color when you click on it.

  2. Its not as bad as it seems.. I didn't know a thing about Lua, other than it was a great scripting language before Josh implemented it..

     

    Take it one model or class at a time. you'll get it

  3. just don't blame Microsoft if some hacker's process then runs riot on your PC with full privileges :D

     

    I don't blame Microsoft, other than trying to copy Linux with there user system. (which fails so far)

     

    Pretty much everything runs just fine for me, since I turned off UAC, and I don't ever install anything in the Programs File directory.

     

    I just have to reboot at least 3 times a week, but thats a norm for windows anyways

  4. SendEntityMessage(31324672, "Hello World!");
    

     

    The first argument is a string/char, not an integer or float. That's the reason that doesn't work.

     

    I don't know if

     

    SendEntityMessage("31324672", "Hello World!");
    

     

    Will work or not, but that would be a string..

     

    I believe rick is right, that's probably an integer of the pointer?

  5. Not to start a flame or anything, but I think most of the problem is most programmers want to keep their (code) a secret. They don't want anyone else to see their coding ideas (probably for fear of someone stealing it), but its very hard to get a community involved with something like that..

     

    I personally think there is way more than enough knowledge here to make a great title with LE, but you have to get over that obstacle...

     

    I think if someone wanted to start a project like that, it would work. I think you would need to get a legal document with NDA's involved (Unless you made it an open source project), as well as the agreement of who gets what with the selling of it, and what the percent of profit involved would be (if there was any)..

     

    Personally I think maybe even a non-profit Leadwerks Community, ORG would be a good start. :)

  6. I believe it should be like that. Your Parent "House" doesn't tell the child to clear, just because you remove it. You must specify..

     

    I think.

     

    require("scripts/class")
    
    local class=CreateClass(...)
    
    function class:CreateObject(model)
    local object=self.super:CreateObject(model)
    
    self.basement=LoadModel("abstract::matt_house_basement.gmf")
    self.basement:SetParent(self.model)
    
    function object:Free(model)
                   self.basement:Free()
    	self.super:Free()
    end
    
    end
    

  7. Yeah. Initially I wanted to update and use the character thingoid, but I couldn't get the animations to play correctly based on the character thingoid...

     

     

    "when you send the message to the character thingoid, I couldn't find the right was to access that message in the character animation sequences. I was trying to reference the object.move for my if elseif, but that didn't come out right. Accessing those direct messages would be better"

     

     

    Also, what I meant on speed. Right now when I move forward 3 my toon moves ~REALLY fast.. But thats the same speed setting you used, so I can't quite figure out why.

     

    Also, my character mesh doesn't interact with the terrain mesh, it always at plain 0 on y..

     

    I didn't see where you did that in the character thingoid, but your controller does go with the terrain mesh.

  8. New update :unsure:

     

    require("scripts/class")
    require("scripts/XML/XML")
    
    local class=CreateClass(...)
    local path = string.lower(StripExt(class.modelreference.path))
    
    local obj,err = XmlParser:ParseXmlFile(path..".xml")
    
    
    function class:InitDialog(grid)
    self.super:InitDialog(grid)
    group = grid:AddGroup("Animations")
    if (not err) then
    	for i,xmlNode in pairs(obj.ChildNodes) do
    		if(xmlNode.Name=="start") then
    			for i,subXmlNode in pairs(xmlNode.ChildNodes) do
    				if(subXmlNode.Name) then
    					group:AddProperty(subXmlNode.Name.."_start", PROPERTY_INTEGER, "", ""..subXmlNode.Attributes.value.."")
    				end
    			end
    		end
    	end
    	for i,xmlNode in pairs(obj.ChildNodes) do
    		if(xmlNode.Name=="end") then
    			for i,subXmlNode in pairs(xmlNode.ChildNodes) do
    				if(subXmlNode.Name) then
    					group:AddProperty(subXmlNode.Name.."_end", PROPERTY_INTEGER, "", ""..subXmlNode.Attributes.value.."")
    				end
    			end
    		end
    	end
    end
    group:Expand(1)
    end
    
    function class:CreateObject(model)
    
    local object = self.super:CreateObject(model)
    
    object.model = model
    
    local pos = object.model:GetPosition()
    object.model:SetPosition(Vec3(pos.x, pos.y, pos.z))
    
    object.framestart = 0
    object.frameend = 50
    
    object.height = tonumber(object:GetKey("controller_height", "1.8"))
    local radius = tonumber(object:GetKey("controller_radius", "0.4"))
    local step = tonumber(object:GetKey("controller_step_height", "0.5"))
    local slope = tonumber(object:GetKey("controller_max_slope", "45.0"))
    
    object.rotation = 0
    object.forward = 0
    object.reverse = 0
    object.sright = 0
    object.sleft = 0
    object.tleft = 0
    object.tright = 0
    object.jump = 0
    object.moveSpeed = 2
    object.strafeSpeed = 2
    
    --Notify(object.framestart)  // Debug
    
    function object:SetKey(key,value)
    	if key=="idle_start" then
    		self.idle_start = tonumber(value)
    	elseif key=="idle_end" then
    		self.idle_end = tonumber(value)
    	elseif key=="walk_start" then
    		self.walk_start = tonumber(value)
    	elseif key=="walk_end" then
    		self.walk_end = tonumber(value)
    	elseif key=="run_start" then
    		self.run_start = tonumber(value)
    	elseif key=="run_end" then
    		self.run_end = tonumber(value)
    	elseif key=="jump_start" then
    		self.jump_start = tonumber(value)
    	elseif key=="jump_end" then
    		self.jump_end = tonumber(value)
    	elseif key=="crouch_start" then
    		self.crouch_start = tonumber(value)
    	elseif key=="crouch_end" then
    		self.crouch_end = tonumber(value)
    	elseif key=="strafeleft_start" then
    		self.strafeleft_start = tonumber(value)
    	elseif key=="strafeleft_end" then
    		self.strafeleft_end = tonumber(value)
    	elseif key=="straferight_start" then
    		self.straferight_start = tonumber(value)
    	elseif key=="straferight_end" then
    		self.straferight_end = tonumber(value)
    	elseif key=="height" then
    		self.height = tonumber(vaue)
    	else 
    		return self.super:SetKey(key,value)
    
    	end
    	return 1
    end
    
    function object:GetKey(key,value)
    	if key=="idle_start" then
    		return self.idle_start
    	elseif key=="idle_end" then
    		return self.idle_end
    	elseif key=="walk_start" then
    		return self.walk_start
    	elseif key=="walk_end" then
    		return self.walk_end
    	elseif key=="run_start" then
    		return self.run_start
    	elseif key=="run_end" then
    		return self.run_end
    	elseif key=="jump_start" then
    		return self.jump_start
    	elseif key=="jump_end" then
    		return self.jump_end
    	elseif key=="crouch_start" then
    		return self.crouch_start
    	elseif key=="crouch_end" then
    		return self.crouch_end
    	elseif key=="strafeleft_start" then
    		return self.strafeleft_start
    	elseif key=="strafeleft_end" then
    		return self.strafeleft_end
    	elseif key=="straferight_start" then
    		return self.straferight_start
    	elseif key=="straferight_end" then
    		return self.straferight_end
    	elseif key=="height" then
    		return self.height
    	else
    		return self.key
    	end 
    	return value
    end
    
           function object:StartAnimations(movement)
                   object.framestart = object:GetKey(movement .. "_start", "")
                   return object.framestart
           end
    
           function object:EndAnimations(movement)
                   object.frameend = object:GetKey(movement .. "_end")
                   return object.frameend
           end
    
    function object:LockKeys(model)
    
    	self.super:LockKeys()
    end
    
    function object:UnlockKeys(model)
    
    	self.super:UnlockKeys()
    end
    
    function object:UpdateMatrix()
    
    end
    
    function object:Reset()
    
    end
    
    function object:SetTarget(target,index)
    
    end
    
    function object:Collision(entity,position,normal,force,speed)
    
    end
    
    function object:ReceiveMessage(message,extra)
    	if message=="forward" then
    		object.forward = tonumber(extra) * object.moveSpeed
    	elseif message=="reverse" then
    		object.reverse = tonumber(extra) * object.moveSpeed
    	elseif message=="stop" then
    		object.forward = tonumber(extra) * object.moveSpeed
    		object.reverse = tonumber(extra) * object.moveSpeed
    	elseif message=="sleft" then
    	elseif message=="sright" then
    	elseif message=="tleft" then
    	elseif message=="tright" then
    	elseif message=="crouch" then
    	elseif message=="jump" then
    	elseif message=="attack" then
    	else
    		self.super:ReceiveMessage(message,extra)
    	end
    end
    
    function object:Render()
    
    	object.framestart = object:StartAnimations("idle")
    	object.frameend = object:EndAnimations("idle")
    	object.move = 0
    	if GetGlobalString("mode") == "GAME_MODE" then
    		local pos = object.model:GetPosition()
    		if object.forward > 1 then	
    			object.model:SetPosition(Vec3(pos.x, pos.y, pos.z+object.forward))
    		elseif object.reverse < -1 then
    			object.model:SetPosition(Vec3(pos.x, pos.y, pos.z+object.reverse))
    		else
    			object.frame = math.fmod(AppTime()/30, object.framestart - object.frameend) + object.framestart
    			Animate(object.model, object.frame, 0.5, 0, true)
    		end
    
    	else
    
    	end
    
    	if GetGlobalString("mode") ~= "GAME_MODE" then
    		if object.frameend ~= nil and object.frameend ~= 0 or object.framestart ~= nil then
    			object.frame = math.fmod(AppTime()/30, object.framestart - object.frameend) + object.framestart
    			Animate(object.model, object.frame, 0.5, 0, true)
    		end
    	end
    
    end
    
    function object:Free(model)
    
    	self.super:Free()
    end
    
    end
    --[[
    function class:Free()
    
    self.super:Free()
    end
    ]]--
    

     

    and the keyboard controller

     

    require("scripts/class")
    require("Scripts/Constants/keycodes")
    require("Scripts/hooks")
    
    
    local class=CreateClass(...)
    
    
    -- we can get the value by passing the string to _G[]
    function class:InitDialog(grid)
    self.super:InitDialog(grid)
    group = grid:AddGroup("Movement Controls")
    
    letters = "NO_KEY,KEY_BACKSPACE,KEY_TAB,KEY_CLEAR,KEY_RETURN,KEY_ENTER,KEY_ESCAPE,KEY_SPACE,KEY_PAGEUP,KEY_PAGEDOWN,KEY_END,KEY_HOME,KEY_LEFT,KEY_RIGHT,KEY_UP,KEY_DOWN,KEY_SELECT,KEY_PRINT,KEY_EXECUTE,KEY_SCREEN,KEY_INSERT,KEY_DELETE,KEY_0,KEY_1,KEY_2,KEY_3,KEY_4,KEY_5,KEY_6,KEY_7,KEY_8,KEY_9,KEY_NUM0,KEY_NUM1,KEY_NUM2,KEY_NUM3,KEY_NUM4,KEY_NUM5,KEY_NUM6,KEY_NUM7,KEY_NUM8,KEY_NUM9,KEY_NUMMULTIPLY,KEY_NUMADD,KEY_NUMSUBSTRACT,KEY_NUMDECIMAL,KEY_NUMDIVIDE,KEY_F1,KEY_F2,KEY_F3,KEY_F4,KEY_F5,KEY_F6,KEY_F7,KEY_F8,KEY_F9,KEY_F10,KEY_F11,KEY_F12,KEY_TILDE,KEY_MINUS,KEY_EQUALS,KEY_OPENBRACKET,KEY_CLOSEDBACKET,KEY_BACKSLASH,KEY_SEMICOLON,KEY_QUOTES,KEY_COMMA,KEY_PERIOD,KEY_SLASH,KEY_LSHIFT,KEY_RSHIFT,KEY_LCONTROL,KEY_RCONTROL,KEY_LALT,KEY_RALT,KEY_LSYS,KEY_RSYS"
           for i = 65,90 do
                   letters = letters..",".."KEY_"..string.char(i)
           end
           group:AddProperty("forward", PROPERTY_CHOICEEDIT, letters, "Forward")
    group:AddProperty("backward", PROPERTY_CHOICEEDIT, letters, "Backward")
    group:AddProperty("strafe_left", PROPERTY_CHOICEEDIT, letters, "Strafe Left")
    group:AddProperty("strafe_right", PROPERTY_CHOICEEDIT, letters, "Strafe Right")
    group:AddProperty("rotate_right", PROPERTY_CHOICEEDIT, letters, "Rotate Left")
    group:AddProperty("rotate_right", PROPERTY_CHOICEEDIT, letters, "Rotate Right")
    group:AddProperty("jump", PROPERTY_CHOICEEDIT, letters, "Jump")
    group:AddProperty("duck", PROPERTY_CHOICEEDIT, letters, "Duck")
    
    group:Expand(1)
    end
    
    function class:CreateObject(model)
    local object=self.super:CreateObject(model)
    
    object.model = model
    object.forward = ""
    object.backward = ""
    object.strafeLeft = ""
    object.strafeRight = ""
    object.rotateLeft = ""
    object.rotateRight = ""
    object.jump = ""
    object.duck = ""
    object.speed = 2
    object.moveOneTime = false
    object.strafeOneTime = false
    
    
    function object:SetKey(key,value)
    	if key == "forward" then
    		object.forward = value
    	elseif key == "backward" then
    		object.backward = value
    	elseif key == "strafe_left" then
    		object.strafeLeft = value
    	elseif key == "strafe_right" then
    		object.strafeRight = value
    	elseif key == "rotate_left" then
    		object.rotateLeft = value
    	elseif key == "rotate_right" then
    		object.rotateRight = value
    	elseif key == "jump" then
    		object.jump = value
    	elseif key == "duck" then
    		object.duck = value
    	else
    		return self.super:SetKey(key,value)
    	end
    	return 1
    end
    
    function object:GetKey(key,value)
    	if key == "forward" then
    		return object.forward
    	elseif key == "backward" then
    		return object.backward
    	elseif key == "strafe_left" then
    		return object.strafeLeft
    	elseif key == "strafe_right" then
    		return object.strafeRight
    	elseif key == "rotate_left" then
    		return object.rotateLeft
    	elseif key == "rotate_right" then
    		return object.rotateRight
    	elseif key == "jump" then
    		return object.jump
    	elseif key == "duck" then
    		return object.duck
    	else
    		return self.super:GetKey(key,value)
    	end
    	return value
    end
    
    function object:Update()
    	t = model:GetTarget(0)
    
    	if GetGlobalString("mode") == "GAME_MODE" then
    		if t ~= nil then
    			if KeyHit(_G[object.forward]) == 1 then
    				object.moveOneTime = true
    				t:SendMessage("forward", "1")
    
    			elseif KeyHit(_G[object.backward]) == 1 then
    				object.moveOneTime = true
    				t:SendMessage("reverse", "-1")
    			else
    				if KeyDown(_G[object.forward]) == 0 and KeyDown(_G[object.backward]) == 0 and object.moveOneTime == true then
    					-- we only want to send the stop message once
    					object.moveOneTime = false
    					t:SendMessage("stop","0")
    				end
    			end
    
    			if KeyHit(_G[object.strafeLeft]) == 1 then
    				object.strafeOneTime = true
    				t:SendMessage("strafe", "0", "-1")
    			elseif KeyHit(_G[object.strafeRight]) == 1 then
    				object.strafeOneTime = true
    				t:SendMessage("strafe", "0", "1")
    			else
    				if KeyDown(_G[object.strafeLeft]) == 0 and KeyDown(_G[object.strafeRight]) == 0 and object.strafeOneTime == true then
    					-- we only want to send the stop message once
    					object.strafeOneTime = false
    					t:SendMessage("strafe", "0", "0")
    				end
    			end
    
    			if KeyHit(_G[object.jump]) == 1 then
    				t:SendMessage("jump", "0", "4")
    			end
    		end
    	else
    	end
    end
    
    function object:UpdateMatrix()
    
    end
    
    --[[
    function object:LockKeys(model)
    
    	self.super:LockKeys()
    end
    ]]--
    
    --[[
    function object:UnlockKeys(model)
    
    	self.super:UnlockKeys()
    end
    ]]--
    
    --[[
    function object:UpdateMatrix()
    
    end
    ]]--
    
    --[[
    function object:Reset()
    
    end
    ]]--
    
    --[[
    function object:SetTarget(target,index)
    
    end
    ]]--
    
    --[[
    function object:Collision(entity,position,normasl,force,speed)
    
    end
    ]]--
    --[[
    function object:ReceiveMessage(message,extra)
    	if message="" then
    
    	else
    		self.super:ReceiveMessage(message,extra)
    	end
    end
    ]]--
    
    
    function object:Free(model)
    	--Notify("Inside free")
    	self.super:Free()
    end
    
    end
    
    --[[
    function class:Free()
    
    self.super:Free()
    end
    ]]--
    

     

    THis is a modification to Ricks...

     

    My question so far. How to determine movement speed based on the sise of the virtual world? Should I use a mathematical calculation based on the height of the model?

     

    If I move forward 3 in the editor how much is that in reference to real world terms?

×
×
  • Create New...