Data Realms Fan Forums
http://45.55.195.193/

Example codes for hydro mod
http://45.55.195.193/viewtopic.php?f=73&t=19065
Page 1 of 1

Author:  akblabla [ Tue Jun 22, 2010 12:56 pm ]
Post subject:  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.

Author:  findude [ Tue Jun 22, 2010 1:32 pm ]
Post subject:  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.

Author:  akblabla [ Tue Jun 22, 2010 1:48 pm ]
Post subject:  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.

Page 1 of 1 All times are UTC [ DST ]
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group
http://www.phpbb.com/