Jump to content

Recommended Posts

Posted

               local posL = Vec3(0,0,0)
               local pos = Vec3(0,0,0)

		for i=0, 3362 do

	posL = surface:GetVertexPosition( i )
	pos = TFormPoint( posL, object.model, nil)

               local h = class.GetTerrainHeight(pos.x, pos.z, self.model.world)

 

hm, but It's defined ... IT's Vec3

-= Phenom II X4 965 3.4Ghz - ATI HD5870 - 6 GB DDR3 RAM - Windows 8 Pro 64x=-

Website: http://www.flamewarestudios.com

Posted

Sleeping? how dare he!! lol :);) ... the wonderful world of timezones :D

AMD Bulldozer FX-4 Quad Core 4100 Black Edition

2 x 4GB DDR3 1333Mhz Memory

Gigabyte GeForce GTX 550 Ti OC 1024MB GDDR5

Windows 7 Home 64 bit

 

BlitzMax 1.50 • Lua 5.1 MaxGUI 1.41 • UU3D Pro • MessiahStudio Pro • Silo Pro

3D Coat • ShaderMap Pro • Hexagon 2 • Photoshop, Gimp & Paint.NET

 

LE 2.5/3.4 • Skyline UE4 • CE3 SDK • Unity 5 • Esenthel Engine 2.0

 

Marleys Ghost's YouTube Channel Marleys Ghost's Blog

 

"I used to be alive like you .... then I took an arrow to the head"

Posted

Your problem is very simple:

 

Method in LUA is seperated by : :)

 

change this line

 

local h = class.GetTerrainHeight(pos.x, pos.z, self.model.world)

 

to:

 

local h = class:GetTerrainHeight(pos.x, pos.z, self.model.world)

[HW] C2D Q6600, 4GB RAM, NV8800GTX, Vista Ultimate x64

[sW] Blide Plus, BlitzMax, Delphi, C++, 3DWS 5.53, Leadwerks 2.xx

 

76561197970156808.pngAndyGFX.png

Posted

This little sample shows how-to and when is possible call function/method with . and when with :

 

-- | ---------------------------------------------------------------------------
-- | Define class name
-- | ---------------------------------------------------------------------------

TMyClass = {}


-- | ---------------------------------------------------------------------------
-- | Define class properties
-- | ---------------------------------------------------------------------------

TMyClassProp =
{
	var1 = 10,
	var2 = null,
	my_fnc = function (a) print(a) end
}

-- | ---------------------------------------------------------------------------
-- | CONSTRUCTOR
-- | ---------------------------------------------------------------------------

function TMyClass:New()

   o = TMyClassProp
setmetatable(o, self)
   self.__index = self

   return o

end

-- | ---------------------------------------------------------------------------
-- | Method #1
-- | ---------------------------------------------------------------------------

function TMyClass:SetVar1(v1)

self.var1 = v1

end

-- | ---------------------------------------------------------------------------
-- | Method #2
-- | ---------------------------------------------------------------------------

TMyClass.SetVar3 = function (v1) TMyClass.var1 = v1
					print(TMyClass.var1)
					end



-- | ---------------------------------------------------------------------------
-- | Method #3
-- | ---------------------------------------------------------------------------

function TMyClass:GetVar1(v1)

return self.var1
end


-- *****************************************************************************
-- USING
-- *****************************************************************************

-- create instance of TMyClass

myClass  = TMyClass:New()

-- call class method

myClass:SetVar1(100)

-- direct acces

myClass.var2 = 101

-- test result

print (myClass:GetVar1())
print (myClass.var2)
print (myClass.SetVar3(222))

myClass.my_fnc(123)

 

 

Note: Every functions in LUA are values. More here: Lua Functions

[HW] C2D Q6600, 4GB RAM, NV8800GTX, Vista Ultimate x64

[sW] Blide Plus, BlitzMax, Delphi, C++, 3DWS 5.53, Leadwerks 2.xx

 

76561197970156808.pngAndyGFX.png

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...