Skip to content

Commit

Permalink
Added XML Tools
Browse files Browse the repository at this point in the history
  • Loading branch information
w33zl committed Nov 30, 2022
1 parent 23b30bf commit 3a35484
Show file tree
Hide file tree
Showing 4 changed files with 127 additions and 1 deletion.
44 changes: 44 additions & 0 deletions GE Toolbox (by w33zl)/XML Tools/GEPT_CreateI3DMappings_v1.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
-- Name: Create i3d XML mappings (v1)
-- Author: w33zl
-- Description: Prints a XML tag in the log for each selected node in the scenegraph
-- Icon:
-- Hide: no

--[[
Version: 1.0
Modified: 2022-02-27
Facebook: https://www.facebook.com/w33zl
Ko-fi: https://ko-fi.com/w33zl
Patreon: https://www.patreon.com/wzlmodding
Github: https://github.com/w33zl
Changelog:
v1.0.0 Initial version
]]

source("editorUtils.lua")

local nNumSelectedNodes = getNumSelected()

if nNumSelectedNodes <= 0 then

print ( "Nothing selected. Please select at least 1 object. ")
return

elseif nNumSelectedNodes >= 1 then

local nSelectedRootNodeID = getSelection( 0 )

print("Creating i3d mappings...")

for i=0, nNumSelectedNodes - 1, 1 do

local selectedNodeID = getSelection( i )
local _, indexPath = EditorUtils.getHierarchy(selectedNodeID)
local name = getName(selectedNodeID)

print( string.format("<i3dMapping id=\"%s\" node=\"%s\" />", name, indexPath ));

end
end
68 changes: 68 additions & 0 deletions GE Toolbox (by w33zl)/XML Tools/GEPT_CreateI3DMappings_v2.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
-- Name: Create i3d XML mappings (v2)
-- Author: w33zl
-- Description: Prints a XML tag in the log for each selected node in the scenegraph
-- Icon:
-- Hide: no

--[[
Author: w33zl / WZL Modding
Version: 2.0
Modified: 2022-02-27
Facebook: https://www.facebook.com/w33zl
Ko-fi: https://ko-fi.com/w33zl
Patreon: https://www.patreon.com/wzlmodding
Github: https://github.com/w33zl
Changelog:
v2.0.0 Initial version (fork of v1)
]]

local nNumSelectedNodes = getNumSelected()

local function getIndexPath(node)
local name = getName(node)
local index = getChildIndex(node)
local parent = getParent(node)
local grandParent = getParent(parent)

if grandParent == getChildAt(getRootNode(), 0) then
local p_name, p_index = getIndexPath(parent)
name = p_name .. name
index = p_index .. index
elseif parent ~= 0 and parent ~= getChildAt(getRootNode(), 0) then
local p_name, p_index = getIndexPath(parent)
name = p_name .. "|" .. name
index = p_index .. "|" .. index
else
name = name .. ">"
index = index .. ">"
end
return name, index
end

if nNumSelectedNodes <= 0 then

print ( "Nothing selected. Please select at least 1 object. ")
return

elseif nNumSelectedNodes >= 1 then

local nSelectedRootNodeID = getSelection( 0 )

print("Creating i3d mappings...\n")

print("\n==[COPY TEXT BELOW]=================")


for i=0, nNumSelectedNodes - 1, 1 do

local selectedNodeID = getSelection( i )
local _, indexPath = getIndexPath(selectedNodeID)
local name = getName(selectedNodeID)

print( string.format("<i3dMapping id=\"%s\" node=\"%s\" />", name, indexPath ));

end
print("====================================")
end
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ GE Toolbox is a collection of scripts, tools and guides to simplify modding for
## Overview / Contents

- [Export Spline to a .obj file](Spline2Obj.md)
- *TBA*
- [XML Tools](XMLTools.md)


## Installation
Expand Down
14 changes: 14 additions & 0 deletions XMLTools.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
# GE Toolbox - XML Tools

This collection of scripts helps creating XML for the ingame assets.

## Create i3d XML mappings

### Usage
1. Select one or more nodes in the scenegraph in GE
2. Execute script "*Create i3d XML mappings (v2)*" in the scripts folder/submenu `GE Toolbox/XML Tools` (for keyboard shortcut, check [GE-HAM](https://github.com/w33zl/GE-Hotkeys-and-Macros))
3. The script now outputs a XML tag for each node selected with the node name as the "id" attribute and the index path as the "node" attribute, e.g. `<i3dMapping id="sampleNode" node="0>1" />`
4. Copy the text below the line `==[COPY TEXT BELOW]=================` and then paste into your vehicle/placeable XML file

***Please note:** There is two versions (v1 and v2) included, it is recommended to use the v2 version.*

0 comments on commit 3a35484

Please sign in to comment.