Приветствую Вас Гость!
Четверг, 02.05.2024, 07:59
Главная | Регистрация | Вход | RSS

[ Новые сообщения · Участники · Правила форума · Поиск · RSS ]
  • Страница 1 из 2
  • 1
  • 2
  • »
FS Форум » Моделирование » Скриптинг » ManySilo (Мультифрут триггер) (Установка. Обсуждение. Проблемы.)
ManySilo (Мультифрут триггер)
BeckarДата: Четверг, 25.11.2010, 14:11 | Сообщение # 1
Группа: Администраторы
Сообщений: 692
Статус: Offline
Этот мод позволяет выбрать культуру загружаемую в кузов прицепа или автомобиля.
Автор мода WeeRuz. Идея и теоретическая часть взята с superSilo for Farm Simulator 2009, автор: Defender. Тот самый Defender, который написал FS 2009 Fruitimporter.
WeeRuz разрешает изменение и переделку ManySilo, единственное требование - сохранять его имя в LUA файле.

Скачать можно здесь

Установка очень проста: распаковать архив, файл триггера manySiloTrigger.i3d импортировать на карту, архив manySilo.zip скопировать в папку mods.
На этом можно и закончить: стандартные культуры можно будет выбирать в игре в появляющемся слева меню. Переход между культурами осуществляется стрелками, выбор - клавишей Enter.

Если Вы хотите добавить в триггер культуры или удалить их, откройте карту и в User attributes триггера, в поле fruitTypes, добавьте нужное или в поле ignoreList впишите лишнее. Имеется еще одна установка: setting, с ней я пока не разобрался.

LUA

Code
-- Author : WeeRuz
print("manySilo");
manySilo = {};
function manySilo:onCreate(id)
  manySilo:load(id);
  print("test");
end;
manySiloOnCreate = manySilo.onCreate;

function manySilo:load(id)
  addTrigger(id, "manySiloCallback", self);
  self.hud = false;
  self.otherId = 0;
  self.triggerId = 0;
  self.fruitcnt = 0;
  self.currentFruit = 1;
  self.trailerFruits = {};
  self.fill = false;
  self.lockedFruit = 0;
  self.allowedFruits = {};
  self.fruitsToTrailer = {};
  self.fillFruit = FruitUtil.fruitTypeToFillType[self.currentFruit];
  self.setting = Utils.getNoNil(getUserAttribute(id, "setting"),"");
  self.fruitTypes = getUserAttribute(id,"fruitTypes"):split(" ");
  self.ignoreList = getUserAttribute(id,"ignoreList"):split(" ");
   
  if self.setting == "" and self.ignoreList[1] ~= "" then
   print("manySilo-WARNING: Fruits detected in ignoreList even though setting attribute is empty. Ignorelist wont work without a setting.")
  end;  
  if self.setting ~= "" and self.fruitTypes[1] ~= "" then
   print("manySilo-WARNING: Fruits detected in fruitTypes, but setting is set to '"..self.setting.."'. Setting attribute has higher priority and will take over.")
  end;
  if self.setting == "" and self.fruitTypes[1] ~= "" and self.ignoreList[1] ~= "" then
   print("manySilo-WARNING: Fruits detected in both fruitTypes and ignoreList attribute. You dont have to use ignoreList when using fruitTypes.")
  end;
  if self.setting ~= "" and self.setting ~= "realism" and self.setting ~= "all" and self.setting ~= "seedable" then
   print("manySilo-WARNING: Unknown setting in 'setting' attribute. Falling back on 'realism'");
   self.setting = "realism";
  end;
  if self.setting == "" and self.fruitTypes[1] == "" then
   print("manySilo-WARNING: Both fruitTypes and setting is empty. Falling back on 'all' setting.")
   self.setting = "all";
  end;
  if self.setting == "realism" then
   local i = 0;
   for a=1, FruitUtil.NUM_FRUITTYPES do
    if (FruitUtil.fruitIndexToDesc[a].allowsSeeding) and (FruitUtil.fruitIndexToDesc[a].name~="grass")then
      i=i+1;
      self.allowedFruits[i]=a;
    end;
   end;
   if self.ignoreList[1] ~= "" then
    for b=1,table.maxn(self.allowedFruits) do
     for d=1, table.maxn(self.ignoreList) do
      if FruitUtil["FRUITTYPE_"..string.upper(self.ignoreList[d])] == self.allowedFruits[b] then
       table.remove(self.allowedFruits,b)
      end;
     end;
    end;
   end;
  end;
  if self.setting == "seedable" then
   local i = 0;
   for a=1, FruitUtil.NUM_FRUITTYPES do
    if (FruitUtil.fruitIndexToDesc[a].allowsSeeding) then
      i=i+1;
      self.allowedFruits[i]=a;
    end;
   end;
   if self.ignoreList[1] ~= "" then
    for b=1,table.maxn(self.allowedFruits) do
     for d=1, table.maxn(self.ignoreList) do
      if FruitUtil["FRUITTYPE_"..string.upper(self.ignoreList[d])] == self.allowedFruits[b] then
       table.remove(self.allowedFruits,b)
      end;
     end;
    end;
   end;
  end;
  if self.setting == "all" then
   local i = 0;
   for a=1, FruitUtil.NUM_FRUITTYPES do
    i=i+1;
    self.allowedFruits[i]=a;
   end;
   if self.ignoreList[1] ~= "" then
    for b=1,table.maxn(self.allowedFruits) do
     for d=1, table.maxn(self.ignoreList) do
      if FruitUtil["FRUITTYPE_"..string.upper(self.ignoreList[d])] == self.allowedFruits[b] then
       table.remove(self.allowedFruits,b)
      end;
     end;
    end;
   end;
  end;
  if self.allowedFruits[1] == "" then
   for f = 1, table.maxn(self.fruitTypes) do
    self.allowedFruits[f] = FruitUtil["FRUITTYPE_"..string.upper(self.fruitTypes[f])]
   end;
  end;
   
  for c = 1 , table.maxn(self.allowedFruits) do
   print("Allowed fruits :"..c..":"..FruitUtil.fruitIndexToDesc[self.allowedFruits[c]].name)
  end;
  local ParticlePosX,ParticePosY,ParticlePosZ = Utils.getVectorFromString(getUserAttribute(id, "particlePosition"));
  local x,y,z = localToWorld(id, ParticlePosX,ParticePosY,ParticlePosZ)
  self.siloParticleSystemRoot = loadI3DFile("data/vehicles/particleSystems/wheatParticleSystemLong.i3d");
  setTranslation(self.siloParticleSystemRoot, x, y, z);
  link(getRootNode(), self.siloParticleSystemRoot);
  for i=0, getNumOfChildren(self.siloParticleSystemRoot)-1 do
   local child = getChildAt(self.siloParticleSystemRoot, i);
   if getClassName(child) == "Shape" then
    local geometry = getGeometry(child);
    if geometry ~= 0 then
     if getClassName(geometry) == "ParticleSystem" then
      self.siloParticleSystem = geometry;
     end;
    end;
   end;
  end;
  if self.siloParticleSystem ~= nil then
   setEmittingState(self.siloParticleSystem, false);
  end;
end;
function manySilo:loadMap(name)

end;

function manySilo:deleteMap()
end;

function manySilo:delete()
end;

function manySilo:mouseEvent(posX, posY, isDown, isUp, button)
end;

function manySilo:keyEvent(unicode, sym, modifier, isDown)
end;
function manySilo:update(dt)
  if not self.fill then
   setEmittingState(self.siloParticleSystem, false);
  end;
  if self.otherId ~= 0 then
   trailer = g_currentMission.objectToTrailer[self.otherId];
   if trailer ~= nil then
    if trailer.fillTypes ~= nil and trailer.setFillLevel ~= nil and trailer.fillLevel ~= nil then
       
     for t=1, table.maxn(self.allowedFruits) do
      for tt=1, table.maxn(trailer.fillTypes) do
       if FruitUtil.fruitTypeToFillType[self.allowedFruits[t]] == tt and trailer.fillTypes[tt] == true then
        self.trailerFruits[t] = FruitUtil.fruitTypeToFillType[self.allowedFruits[t]];
        self.fruitsToTrailer[FruitUtil.fruitTypeToFillType[self.allowedFruits[t]]] = t;
       end;
      end;
     end;
     if InputBinding.hasEvent(InputBinding.MENU_RIGHT) then
      for c = 1 , table.maxn(self.trailerFruits) do
       print("Allowed fruits :"..c..":"..FruitUtil.fruitIndexToDesc[self.trailerFruits[c]].name)
      end;
     end;
     if InputBinding.hasEvent(InputBinding.MENU_UP) and self.currentFruit > 1 then
      if trailer.fillLevel <= 0 then
       self.currentFruit = self.currentFruit - 1      
       self.fillFruit = self.trailerFruits[self.currentFruit];
      end;
     end;
     if InputBinding.hasEvent(InputBinding.MENU_DOWN) and self.currentFruit < table.maxn(self.trailerFruits) then
      if trailer.fillLevel <= 0 then
       self.currentFruit = self.currentFruit + 1      
       self.fillFruit = self.trailerFruits[self.currentFruit];
      end;
     end;
     if InputBinding.hasEvent(InputBinding.MENU_ACCEPT) then
      self.fill = not self.fill;
     end;
     if trailer.fillLevel > 0 then
       
      self.currentFruit = self.fruitsToTrailer[FruitUtil.fruitTypeToFillType[trailer:getCurrentFruitType()]];
       
      self.lockedFruit = self.currentFruit;
      self.fillFruit = self.trailerFruits[self.currentFruit];
       
     else
     self.lockedFruit = 0;
     end;
     if trailer.fillLevel < trailer.capacity and trailer:allowFillType(self.fillFruit, true) then
      if self.fill then
       local delta = dt*0.6;
       if g_currentMission.missionStats.farmSiloAmounts[self.fillFruit]<=delta then
        delta=g_currentMission.missionStats.farmSiloAmounts[self.fillFruit];
        self.fill = false;
       end;
       if delta > 0 then
        trailer:setFillLevel(trailer.fillLevel+delta, self.fillFruit);
        g_currentMission.missionStats.farmSiloAmounts[self.fillFruit]=g_currentMission.missionStats.farmSiloAmounts[self.fillFruit]-delta;
        setEmittingState(self.siloParticleSystem, true);
       end;
      end;
      if g_currentMission.missionStats.farmSiloAmounts[self.fillFruit]<=0 then
       g_currentMission.missionStats.farmSiloAmounts[self.fillFruit]=0;
       self.fill = false;
      end;
     else
       
      self.fill = false;
     end;
     self.show = true;
    end;
   end;   
  end;
end;
function manySilo:draw()
  if self.show then
   setTextBold(true);
   renderText(0.02,0.70,0.023,"Choose fruit to fill:");
   setTextBold(false);
   setTextColor(0.1,1,0.1,1);
   local i = 0.02;
   for a = 1, table.maxn(self.trailerFruits) do
    if self.trailerFruits[a] ~= nil then
     if self.lockedFruit == a then
      setTextColor(1,0.1,0.1,1);
     elseif Utils.getNoNil(g_currentMission.missionStats.farmSiloAmounts[self.trailerFruits[a]],0)<=0 and self.lockedFruit ~= a then
      setTextColor(0.7,0.5,0,1);
     else
      setTextColor(0.1,1,0.1,1);
     end;
     if a == self.currentFruit then
      renderText(0.02,0.70-i,0.02,a..": ["..g_i18n:getText(FruitUtil.fruitIndexToDesc[FruitUtil.fillTypeToFruitType[self.trailerFruits[a]]].name).."]");
     else
      renderText(0.02,0.70-i,0.02,a..": "..g_i18n:getText(FruitUtil.fruitIndexToDesc[FruitUtil.fillTypeToFruitType[self.trailerFruits[a]]].name));
     end;
     i=i+0.02;
    end;
   end;
  end;
end;
function manySilo:manySiloCallback(triggerId, otherId, onEnter, onLeave, onStay, otherShapeId)
  if onEnter then
   if otherId ~= nil then
    self.otherId = otherId;
    self.triggerId = triggerId;    
   end;
  elseif onLeave then
    self.otherId = 0;
    self.triggerId = 0;  
    self.show = false;
    self.fruitcnt = 0;
    self.currentFruit = 1;
    self.trailerFruits = {};
    self.fill = false;
    self.lockedFruit = 0;

  elseif onStay then
   if otherId ~= nil then
    self.otherId = otherId;
    self.triggerId = triggerId;
   end;
  end;
end;

function print_r (t, indent) -- alt version, abuse to http://richard.warburton.it
   local indent=indent or ''
   for key,value in pairs(t) do
     print(indent,'[',tostring(key),']')  
     if type(value)=="table" then print(':\n') print_r(value,indent..'\t')
   
     else print(' = ',tostring(value),'\n') end
   end
end
function string:split(delimiter)
   local result = { }
   local from  = 1
   local delim_from, delim_to = string.find( self, delimiter, from  )
   while delim_from do
     table.insert( result, string.sub( self, from , delim_from-1 ) )
     from  = delim_to + 1
     delim_from, delim_to = string.find( self, delimiter, from  )
   end
   table.insert( result, string.sub( self, from  ) )
   return result
end

addModEventListener(manySilo);

XML

Code
<?xml version="1.0" encoding="utf-8" standalone="no" ?>
<modDesc descVersion="4">
     <author>WeeRuz</author>
     <version>1</version>
     <title>
         <en>manySilo</en>
    
     </title>
     <description>
         <en>manySilo</en>
          
     </description>
     <extraSourceFiles>
         <sourceFile filename="manySilo.lua" />   
     </extraSourceFiles>
  <l10n>
      <text name="dryGrass"> <en>DryGrass</en> <de>Heu</de> </text>
   <text name="dung"> <en>Dung</en> <de>Mist</de> </text>
   <text name="fertilizer"> <en>Fertilizer</en> <de>Kunstduenger</de> </text>
   <text name="manure"> <en>Manure</en> <de>Guelle</de> </text>
   <text name="pesticide"> <en>Pesticide</en> <de>Pestizide</de> </text>
   <text name="betterave"> <en>Beetroot</en> <de>Rueben</de> </text>
   <text name="blumkohl"> <en>Cauliflower</en> <de>Blumenkohl</de> </text>
   <text name="cotton"> <en>Cotton</en> <de>Baumwolle</de> </text>
   <text name="erbse"> <en>Pea</en> <de>Erbsen</de> </text>
   <text name="kuh"> <en>Cows</en> <de>Kuh</de> </text>
   <text name="pferd"> <en>Horses</en> <de>Pferd</de> </text>
   <text name="schaf"> <en>Sheep</en> <de>Schaf</de> </text>
   <text name="schwein"> <en>Pigs</en> <de>Schwein</de> </text>
   <text name="gelbbo"> <en>Yellow Beans beans</en> <de>gelbe Bohnen</de> </text>
   <text name="gruenbo"> <en>String Beans</en> <de>gruene Bohnen</de> </text>
   <text name="greenwheat"> <en>Green Wheat</en> <de>gruener Weizen</de> </text>
   <text name="karotte"> <en>Carrots</en> <de>Karotte</de> </text>
   <text name="carrot"> <en>Carrots</en> <de>Mohrruebe</de> </text>
   <text name="luzerne"> <en>lucerne</en> <de>Luzerne</de> </text>
   <text name="maizev2"> <en>Maize v2</en> <de>Mais+Stroh</de> </text>
   <text name="maize2"> <en>Maize2</en> <de>Haeckselmais</de> </text>
   <text name="mohn"> <en>Poppy</en> <de>Mohn</de> </text>
   <text name="nad"> <en>nad</en> <de>Schilf</de> </text>
   <text name="oats"> <en>Oats</en> <de>Hafer</de> </text>
   <text name="oat"> <en>Oats</en> <de>Hafer</de> </text>
   <text name="owies"> <en>Oats</en> <de>Hafer</de> </text>
   <text name="pea"> <en>Peapods</en> <de>Erbsenschote</de> </text>
   <text name="potato"> <en>Potatos</en> <de>Kartoffel</de> </text>
   <text name="rice"> <en>Rice</en> <de>Reis</de> </text>
   <text name="rotkohl"> <en>Red Cabbage</en> <de>Rotkohl</de> </text>
   <text name="silage"> <en>Silage</en> <de>Silage</de> </text>
   <text name="soybean"> <en>Soy</en> <de>Sojabohnen</de> </text>
   <text name="spinat"> <en>Spinach</en> <de>Spinat</de> </text>
   <text name="sugarbeet"> <en>Sugarbeet</en> <de>Zuckerruebe</de> </text>
   <text name="sugarcane"> <en>Sugarcane</en> <de>Zuckerrohr</de> </text>
   <text name="sunflower"> <en>Sunflower</en> <de>Sonnenblume</de> </text>
   <text name="texasfu"> <en>Texasfu</en> <de>Texasfu</de> </text>
   <text name="weisskohl"> <en>White Cabbage</en> <de>Weisskohl</de> </text>
   <text name="wirsingkohl"> <en>Savoy Cabbage</en> <de>Wirsingkohl</de> </text>
   <text name="forest1"> <en>Timber</en> <de>Holz</de> </text>
         <text name="zwir"> <en>Gravel</en> <de>Kies</de> </text>
   <text name="sand"> <en>Sand</en> <de>Sand</de> </text>
   <text name="cabbage"> <en>Red Cabbage</en> <de>Rotkohl</de> </text>
   <text name="rye"> <en>Rye</en> <de>Roggen</de> </text>
   <text name="sunflowerSilage"> <en>Sunflower Silage</en> <de>SonnenblumenSilage</de> </text>
   <text name="triticale"> <en>Triticale</en> <de>Roggen-Weizen</de> </text>
   <text name="MAPFRUITTRIGGER_1"> <en>Stop loading:</en> <de>Start Befuellen:</de> </text>
   <text name="MAPFRUITTRIGGER_2"> <en>Start loading</en> <de>Stop Befuellen:</de> </text>
   <text name="milch"> <en>Milk</en> <de>Milch</de> </text>
                 <text name="minze"> <en>Minze</en> <de>Minze</de> </text>
   <text name="radieschen"> <en>Radishes</en> <de>Radieschen</de> </text>
     </l10n>
</modDesc>

Молоко пока не работает. Впрочем, это бета-версия. Главное - старт есть.

 
VVPutinДата: Четверг, 25.11.2010, 14:24 | Сообщение # 2
Ударник- Модокопатель
Группа: Администраторы
Сообщений: 578
Репутация: 90
Статус: Offline
Я думаю к Новому году, сгущённое молоко возить будем hands
 
BeckarДата: Четверг, 25.11.2010, 14:32 | Сообщение # 3
Группа: Администраторы
Сообщений: 692
Статус: Offline
Ну можно еще в коде поковыряться, там прописан milch, а в игре возможно стоит milk. Или в прицепе, который я использовал, может быть загвоздка.
 
VVPutinДата: Четверг, 25.11.2010, 14:41 | Сообщение # 4
Ударник- Модокопатель
Группа: Администраторы
Сообщений: 578
Репутация: 90
Статус: Offline
Beckar, Главное,что то начинает продвигаться.Как сказал (если не ошибаюсь ) Остап Бендер- "Лёд тронулся,заседание продолжается" biggrin
 
BeckarДата: Пятница, 26.11.2010, 11:59 | Сообщение # 5
Группа: Администраторы
Сообщений: 692
Статус: Offline
Смотрел переписку WeeRuz на британском сайте, автор описал несколько ошибок, будет исправлять. Так что, должна выйти полностью рабочая версия.
Что интересно, одна из ошибок - на карте может работать только один триггер, а я поставил три и все работают. Единственное "но" - система частиц отображается только на родительском. Еще одна из ошибок - мод конфликтует сам с собой, может быть поэтому и проблемы с молоком.
 
VVPutinДата: Пятница, 26.11.2010, 17:12 | Сообщение # 6
Ударник- Модокопатель
Группа: Администраторы
Сообщений: 578
Репутация: 90
Статус: Offline
Beckar, А я поставил это мод и при загрузке культур, действительно слева появилось меню.Но что либо выбрать я не смог.Стрелки на выбор культур не реагируют. sad
 
BeckarДата: Пятница, 26.11.2010, 23:10 | Сообщение # 7
Группа: Администраторы
Сообщений: 692
Статус: Offline
VVPutin, стрелки не на нумпаде, а те, что камеру перемещают.
 
VVPutinДата: Пятница, 26.11.2010, 23:52 | Сообщение # 8
Ударник- Модокопатель
Группа: Администраторы
Сообщений: 578
Репутация: 90
Статус: Offline
Beckar, Так я и те и эти стрелки нажимал, а у меня почему то камера ходит.Ладно чёрт с ним ,всё равно он пока не рабочий
 
BeckarДата: Суббота, 27.11.2010, 15:05 | Сообщение # 9
Группа: Администраторы
Сообщений: 692
Статус: Offline
Quote (VVPutin)
а у меня почему то камера ходит

Правильно, а вместе с камерой выбираются культуры. smile
 
sashok1970Дата: Среда, 01.12.2010, 14:50 | Сообщение # 10
Директор автозавода
Группа: Коллеги
Сообщений: 80
Репутация: 3
Статус: Offline


Сообщение отредактировал sashok1970 - Среда, 01.12.2010, 14:51
 
VVPutinДата: Среда, 01.12.2010, 15:13 | Сообщение # 11
Ударник- Модокопатель
Группа: Администраторы
Сообщений: 578
Репутация: 90
Статус: Offline
sashok1970, Ух ты!!! Круто!! hands И как это сделать?
 
BeckarДата: Среда, 01.12.2010, 15:14 | Сообщение # 12
Группа: Администраторы
Сообщений: 692
Статус: Offline
sashok1970
Да, он предлагает выбрать культуру, но выбирать не из чего.
 
VVPutinДата: Среда, 01.12.2010, 16:30 | Сообщение # 13
Ударник- Модокопатель
Группа: Администраторы
Сообщений: 578
Репутация: 90
Статус: Offline
sashok1970, Ну что,не опубликуешь своё творение?
 
AGROMASH25Дата: Среда, 01.12.2010, 17:09 | Сообщение # 14
Группа: Экскурсанты
Сообщений: 18
Репутация: 1
Статус: Offline
Да хорошая идея с молоком,а то без воды и молока как то не то biggrin
 
VVPutinДата: Пятница, 24.12.2010, 19:01 | Сообщение # 15
Ударник- Модокопатель
Группа: Администраторы
Сообщений: 578
Репутация: 90
Статус: Offline
Извиняюсь,не разглядел скрин,как следует sad

Добавлено (24.12.2010, 19:01)
---------------------------------------------
Интересную информацию увидел сегодня.Оказывается у PDA и ManySilo один и тот же XML wacko

 
FS Форум » Моделирование » Скриптинг » ManySilo (Мультифрут триггер) (Установка. Обсуждение. Проблемы.)
  • Страница 1 из 2
  • 1
  • 2
  • »
Поиск:

Для добавления необходима авторизация