User Tools

Site Tools


preview

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revisionPrevious revision
Next revision
Previous revision
Next revisionBoth sides next revision
preview [2019/10/04 17:13] maximepreview [2020/04/22 11:47] – created vjraymon
Line 1: Line 1:
-====== Preview Modding Documentation for Foundation 1.4 ======+====== Custom component: how to compute ground or water elevation ====== 
 +Since 1.5, Foundation allows to mod Custom component and links it to a fbx (see Exemple02)
  
-:!Please do not upload mods for Foundation 1.4 to mod.io before the official release of those modding features, since it would make your mod visible to all players, and they won't be able to play it :!:+The following LUA code computes and returns the global Y elevation of water from a global position: 
 + 
 +function MY_CUSTOM_COMPONENT:computeWaterElevation(_globalPosition) 
 +    local raycastResult = {} 
 +      
 +    -- Raycast from the _globalPosition + 1000 
 +    -- to _globalPosition - 1000 
 +    -- only on objects with a WATER flag 
 +    local FromPosition = { _globalPosition[1], _globalPosition[2]+1000, _globalPosition[3] } 
 +    local ToPosition = { _globalPosition[1], _globalPosition[2]-1000, _globalPosition[3] } 
 +    if not self:getLevel():rayCast(FromPosition, 
 +                                   ToPosition, 
 +                                   raycastResult, 
 +                                   2 ^ OBJECT_FLAG.WATER:toNumber()) then 
 +         MyMod:logWarning("MY_CUSTOM_COMPONENT: Water not found on the vertical of " 
 +                          .. tostring(_globalPosition)) 
 +         return _globalPosition[2] 
 +    else 
 +         return raycastResult["Position"][2] 
 +    end 
 +end 
 + 
 +You can do the same with the ground by replacing OBJECT_FLAG.WATER by OBJECT_FLAG.GROUND 
 + 
 +If the water (or the ground) is not found (for instance when the _globalPosition out of the map) then a warning is edited in the logs, and the code return the Y of the _globalPosition.
  
-===== How to Access 1.4 Preview ? ===== 
-Contact developer on our [[https://discord.gg/foundation|discord server]]. 
  
-===== Generated Documentation ===== 
-  * [[preview:api|API]] 
-  * [[preview:assets|Assets]] 
  
-===== New Features ===== 
-  * [[preview:api:custom_map|Create custom maps]] 
-  * [[migration#Building part function|Building part functions are now assets, declared individually]] 
-  * [[preview:api:building_function|Core building part functions have also been exposed to the API]] 
-  * [[migration#Resource type list|A resource can now have multiple resource types]] 
-  * [[preview:assets:prefab|Prefabs for the game can now be exposed: livestock and tool prefabs are now available]] 
-  * [[preview:assets:behavior_tree|The market tender behavior asset is now available]] 
-  * New [[preview:assets:building|buildings]], [[preview:assets:building_part|building parts]], [[preview:assets:resource|resources]] and [[preview:assets:job|jobs]] assets are now available 
-  * [[preview:api:comp_resource_container|The resource container component is available, allowing modders to create new resource containers on their maps]] 
  
-===== Migration Notes ===== 
-See in [[migration#Foundation 1.4|Migration page]]. 

Donate Powered by PHP Valid HTML5 Valid CSS Driven by DokuWiki