finlach Posted May 28, 2015 Share Posted May 28, 2015 I am making a mod were you play as a spider queen and was wondering if it would be able for when you attach to summon spiders. I was also wondering if summoning a spider could be bound to a key. Link to comment Share on other sites More sharing options...
Seiai Posted May 28, 2015 Share Posted May 28, 2015 (edited) @finlach,add this to your modmain and replace yourcharactersprefabname with your character's prefabname:local function SpawnSpider(player) local pos = GLOBAL.Vector3(player.Transform:GetWorldPosition()) local offset = (GLOBAL.FindWalkableOffset(pos,math.random()*GLOBAL.PI*2,0.5,false)) if offset == nil then if player.components.talker then player.components.talker:Say("No Space!", 2.5) end return end pos=pos+offset local unit=GLOBAL.SpawnPrefab("spider") unit.Transform:SetPosition(pos:Get()) player.components.leader:AddFollower(unit) endAddModRPCHandler(modname, "SpawnSpider", SpawnSpider)GLOBAL.TheInput:AddKeyDownHandler(GLOBAL.KEY_X, function()local player=GLOBAL.ThePlayerif player and player.prefab=="yourcharactersprefabname" and not GLOBAL.IsPaused() and not GLOBAL.TheInput:IsKeyDown(GLOBAL.KEY_CTRL) and not GLOBAL.TheInput:IsKeyDown(GLOBAL.KEY_SHIFT) and not player.HUD:IsChatInputScreenOpen() and not player.HUD:IsConsoleScreenOpen()then SendModRPCToServer(MOD_RPC[modname]["SpawnSpider"])end end)X is the Hotkey here to spawn them. Edited May 28, 2015 by Seiai Link to comment Share on other sites More sharing options...
finlach Posted May 29, 2015 Author Share Posted May 29, 2015 Thanks is working. Link to comment Share on other sites More sharing options...
Codelyy Posted May 30, 2015 Share Posted May 30, 2015 @finlach,add this to your modmain and replace yourcharactersprefabname with your character's prefabname: local function SpawnSpider(player) local pos = GLOBAL.Vector3(player.Transform:GetWorldPosition()) local offset = (GLOBAL.FindWalkableOffset(pos,math.random()*GLOBAL.PI*2,0.5,false)) if offset == nil then if player.components.talker then player.components.talker:Say("No Space!", 2.5) end return end pos=pos+offset local unit=GLOBAL.SpawnPrefab("spider") unit.Transform:SetPosition(pos:Get()) player.components.leader:AddFollower(unit) endAddModRPCHandler(modname, "SpawnSpider", SpawnSpider)GLOBAL.TheInput:AddKeyDownHandler(GLOBAL.KEY_X, function()local player=GLOBAL.ThePlayerif player and player.prefab=="yourcharactersprefabname" and not GLOBAL.IsPaused() and not GLOBAL.TheInput:IsKeyDown(GLOBAL.KEY_CTRL) and not GLOBAL.TheInput:IsKeyDown(GLOBAL.KEY_SHIFT) and not player.HUD:IsChatInputScreenOpen() and not player.HUD:IsConsoleScreenOpen()then SendModRPCToServer(MOD_RPC[modname]["SpawnSpider"])end end)X is the Hotkey here to spawn them. I copied this code just to try it out with my character but i get an error every single time i press X saying that the variable "Player" is not declared Link to comment Share on other sites More sharing options...
Seiai Posted May 30, 2015 Share Posted May 30, 2015 @codelyoko373, did u add it to your modmain? can u attach your modmain and the logfile? Link to comment Share on other sites More sharing options...
Codelyy Posted May 30, 2015 Share Posted May 30, 2015 (edited) @codelyoko373,did u add it to your modmain?can u attach your modmain and the logfile? Well this is my modmain: local MakePlayerCharacter = require "prefabs/player_common"local assets = {Asset( "ANIM", "anim/player_basic.zip" ),Asset( "ANIM", "anim/player_idles_shiver.zip" ),Asset( "ANIM", "anim/player_actions.zip" ),Asset( "ANIM", "anim/player_actions_axe.zip" ),Asset( "ANIM", "anim/player_actions_pickaxe.zip" ),Asset( "ANIM", "anim/player_actions_shovel.zip" ),Asset( "ANIM", "anim/player_actions_blowdart.zip" ),Asset( "ANIM", "anim/player_actions_eat.zip" ),Asset( "ANIM", "anim/player_actions_item.zip" ),Asset( "ANIM", "anim/player_actions_uniqueitem.zip" ),Asset( "ANIM", "anim/player_actions_bugnet.zip" ),Asset( "ANIM", "anim/player_actions_fishing.zip" ),Asset( "ANIM", "anim/player_actions_boomerang.zip" ),Asset( "ANIM", "anim/player_bush_hat.zip" ),Asset( "ANIM", "anim/player_attacks.zip" ),Asset( "ANIM", "anim/player_idles.zip" ),Asset( "ANIM", "anim/player_rebirth.zip" ),Asset( "ANIM", "anim/player_jump.zip" ),Asset( "ANIM", "anim/player_amulet_resurrect.zip" ),Asset( "ANIM", "anim/player_teleport.zip" ),Asset( "ANIM", "anim/wilson_fx.zip" ),Asset( "ANIM", "anim/player_one_man_band.zip" ),Asset( "ANIM", "anim/shadow_hands.zip" ),Asset( "SOUND", "sound/sfx.fsb" ),Asset( "SOUND", "sound/wilson.fsb" ),Asset( "ANIM", "anim/beard.zip" ),Asset( "ANIM", "anim/esctemplate.zip" ),}local prefabs = {}local start_inv = {-- Custom starting items}local fn = function(inst)-- choose which sounds this character will playinst.soundsname = "willow"-- Minimap iconinst.MiniMapEntity:SetIcon( "esctemplate.tex" )-- Statsinst.components.health:SetMaxHealth(150)inst.components.hunger:SetMax(150)inst.components.sanity:SetMax(200)-- Damage multiplier (optional)inst.components.combat.damagemultiplier = 1-- Hunger rate (optional)inst.components.hunger.hungerrate = 1 * TUNING.WILSON_HUNGER_RATE-- Movement speed (optional)inst.components.locomotor.walkspeed = 4inst.components.locomotor.runspeed = 6endlocal function SpawnSpider(player)local pos = GLOBAL.Vector3(player.Transform:GetWorldPosition())local offset = (GLOBAL.FindWalkableOffset(pos,math.random()*GLOBAL.PI*2,0.5,false))if offset == nil thenif player.components.talker thenplayer.components.talker:Say("No Space!", 2.5)endreturnendpos=pos+offsetlocal unit=GLOBAL.SpawnPrefab("spider")unit.Transform:SetPosition(pos:Get())player.components.leader:AddFollower(unit)endAddModRPCHandler(modname, "SpawnSpider", SpawnSpider)GLOBAL.TheInput:AddKeyDownHandler(GLOBAL.KEY_X, function()local player=GLOBAL.ThePlayerif player and player.prefab=="esctemplate"and not GLOBAL.IsPaused() and not GLOBAL.TheInput:IsKeyDown(GLOBAL.KEY_CTRL) and not GLOBAL.TheInput:IsKeyDown(GLOBAL.KEY_SHIFT)and not player.HUD:IsChatInputScreenOpen() and not player.HUD:IsConsoleScreenOpen()thenSendModRPCToServer(MOD_RPC[modname]["SpawnSpider"])endend)return MakePlayerCharacter("esctemplate", prefabs, assets, fn, start_inv)Don't know where my logfile is... sorry Edited May 30, 2015 by codelyoko373 Link to comment Share on other sites More sharing options...
Seiai Posted May 30, 2015 Share Posted May 30, 2015 (edited) Don't know where my logfile is... sorrythen u should read a few tutorials, will also help u a lot with modding, i suggest this: http://forums.kleientertainment.com/topic/50811-guide-modding-practices-series-index/ and there's a lot of other good tutorials on the top areas of this forum and of the modforum for regular dont starve http://forums.kleientertainment.com/forum/26-dont-starve-mods-and-tools/ your logfile is in Documents\Klei\DoNotStarveTogether\log.txt and the file u posted is not your modmain but your character's prefabfile. the modmain is called modmain.lua. u have to add the code there. Edited May 30, 2015 by Seiai Link to comment Share on other sites More sharing options...
Codelyy Posted May 30, 2015 Share Posted May 30, 2015 then u should read a few tutorials, will also help u a lot with modding, i suggest this: http://forums.kleientertainment.com/topic/50811-guide-modding-practices-series-index/and there's a lot of other good tutorials on the top areas of this forum and of the modforum for regular dont starve http://forums.kleientertainment.com/forum/26-dont-starve-mods-and-tools/your logfile is inDocuments\Klei\DoNotStarveTogether\log.txtand the file u posted is not your modmain but your character's prefabfile.the modmain is called modmain.lua.u have to add the code there.Thanks for the tutorial links and i have no idea why i put it in my prefabfile XD... I swear i put it in the modmain but i guess i was getting confused with all the windows i had up at the same time. Link to comment Share on other sites More sharing options...
finlach Posted June 2, 2015 Author Share Posted June 2, 2015 Is working fine. Though when I was testing to add to me and my friend (mb's) mod. We could not find a way to add the birthing animation as well as putting a cap on the amount of spiders being spawned. Thank you very much Link to comment Share on other sites More sharing options...
Seiai Posted June 2, 2015 Share Posted June 2, 2015 @finlach,to limit the spiders to 10, add this local spiders=0 for k,v in pairs(player.components.leader.followers) do if k.prefab=="spider" then spiders=spiders+1 end end if spiders>=10 then if player.components.talker then player.components.talker:Say("Dude, I'm no damn spiderhorder!", 2.5) end return false endright afterlocal function SpawnSpider(player)*there might be synthaxerror, didn't actually run itwith "adding the birthinganimation", do u mean a custom animation u made in spriter? Link to comment Share on other sites More sharing options...
Blackbando Posted June 4, 2015 Share Posted June 4, 2015 Something I'd like to point out: There's already a DST mod adding Spider Queen. And it works just like regular Spider Queen. Link to comment Share on other sites More sharing options...
Mbfox Posted June 7, 2015 Share Posted June 7, 2015 @Seiai, Thanks so much for your help! The baby limit script worked fine Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now