View unanswered posts | View active topics It is currently Fri Dec 27, 2024 8:48 am



Reply to topic  [ 3 posts ] 
 Example codes for hydro mod 
Author Message
User avatar

Joined: Wed May 20, 2009 3:10 pm
Posts: 366
Location: Århus, Denmark
Reply with quote
Post Example codes for hydro mod
Now it is possible to make mods to the hydro mod.

The water adds readable variable named WaterHeight and if you want your actor to be unaffected by the water you just make his sharpness 2 (for some reason 0.9994253 didn't work).

Heres some basic codes you can play around with and get a idea how it works.


Code:
function Create(self)
end

function Destroy(self)
end

function Update(self)
  local water = false
  if WaterHeight ~= nil then
    water = true
  end
  if water == true and self.Pos.Y + self.Vel.Y >  WaterHeight then
    self.Vel = self.Vel * 0.9
    self.AngularVel = self.AngularVel * 0.9
  end
end

Place this on a actor with sharpness = 2 and you've got a dude that walks on the bottom.


Code:
function Create(self)
end

function Destroy(self)
end

function Update(self)
  local water = false
  if WaterHeight ~= nil then
    water = true
  end
  if water == true and self.Pos.Y + self.Vel.Y >  WaterHeight then
    self.Vel = self.Vel * 0.9 - 1
    self.AngularVel = self.AngularVel * 0.9
    self.AngularVel = self.AngularVel - ((self.RotAngle + self.AngularVel) * 0.015)
    self.RotAngle = self.RotAngle * 0.99
  end
end

This is a code you can attach on a crab (with sharpness = 2) to make it float like a boat.

These scripts won't make your mod need hydro to run.


Last edited by akblabla on Thu Jul 29, 2010 10:55 am, edited 3 times in total.



Tue Jun 22, 2010 12:56 pm
Profile
User avatar

Joined: Tue Dec 12, 2006 3:10 pm
Posts: 495
Location: Uncertain quantum state
Reply with quote
Post Re: Example codes for hydro mod
you could add some simple checks like
Code:
string.find(actor.Material,"metal") ~= nil

or
Code:
string.find(actor.Material,"flesh") ~= nil


Even if modders are using custom materials, their material names just might make some sense.


Tue Jun 22, 2010 1:32 pm
Profile
User avatar

Joined: Wed May 20, 2009 3:10 pm
Posts: 366
Location: Århus, Denmark
Reply with quote
Post Re: Example codes for hydro mod
Actually the hydro mod is 100% dynamic when it comes to non-actor physics. This was made because numgun said it would be cool if other modders could make boats, submarines... to the mod without needing to make it a part of the mod. Other than that i thought it would be cool that my new hovercraft could skim over the water like it was earth.


Tue Jun 22, 2010 1:48 pm
Profile
Display posts from previous:  Sort by  
Reply to topic   [ 3 posts ] 

Who is online

Users browsing this forum: No registered users


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group.
Designed by STSoftware for PTF.
[ Time : 0.036s | 13 Queries | GZIP : Off ]