Is that possible? How?
for example I want a map to use functions for spawning resources that are defined in the mod.
maplayout.lua in map:
GameStart()
SpawnResource (800,1200)
end
resource.lua in mod:
local resource_unit = "goldnugget"
function SpawnResource (x,y)
--lots of fancy stuff to spawn the unit in correct way
--doing changes here updates all maps, ie if the name of the resource_unit is changed
end
At the moment I basically do
CreateUnit (x,y, "goldnugget")
in the maps lua and of course that is a bit fail.
Just passing over all the resources positions in some global variable thing would be ok too, so hints on this are welcome too.
maps gadget calling mods gadget functions
Moderator: Moderators
Re: maps gadget calling mods gadget functions
Could you not rearrange this and instead of doing the logic in the map, only do the mod agnostic stuff on the map, and provide the necessary data for the mod specifics? Then access the data on the mod side and do it there.
For example, the map could generate a list of positions for the spawning units, then the games gadget can read this in and do the necessary business. This should be a lot more flexible, and it means you dont need to rerelease all your maps when you change the code a little, because its only in one place, the game.
For example, the map could generate a list of positions for the spawning units, then the games gadget can read this in and do the necessary business. This should be a lot more flexible, and it means you dont need to rerelease all your maps when you change the code a little, because its only in one place, the game.
Re: maps gadget calling mods gadget functions
Yes of course this would be fine too. Its what I meant withFor example, the map could generate a list of positions for the spawning units, then the games gadget can read this in and do the necessary business.
The reason you said is excactly why I want this, also so that mappers dont have to tell with the confusing stuff of UnitCreate etc.Just passing over all the resources positions in some global variable thing would be ok too
Would this be done with the _G.bla thing?
Re: maps gadget calling mods gadget functions
learned about including config files in #ca channel, will probally use that.
Re: maps gadget calling mods gadget functions
Map / Mod Gadgets are interchangeable and aren't separated in any way. Maps can call unitDefs in a specific mod, for example, without any problems at all. If you want your map to be agnostic, best (easy) result is to check the mod's name and see whether it matches, and then don't bother running, but there are more sophisticated methods, like setting a GG or G_ global, if you need to do that (be wary of order-of-operations issues, if all of this needs to happen before game start, however).