Category | Scripting |
Created | 04.11.2016 23:16 |
Seby Sdfkz (sdfkz) | 04.11.2016 23:19 |
---|---|
I have a problem with the script hydraulc conversion mode script has no error in the log but. does not work in game hydraulic cylinder that's the problem that I do not realize XML <hydraulic2 indexHydraulic="7|4" indexPunch="7|4|0" translationPunch="7|4|0|0" hydraulicPoint2="7|2|0|1"/> LUA function excavator:load(savegame) self.hydraulic2 = {}; self.hydraulic2.node = Utils.indexToObject(self.components, getXMLString(self.xmlFile, "vehicle.hydraulic2#indexHydraulic")); self.hydraulic2.punch = Utils.indexToObject(self.components, getXMLString(self.xmlFile, "vehicle.hydraulic2#indexPunch")); self.hydraulic2.translationPunch = Utils.indexToObject(self.components, getXMLString(self.xmlFile, "vehicle.hydraulic2#translationPunch")); local ax, ay, az = getWorldTranslation(self.hydraulic2.punch); local bx, by, bz = getWorldTranslation(self.hydraulic2.translationPunch); self.hydraulic2.punchDistance = Utils.vector3Length(ax-bx, ay-by, az-bz); self.keys = {}; self.keysDesc = {}; local i=0; while true do local baseName = string.format("vehicle.keys.input(%d)", i); local inputName = getXMLString(self.xmlFile, baseName.. "#name"); if inputName == nil then break; end; local inputKey = getXMLString(self.xmlFile, baseName.. "#key"); if Input[inputKey] == nil then print("Error: invalid key '" .. inputKey .. "' for input event '" .. inputName .. "'"); break; end; self.keys[inputName] = Input[inputKey]; self.keysDesc[inputName] = getXMLString(self.xmlFile, baseName.. "#keyDesc"); i = i+1; end; self.hydraulicPoint2 = Utils.indexToObject(self.components, getXMLString(self.xmlFile, "vehicle.hydraulic2#hydraulicPoint2")); end; function excavator:update(dt) if self.hydraulic2 ~= nil then local ax, ay, az = getWorldTranslation(self.hydraulic2.node); local bx, by, bz = getWorldTranslation(self.hydraulicPoint2); local x, y, z = worldDirectionToLocal(getParent(self.hydraulic2.node), bx-ax, by-ay, bz-az); setDirection(self.hydraulic2.node, x*-1, y*-1, 0, 0, 1, 0); if self.hydraulic2.punch ~= nil then local distance = Utils.vector3Length(ax-bx, ay-by, az-bz); setTranslation(self.hydraulic2.punch, 0, 0, (distance-self.hydraulic2.punchDistance)*-1); end; end; Where is the mistake? or it has changed the script to work? help! thanks! |
Seby Sdfkz (sdfkz) | 20.01.2017 00:15 |
---|---|
Note: Log in to post. Create a new account here.