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/02 15:33] polymorphgamespreview [2020/04/22 11:48] 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:
  
-===== How to Access 1.4 Preview ? ===== + function MY_CUSTOM_COMPONENT:computeWaterElevation(_globalPosition) 
-Contact developer on our [[https://discord.gg/foundation|discord server]].+    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
  
-===== Generated Documentation ===== +You can do the same with the ground by replacing OBJECT_FLAG.WATER by OBJECT_FLAG.GROUND
-  * [[preview:api|API]] +
-  * [[preview:assets|Assets]] +
-  * [[api:mod-functions|Mod functions]]+
  
-===== New Features ===== +If the water (or the ground) is not found (for instance when the _globalPosition out of the map) then warning is edited in the logs, and the code return the Y of the _globalPosition.
-  * [[preview:components|Setup components on FBX nodes]] +
-  * [[preview:workplaces|Create workplaces]] +
-  * [[preview:monuments|Create monuments and bridges]] +
-  * [[preview:walls|Create walls]] +
-  * [[preview:particle-effects|Create particle effects]] +
-  * [[preview:asset-override|Game asset override]] +
-  * [[preview:building-asset-processor|Building asset processor]] +
-  * [[preview:logs|Mod individual log file]] +
-  * [[preview:example-02|New mod example: Example 02 - Mithril Factory]] +
-  * [[preview:api:mod-functions:io|IO functions]] +
-  * [[preview:dependencies|Mod Dependencies]] +
-===== Migration Notes ===== +
-==== New mod.json ==== +
-In order to only load mods when enabled, Foundation will now need new description file for each mod. It will declare all the things Foundation would need to know about the mod without parsing the lua file.+
  
-<file json mod.json> 
-{ 
- "Name": "Simple Example Mod", 
- "Author": "Leo", 
- "Description": "A very simple mod example", 
- "Version": "2.0.0", 
  
- "AdditionalLanguageList": [ 
- { 
- "Name": "Klingon", 
- "Code": "tlh" 
- } 
- ] 
-} 
-</file> 
  
-==== createMod() function is simplified ==== 
-Since the new ''mod.json'' file already contains all basic information about the mod, the ''foundation.createMod()'' function does not take any parameter anymore. 
  
-<file lua mod.lua> 
-local myMod = foundation.createMod() 
-</file> 
- 
- 
-==== GENERAL_DATA asset type has been removed ==== 
-''GENERAL_DATA'' asset type has been removed and all its properties has been moved to ''BALANCING''. 
- 
-However, modders can now partially override Foundation main balancing (''DEFAULT_BALANCING''), instead of being forced to replace all balancing properties. see [[preview:asset-override|Asset override]] for more information. 

Donate Powered by PHP Valid HTML5 Valid CSS Driven by DokuWiki