Community Forum

addPlaceableType does not work

Forum Overview >> Scripting

CategoryScripting
Created26.01.2019 15:09


Heady Planet-ls (Headshot XXL) 26.01.2019 15:10
I try to register a new placeable type with:

local ret = g_placeableTypeManager:addPlaceableType("BuildPlaceable", BuildPlaceable", Utils.getFilename("BuildPlaceable.lua", g_currentModDirectory), nil);

but get this in the log:

2019-01-26 14:59 Error: No filename specified for placeable type 'FS19_Build.BuildPlaceable'. Ignoriring it!

Whats wrong?

Bilbo Beutlin (BBeutlin) 26.01.2019 15:58
1. Missing leading quote for second argument
2. The global 'g_currentModDirectory' might be invalid inside functions. You should setup a variable just at begin of your code like
----------
myMod = {}
myMod.homeDir = g_currentModDirectory
----------
In your functions then use 'myMod.homeDir'

Heady Planet-ls (Headshot XXL) 27.01.2019 11:10
Good hint. But same problem.

Moddesc:
<extraSourceFiles>
<sourceFile filename="registerPlaceable.lua" />
</extraSourceFiles>

the code ist in the registerPlaceable.lua, in the first level, in no function:

local modDir = g_currentModDirectory;
local specFile = Utils.getFilename("BuildPlaceable.lua", modDir);
print("specFile: "..specFile)
local ret = g_placeableTypeManager:addPlaceableType("BuildPlaceable", "BuildPlaceable", specFile, nil);


Log:
2019-01-27 11:05 specFile: C:/Users/user/Documents/My Games/FarmingSimulator2019/mods/FS19_BuildPlaceable/BuildPlaceable.lua
2019-01-27 11:05 Error: No filename specified for placeable type 'FS19_BuildPlaceable.BuildPlaceable'. Ignoriring it!



Bilbo Beutlin (BBeutlin) 27.01.2019 12:59
In comparison with "PlaceableTypeManager.loadMapData" I'd suggest you try like
typeName = "myPlaceable"
className = "placeable" -or- "placeable.mySpec" - maybe class must be present, maybe it's created as subclass
customEnvironment = "" - instead nil, obviously 'addPlaceableType()' expects a string also if empty

Heady Planet-ls (Headshot XXL) 28.01.2019 18:47
I dont get any further

https://www.file-upload.net/download-13487912/FS19_PlaceableTest.zip.html


Heady Planet-ls (Headshot XXL) 31.01.2019 20:29
Is it possible to show the content of the function PlaceableTypeManager: addPlaceableType ()?


Note: Log in to post. Create a new account here.