Unlocking Items Automatically
Moderator: Sir Tawmis
-
- Posts: 35
- Joined: Fri Apr 12, 2019 5:59 am
Unlocking Items Automatically
Sorry, I might just be missing something in the documentation - but I am at the stage where I am adding some new weapons to the game but I was hoping to have the weapons/cards available "for free" without providing them as loot.
I am just testing with an accessory to start with to get my own cards into the game. Does anyone have any tips on any flags I can pass to def_accessory and/or something I can add to the load map hook to get the cards available without having to unlock them in the game?
I am just testing with an accessory to start with to get my own cards into the game. Does anyone have any tips on any flags I can pass to def_accessory and/or something I can add to the load map hook to get the cards available without having to unlock them in the game?
Re: Unlocking Items Automatically
Sorry for the looong delay! We've been on a long break after the intensive crunch we had in spring and we've just got back to finish the modding support.
The answer to your question depends where/when you want to add the cards. E.g. do you want to add them to the merchant stock after a mission, or add to the shared party inventory at the start of the campaign? Adding cards at the start of the campaign would be problematic because new mods can be added in the middle of a campaign, so the "start campaign" event would not be triggered...
I'm thinking something like the following would be a good addition to the modding API.
The functions set_registry() / get_registry() could be used to store any arbitrary key-value pairs in a global dictionary. The contents of the dictionary would be stored in savegames and could be a primitive way for mods to communicate with each other.
Would this work for you?
The answer to your question depends where/when you want to add the cards. E.g. do you want to add them to the merchant stock after a mission, or add to the shared party inventory at the start of the campaign? Adding cards at the start of the campaign would be problematic because new mods can be added in the middle of a campaign, so the "start campaign" event would not be triggered...
I'm thinking something like the following would be a good addition to the modding API.
Code: Select all
if not get_registry_key("$mod.new_merchant_items_added") then
local inv = get_merchant_stock()
add_inventory(inv, "$mod.johns_mighty_axe")
set_registry_key("$mod.new_merchant_items_added", true)
end
Would this work for you?
Re: Unlocking Items Automatically
I added the functions mentioned above. Check out the new version in Steam.
-
- Posts: 35
- Joined: Fri Apr 12, 2019 5:59 am
Re: Unlocking Items Automatically
Hope you had a great vacation!
Many thanks for the response (and the handy feature to support it) - I'm busy for the next few days but I am already looking forward to adding a few more items to the game and having my first small little mod ready .
Many thanks for the response (and the handy feature to support it) - I'm busy for the next few days but I am already looking forward to adding a few more items to the game and having my first small little mod ready .
-
- Posts: 35
- Joined: Fri Apr 12, 2019 5:59 am
Re: Unlocking Items Automatically
I might be being completely stupid, but I tried the above code in my mod and it doesn't seem to recognise the new functions that you mention. I have the following in my mod_main.lua file but it doesn't seem to recognise any of the new functions (get_registry_key or get_merchant_stock)...
Am I doing something stupid?
Code: Select all
-- make alterations to the world map
register_global_hook("on_enter_world_map", function(map)
local site = spawn("map_herb_plant", map, 0, 0, 0)
register_named_obj(map, site, "$mod.my_site")
set_world_pos3(site, 108.169685, 0.000000, -126.138138) -- TODO: you should probably relocate the mod to somewhere else to avoid overlapping with other mods
set_world_rot_euler(site, 0.000000, 0.563791, 0.000000)
set_obj_scale3(site, 1.0, 1.0, 1.0)
if not get_registry_key("$mod.new_merchant_items_added") then
local inv = get_merchant_stock()
add_inventory(inv, "$mod.johns_mighty_axe")
set_registry_key("$mod.new_merchant_items_added", true)
end
end)
Re: Unlocking Items Automatically
Sorry, I renamed a couple of functions:
get_registry, set_registry, get_merchant_inventory.
They should be documented in the scripting reference now.
get_registry, set_registry, get_merchant_inventory.
They should be documented in the scripting reference now.
-
- Posts: 35
- Joined: Fri Apr 12, 2019 5:59 am
Re: Unlocking Items Automatically
Ahhh - that's great, many thanks! Sorry for not checking - when I looked before the launch they weren't in the reference.
I will try again this weekend and see if I can get my "Oriental Weapons Pack" ported from Grimrock to Druidstone .
// JW
I will try again this weekend and see if I can get my "Oriental Weapons Pack" ported from Grimrock to Druidstone .
// JW
-
- Posts: 35
- Joined: Fri Apr 12, 2019 5:59 am
Re: Unlocking Items Automatically
That works a treat - I can see the card in Steelface's inventory - many thanks! I should have everything I need now to get my first 3D item into the game. Thanks again for your help!