Jump to content

The Windmill Example Script Problem


Mince
 Share

Recommended Posts

I tried the EntityNew={} ver

That gave me a error with inherit = nil???

 

The following Script dont work, either

 

if any one can help me rotate the blades that will be great.

 

--Include the base script for all classes

dofile("Scripts/base.lua")

 

 

--Some global sounds we will use for all instances

squeak={}

squeak[0]=LoadSound("abstract::squeak_1.ogg")

squeak[1]=LoadSound("abstract::squeak_2.ogg")

 

 

--This function builds the interface for the properties editor

function InitDialog(grid)

 

--Add the base interface for all classes

base_InitDialog(grid)

 

--Now we can add our own custom properties

group=grid:AddGroup( "Windmill" )

group:AddProperty( "spinspeed","|0,4",PROPERTY_FLOAT,"Spin Speed")

group:Expand(1)

 

end

 

 

--Spawn function for creating new instances

function Spawn(model)

local entity=base_Spawn(model)

 

--Retrieve a few limbs we will use later

entity.blades=model:FindChild("windmill_blades")

entity.base=model:FindChild("windmill_housing")

entity.model:SetKey("spinspeed","1")

 

--An update function for one instance. Declaring the function as part of the entity table allows us to use "self" for the table

function entity:Update()

 

--Although these limbs should always be present, it"s a good idea to add a check to make sure they exist before using them

if self.blades~=nil then

self.blades:Turnf(0,tonumber(self.model:GetKey("spinspeed"))*AppSpeed(),0,0)

end

 

if self.base~=nil then

 

--Make the base sway slightly

angle=math.sin(AppTime()/2000.0)*5-15

angle=angle+math.cos(AppTime()/500.0)*2

self.base:SetRotationf(0,0,angle,0)

 

--Make the base squeak

lasttime=tonumber(self.model:GetKey("lastsqueaktime","0"))

if (AppTime()-lasttime>8000) then

self.model:SetKey("lastsqueaktime",AppTime()+math.random(0,5000))

self.base:EmitSound(squeak[math.random(0,1)],50,1,0)

end

lasttime=tonumber(self.model:GetKey("lastsheeptime","0"))

 

end

 

end

 

end

 

 

--Update function, called during every UpdateWorld()

function Update(world)

if world==world_main then

local model,entity

for model,entity in pairs(entitytable) do

if model.world==world then

entity:Update()

end

end

end

end

Link to comment
Share on other sites

where did you get the windmill model from? that hasn't been around since 2.3 first came out... which is also using very old inherent scripts and multi-state lua in the beta version of the LE2.3 editor in that video so not too surprised that it doesn't work in the latest LE2.5 evaluation version...

Win7 64bit / Intel i7-2600 CPU @ 3.9 GHz / 16 GB DDR3 / NVIDIA GeForce GTX 590

LE / 3DWS / BMX / Hexagon

macklebee's channel

Link to comment
Share on other sites

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.

 Share

×
×
  • Create New...