afro1967 Posted October 13, 2013 Share Posted October 13, 2013 In need of an example of how to make an item spawn where I need it to.I gave this and a few others a go. SpawnPrefab("axe").Transform:SetPosition(inst.Transform:GetWorldPosition(-445, 20, 0)) Also could use help with making it rain when i need it to. Thanks Link to comment Share on other sites More sharing options...
Malacath Posted October 13, 2013 Share Posted October 13, 2013 In need of an example of how to make an item spawn where I need it to.I gave this and a few others a go. SpawnPrefab("axe").Transform:SetPosition(inst.Transform:GetWorldPosition(-445, 20, 0))Usually you'll want to store your prefab in a local variable for best possible access. The rest you did was fine though 20 in the y-direction would mean that the prefab spawns high above the ground and will fall down. I usually do it like this when spawning an item, in this case close to the player.local pig = SpawnPrefab("pigman")local player = GetPlayer()local pos = player:GetPosition()pos.x = pos.x + 6pos.z = pos.z + 6pig.Transform:SetPosition(pos:Get())pig.components.combat:SuggestTarget(player)--this line shows why it might make sense to store the prefab in a variableCalling down rain is actually a really easy oneliner, I guess you can figure it out ; )GetSeasonManager():ForcePrecip()Hope it helps. Link to comment Share on other sites More sharing options...
afro1967 Posted October 13, 2013 Author Share Posted October 13, 2013 Usually you'll want to store your prefab in a local variable for best possible access. The rest you did was fine though 20 in the y-direction would mean that the prefab spawns high above the ground and will fall down. I usually do it like this when spawning an item, in this case close to the player.local pig = SpawnPrefab("pigman")local player = GetPlayer()local pos = player:GetPosition()pos.x = pos.x + 6pos.z = pos.z + 6pig.Transform:SetPosition(pos:Get())pig.components.combat:SuggestTarget(player)--this line shows why it might make sense to store the prefab in a variableCalling down rain is actually a really easy oneliner, I guess you can figure it out ; )GetSeasonManager():ForcePrecip()Hope it helps.Thank you very much! Link to comment Share on other sites More sharing options...
afro1967 Posted October 14, 2013 Author Share Posted October 14, 2013 Usually you'll want to store your prefab in a local variable for best possible access. The rest you did was fine though 20 in the y-direction would mean that the prefab spawns high above the ground and will fall down. I usually do it like this when spawning an item, in this case close to the player.local pig = SpawnPrefab("pigman")local player = GetPlayer()local pos = player:GetPosition()pos.x = pos.x + 6pos.z = pos.z + 6pig.Transform:SetPosition(pos:Get())pig.components.combat:SuggestTarget(player)--this line shows why it might make sense to store the prefab in a variableCalling down rain is actually a really easy oneliner, I guess you can figure it out ; )GetSeasonManager():ForcePrecip()Hope it helps.Is there an easy way to add the icon for your prefab to the minimap? Link to comment Share on other sites More sharing options...
Malacath Posted October 14, 2013 Share Posted October 14, 2013 Is there an easy way to add the icon for your prefab to the minimap?I don't know... is there a hard way? Link to comment Share on other sites More sharing options...
Developer Cheerio Posted October 14, 2013 Developer Share Posted October 14, 2013 Is there an easy way to add the icon for your prefab to the minimap?This should work:local minimap = inst.entity:AddMiniMapEntity()minimap:SetIcon( "beehive.png" )I'd also like to suggest checking out the Scripting with Sublime guide. I didn't know how to add a minimap icon but I just searched for the word 'minimap' using Sublime and came up with a ton of examples. The guide might be helpful if you need to search for other things in the future. Link to comment Share on other sites More sharing options...
Malacath Posted October 14, 2013 Share Posted October 14, 2013 This should work:local minimap = inst.entity:AddMiniMapEntity()minimap:SetIcon( "beehive.png" )I'd also like to suggest checking out the Scripting with Sublime guide. I didn't know how to add a minimap icon but I just searched for the word 'minimap' using Sublime and came up with a ton of examples. The guide might be helpful if you need to search for other things in the future.Of course, finding the code is obvious. But I never managed to add my own icons. Maybe I'm just stupid though ^^' Link to comment Share on other sites More sharing options...
Developer Cheerio Posted October 14, 2013 Developer Share Posted October 14, 2013 Of course, finding the code is obvious. But I never managed to add my own icons. Maybe I'm just stupid though ^^'I think it should be as simple as compiling a new tex and specifying that name in the 'SetIcon' method but if it isn't, let me know and I'll look into it. Link to comment Share on other sites More sharing options...
TheDanaAddams Posted October 14, 2013 Share Posted October 14, 2013 I would be very interested in knowing how exactly to read in a custom map icon - as far as I was aware, we couldn't do it, due to the way the map icons were set up! Link to comment Share on other sites More sharing options...
afro1967 Posted October 15, 2013 Author Share Posted October 15, 2013 I would be very interested in knowing how exactly to read in a custom map icon - as far as I was aware, we couldn't do it, due to the way the map icons were set up!Yes I always thought we had to add our icon to the sheet along with the added xml info,but this looks hopeful! Link to comment Share on other sites More sharing options...
Malacath Posted October 15, 2013 Share Posted October 15, 2013 I'll do my best to add a custom minimap icon. I'll let you know if it works as expected.EDIT: Nope, no way I'm gonna do this. I put the file in 5 different locations, used 3 different combinations of code and naming, all the same result:Assert failure 'icon_element != NULL' at ..\source\game\components\MiniMapRenderer.cpp(371): Trace follows...So, Cheerio any clues on how to do it exactly? Because the naming of the files in the minimap folder as well as the fact that the images are called "*.png" confuse me as to how it's done properly Link to comment Share on other sites More sharing options...
Developer Cheerio Posted October 15, 2013 Developer Share Posted October 15, 2013 I'll do my best to add a custom minimap icon. I'll let you know if it works as expected.EDIT: Nope, no way I'm gonna do this. I put the file in 5 different locations, used 3 different combinations of code and naming, all the same result:Assert failure 'icon_element != NULL' at ..\source\game\components\MiniMapRenderer.cpp(371): Trace follows...So, Cheerio any clues on how to do it exactly? Because the naming of the files in the minimap folder as well as the fact that the images are called "*.png" confuse me as to how it's done properlyThat sucks. I'll look into it . Link to comment Share on other sites More sharing options...
Developer Cheerio Posted October 16, 2013 Developer Share Posted October 16, 2013 I'll do my best to add a custom minimap icon. I'll let you know if it works as expected.EDIT: Nope, no way I'm gonna do this. I put the file in 5 different locations, used 3 different combinations of code and naming, all the same result:Assert failure 'icon_element != NULL' at ..\source\game\components\MiniMapRenderer.cpp(371): Trace follows...So, Cheerio any clues on how to do it exactly? Because the naming of the files in the minimap folder as well as the fact that the images are called "*.png" confuse me as to how it's done properlySo it used to be hard to do because you had to add your own images to the minimap atlas but in the next hotfix for the public preview it's much easier. There will be basically 3 parts to setting up a minimap icon. Step#1: Load a new atlas for your minimaplocal image_path = resolvefilepath("images/myminimap.tex")local atlas_path = resolvefilepath("images/myminimap.xml")local Assets ={ Asset("IMAGE", image_path), Asset("ATLAS", atlas_path),} Step#2: Tell the minimap about your new atlasGetWorld().minimap.MiniMap:AddAtlas(atlas_path) Step#3: Tell your prefab which icon to use inside your minimap atlaslocal minimap = inst.entity:AddMiniMapEntity()minimap:SetIcon( "myminimap.tex" ) And that should work. Remember, this won't work until the new hotfix for the public preview is available which should be in the next couple of days. Link to comment Share on other sites More sharing options...
TheDanaAddams Posted October 16, 2013 Share Posted October 16, 2013 Brilliant!Been looking forward to being able to do this. I didn't think it was possible, so I'm glad to know that was - and more importantly, is no longer - the case. =) Edit: One thing! How big should our map icons be? What image-dimensions? Link to comment Share on other sites More sharing options...
Developer Cheerio Posted October 16, 2013 Developer Share Posted October 16, 2013 Brilliant!Been looking forward to being able to do this. I didn't think it was possible, so I'm glad to know that was - and more importantly, is no longer - the case. =) Edit: One thing! How big should our map icons be? What image-dimensions?They can be whatever size looks good to you, just make sure they're square. Also if you have one or two icons, having seperate .tex files is fine but if you're going to add a bunch of minimap icons, it'll run way better if you make one big atlas with all the images inside. Link to comment Share on other sites More sharing options...
Malacath Posted October 16, 2013 Share Posted October 16, 2013 They can be whatever size looks good to you, just make sure they're square. Also if you have one or two icons, having seperate .tex files is fine but if you're going to add a bunch of minimap icons, it'll run way better if you make one big atlas with all the images inside.Great, thanks a lot ^^ @TheDanaAddams If I'm not mistaken then the vanilla minimap icons are 64x64. Link to comment Share on other sites More sharing options...
Developer Cheerio Posted October 16, 2013 Developer Share Posted October 16, 2013 Great, thanks a lot ^^ @TheDanaAddams If I'm not mistaken then the vanilla minimap icons are 64x64.I think I used 16x16 in the screenshot. Link to comment Share on other sites More sharing options...
Malacath Posted October 16, 2013 Share Posted October 16, 2013 I think I used 16x16 in the screenshot.Wow, that's tiny. But they are about half as big as Wilson, so 32x32 should be the way to go I guess. Link to comment Share on other sites More sharing options...
TheDanaAddams Posted October 16, 2013 Share Posted October 16, 2013 I think I used 16x16 in the screenshot.Which would make the character portrait about 32x32? Edit: Ninja'd. Link to comment Share on other sites More sharing options...
afro1967 Posted October 16, 2013 Author Share Posted October 16, 2013 This should work:local minimap = inst.entity:AddMiniMapEntity()minimap:SetIcon( "beehive.png" )I'd also like to suggest checking out the Scripting with Sublime guide. I didn't know how to add a minimap icon but I just searched for the word 'minimap' using Sublime and came up with a ton of examples. The guide might be helpful if you need to search for other things in the future.Thanks for the scripting tools! I searched and tryed and tryed with no success, then read the rest of the thread Link to comment Share on other sites More sharing options...
afro1967 Posted October 16, 2013 Author Share Posted October 16, 2013 This should work:local minimap = inst.entity:AddMiniMapEntity()minimap:SetIcon( "beehive.png" )I'd also like to suggest checking out the Scripting with Sublime guide. I didn't know how to add a minimap icon but I just searched for the word 'minimap' using Sublime and came up with a ton of examples. The guide might be helpful if you need to search for other things in the future.Another deal I need help with is tut example.I have created an animal and for the life of me can't get the animation to flip directions.Your help would be appreciated. If chased from behind he runs forward okay, but the darn stubborn ass will not turn around if chased from the front. Link to comment Share on other sites More sharing options...
Developer Cheerio Posted October 16, 2013 Developer Share Posted October 16, 2013 Try one of these: inst.Transform:SetTwoFaced() inst.Transform:SetFourFaced() Link to comment Share on other sites More sharing options...
afro1967 Posted October 16, 2013 Author Share Posted October 16, 2013 Thanks SetTwoFaced worked for now,but how will the face and back animation be called? SetFourFaced but how will the game specify? Link to comment Share on other sites More sharing options...
Developer Cheerio Posted October 17, 2013 Developer Share Posted October 17, 2013 Thanks SetTwoFaced worked for now,but how will the face and back animation be called? SetFourFaced but how will the game specify?There's a naming convention for the animations for four faced. If you wanted to use a set of animations called 'walk_loop'and you set your prefab to four faced, your animations would have to be called 'walk_loop_up', 'walk_loop_down' and 'walk_loop_side' and the animation system will handle picking the right animation for you. Link to comment Share on other sites More sharing options...
afro1967 Posted October 17, 2013 Author Share Posted October 17, 2013 There's a naming convention for the animations for four faced. If you wanted to use a set of animations called 'walk_loop'and you set your prefab to four faced, your animations would have to be called 'walk_loop_up', 'walk_loop_down' and 'walk_loop_side' and the animation system will handle picking the right animation for you.Thanks again! I really am trying figure this code out for myself. Link to comment Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.
Please be aware that the content of this thread may be outdated and no longer applicable.