Boogiepop210 Posted August 19, 2022 Share Posted August 19, 2022 I want to learn how to use components and functions and help others have an better time while managing they're servers. Misc commands. function c_launch_flare(prefab) local flare = c_spawn("flare") local x, y, z = c_find(prefab).Transform:GetWorldPosition() flare.components.burnable:Ignite(true) flare.Transform:SetPosition(x, y, z) end You can guess what this does. ------------------------------------------------------------------------------------------------------- Replace objects with another prefab around an custom radius without replacing self. function c_replaceprefabs(prefab, radius, around, count) radius = radius or 4 around = around or ThePlayer local x,y,z = around.Transform:GetWorldPosition() local target_ents = TheSim:FindEntities(x,y,z, radius, count or nil, {"CLASSIFIED", "player"} ) for _,ent in pairs(target_ents) do local x,y,z = ent.Transform:GetWorldPosition() ent:Remove() SpawnPrefab(prefab).Transform:SetPosition(x,y,z) end end after using the command above do c_replaceprefab("prefab", radius, around, count) to do it ------------------------------------------------------------------------------------------------------- function c_extinguish(radius) radius = radius or 15 local x,y,z = ThePlayer.Transform:GetWorldPosition() local targets = TheSim:FindEntities(x,y,z, radius,nil,nil) for _,t in pairs(targets) do if t.components.burnable and t ~= AllPlayers[1] then t.components.burnable:Extinguish() end end end Extinguishs nearby prefabs if they're burning. Use c_extinguish(radius) to do after doing the command above. ------------------------------------------------------------------------------------------------------- function c_killnear(radius) radius = radius or 12 local x,y,z = ThePlayer.Transform:GetWorldPosition() local targets = TheSim:FindEntities(x,y,z, radius,nil,nil) for _,t in pairs(targets) do if t.components.health and t ~= AllPlayers[1] then t.components.health:Kill() end end end Kills things around the radius, use c_killnear(radius) to after using the command above to use. ------------------------------------------------------------------------------------------------------- Set other players speed c_select()c_speedmult(n) ------------------------------------------------------------------------------------------------------- Delete multiple objects around an certain radius. local REMOVE_CANT_TAGS={"CLASSIFIED", "player"} function c_removenearby(rad) local x,y,z = ConsoleWorldPosition():Get() local ents = TheSim:FindEntities(x,y,z, rad or 2, nil, REMOVE_CANT_TAGS) for k,v in pairs(ents) do v:Remove() end end After using command above use c_removenearby(rad) to remove nearby prefabs ------------------------------------------------------------------------------------------------------- Make an circle function c_makecircle(prefab, count) count = count or 16 local r = 4 for theta = 0, PI2, PI2 / count do local inst = DebugSpawn(prefab) local x,y,z = inst.Transform:GetWorldPosition() inst.Transform:SetPosition(x + math.cos(theta) * r, y, z + math.sin(theta) * r) end end After you use the command above use c_makecircle("prefab", count) to do it. ------------------------------------------------------------------------------------------------------- Make an spiral function c_spiral(prefab,count,radius,loops) count = count or 16 radius = radius or 4 loops = loops or 3 local inst = SpawnPrefab(prefab) if inst == nil then return nil end local x,y,z = ThePlayer.Transform:GetWorldPosition() local step = PI2 / count inst.Transform:SetPosition( x + 0, y, z + radius ) for theta = 0, PI2 * loops + step, step do radius = radius + step inst = SpawnPrefab(prefab) inst.Transform:SetPosition( x + radius * math.sin(theta), y, z + radius * math.cos(theta) ) end end Use c_spiral"prefab" or c_spiral("prefab",count,radius,loops) after using the command above to spawn an spiral ------------------------------------------------------------------------------------------------------- make players do animations. AllPlayers[number].AnimState:PlayAnimation("animation name", false). Animation list here ------------------------------------------------------------------------------------------------------- make existing items have more durrablity or no durrablity. No durrablity command c_select():RemoveComponent("finiteuses") more durrablity command c_select().components.finiteuses:SetUses(amount) ------------------------------------------------------------------------------------------------------- Use c_give with other players c_select()c_give("prefab") ------------------------------------------------------------------------------------------------------- Revive all players for k,v in pairs (AllPlayers) do v:PushEvent('respawnfromghost') end -------------------------------------------------------------------------------------------------- Drop everyone's items for k,v in pairs (AllPlayers) do v.components.inventory:DropEverything(true) end -------------------------------------------------------------------------------------------------- Give everyone creative for k,v in pairs (AllPlayers) do v.components.builder:GiveAllRecipes() do c_supergodmode(v) do c_maintainall(v) end end end ------------------------------------------------------------------------------------------------------- Combat commands. Commit arson function c_ignite(radius,burntime) radius = radius or 12 local x,y,z = ThePlayer.Transform:GetWorldPosition() local targets = TheSim:FindEntities(x,y,z, radius,nil,nil) for _,t in pairs(targets) do if t.components.burnable and t ~= AllPlayers[1] then t.components.burnable:Ignite(true, nil, burntime) end end end ------------------------------------------------------------------------------------------------------- Make stuff sleep function c_pacify(radius,sleepiness,sleeptime) radius = radius or 12 local x,y,z = ThePlayer.Transform:GetWorldPosition() local targets = TheSim:FindEntities(x,y,z, radius,nil,nil) for _,t in pairs(targets) do if t.components.sleeper and t ~= AllPlayers[1] then t.components.sleeper:AddSleepiness(sleepiness,sleeptime) end end end Use c_pacify(radius, sleepiness,sleeptime) after doing the command above do it. ------------------------------------------------------------------------------------------------------- Freeze entities around you (even other players) function c_freeze(radius,thawtime) radius = radius or 12 local x,y,z = ThePlayer.Transform:GetWorldPosition() local targets = TheSim:FindEntities(x,y,z, radius,nil,nil) for _,t in pairs(targets) do if t.components.freezable and t ~= AllPlayers[1] then t.components.freezable:Freeze(thawtime) end end end ------------------------------------------------------------------------------------------------------- Become invisible. ThePlayer:Hide() do ThePlayer:Show() to become visible again ------------------------------------------------------------------------------------------------------- Kill all players for k,v in pairs (AllPlayers) do v:PushEvent('death') end ------------------------------------------------------------------------------------------------------- Set attack speed ThePlayer.components.combat:SetAttackPeriod(period) ------------------------------------------------------------------------------------------------------- Set attack range ThePlayer.components.combat:SetRange(overralrange, hitrange) ------------------------------------------------------------------------------------------------------- function c_slaves(radius) radius = radius or 15 local x, y, z = ThePlayer.Transform:GetWorldPosition() local ents = TheSim:FindEntities(x, y, z, radius, nil,nil) for k, v in pairs(ents) do if v.components.follower then ThePlayer.components.leader:AddFollower(v) end end end This command adds entities around you. Use c_slaves(radius) after doing the command to use. ------------------------------------------------------------------------------------------------------- Random command Add tags c_select():AddTag("thetagyouwannaadd") ------------------------------------------------------------------------------------------------------- Extra commands ReplacePrefab(c_find"prefab you wanna replace", "prefab you want to replace the first one with") for example ReplacePrefab(c_find"multiplayer_portal", "multiplayer_portal_moon") ------------------------------------------------------------------------------------------------------- Place multiple things at once at any coordinate(reccomand having coordinate mod) (y/2)-2.9 part can make stairs if you don't want that then do the 2rd version. For x 1, 10 d for y 1,10 do local e = SpawnPrefab("wall_stone") e.Transform:SetPosition(x coordinate+x, (y or x/2)-2.9, z coordinate + y) end end ------------------------------------------------------------------------------------------------------- For x 1, 10 d for y 1,10 do local e = SpawnPrefab("wall_stone") e.Transform:SetPosition(x coordinate+x, y coordinate, z coordinate + y) end end ------------------------------------------------------------------------------------------------------- My favorite commands function c_colorselected(r, g, b, light) c_select().AnimState:SetMultColour(1,1,1,1) c_select().AnimState:SetAddColour(r,g,b,1) c_select().AnimState:SetLightOverride(light or 1) c_select().AnimState:SetHaunted(true) end Same as c_cyan but things under you cursor will become cyan. ------------------------------------------------------------------------------------------------------- function c_light(r,g,b, intensity, radius, falloff) local light = c_select().entity:AddLight() light:SetColour(r,g,b) light:SetIntensity(intensity or 0.8) light:SetRadius(radius) light:SetFalloff(falloff or 0.33) light:Enable(true) end Makes an light on the player (only players are affected) under the cursor. ------------------------------------------------------------------------------------------------------- function c_sanityaura(num) c_select():AddComponent ("sanityaura") c_select().components.sanityaura.aura = num end selected entity gets an sanity aura(use decimals as whole numbers are too big). Use c_sanityaura(num) after using command above to do it. ------------------------------------------------------------------------------------------------------- AllPlayers[1]:ListenForEvent("attacked", function() c_spawn("tornado").Transform:SetPosition(AllPlayers[1].Transform:GetWorldPosition()) AllPlayers[1].components.health:DoDelta(100, 50) end) ------------------------------------------------------------------------------------------------------ automatic revive after death. AllPlayers[1]:ListenForEvent("makeplayerghost", function AllPlayers[1]:PushEvent("respawnfromghost") end) ------------------------------------------------------------------------------------------------------- Checks if you asleep every five seconds and if you're then wakes you up and gives you god mode. function nosleepspam(inst) if inst.components.sleeper and inst.components.sleep:IsAsleep() then inst.components.sleeper:WakeUp() end end ThePlayer:DoPeriodicTask(1.5, nosleepspam) ------------------------------------------------------------------------------------------------------ Why do I hear boss music? GetPlayer().carolsoundoverride = "dontstarve/music/music_epicfight_stalker" ------------------------------------------------------------------------------------------------------- function c_setdamage(damage,attack,hit,range,percent,period,value,amount) c_select().components.combat:SetDefaultDamage(damage) c_select().components.combat:SetRange(attack, hit) c_select().components.combat:SetAreaDamage(range, percent) c_select().components.combat:SetAttackPeriod(period) c_select().components.combat.damagemultiplier=(value) c_select().components.health:SetMaxHealth(amount) end Literally sets nearly all combat aspects. The first line sets fist damage, the 2nd sets overral range and 3rd sets hit range, 4th sets area attack range and 5th sets are attack damage, 6th sets attack speed (can't go faster then one I think), 7th sets overral damagemultiplier and 8th sets health. Use c_setdamage(damage,attack,hit,range,percent,period,value,amount) after the command above to do it. ------------------------------------------------------------------------------------------------------- function rainboweffect(inst) local r, g, b = math.random(), math.random(), math.random() inst.AnimState:SetAddColour(r, g, b, 0) end c_select():DoPeriodicTask(0.2, rainboweffect) selected changes color every 0.2 seconds ------------------------------------------------------------------------------------------------------- Link to comment Share on other sites More sharing options...
Bumber64 Posted August 19, 2022 Share Posted August 19, 2022 1 hour ago, Insertnamehere2 said: Spawn skinned items without someone in the server needing to have them. Can't (legally) be done. Link to comment Share on other sites More sharing options...
Boogiepop210 Posted August 19, 2022 Author Share Posted August 19, 2022 Oof, well I'll have to stick with the wiki version that needs someone with the skin Link to comment Share on other sites More sharing options...
Duck986 Posted August 19, 2022 Share Posted August 19, 2022 7 hours ago, Insertnamehere2 said: Spawn skinned items without someone in the server needing to have them. (Not possible as I found out) I remember there was an actual chinese mod that allowed you to use any skins in existence even if you didn't own them. Sadly, it was later deleted or hidden. Link to comment Share on other sites More sharing options...
Boogiepop210 Posted August 19, 2022 Author Share Posted August 19, 2022 Oof 14 minutes ago, Duck986 said: I remember there was an actual chinese mod that allowed you to use any skins in existence even if you didn't own them. Sadly, it was later deleted or hidden. Link to comment Share on other sites More sharing options...
MikoFanboy Posted August 19, 2022 Share Posted August 19, 2022 3 hours ago, Duck986 said: I remember there was an actual chinese mod that allowed you to use any skins in existence even if you didn't own them. Sadly, it was later deleted or hidden. nah, the mod was about if someone has a skin, they will share it to everyone in the server, allow them to craft item with that skin, so you don't have to ask your friend to craft for you everytime tbh this could be a good feature since asking for friend to craft skined stuff can achieve the same thing but more inconvenient for both side -------- however I think the real problem with the mod is even when the person leave, the whole server still keep the "shared" skin Link to comment Share on other sites More sharing options...
Friendly Grass Posted August 19, 2022 Share Posted August 19, 2022 12 hours ago, Insertnamehere2 said: Use c_give with other players (prob obvious). The easiest way to do this is to c_select() them first and then call c_give. 13 hours ago, Insertnamehere2 said: Set other players speed (prob obvious). Same here you can c_select() them and run c_speedmult(4) 13 hours ago, Insertnamehere2 said: Spawn tools with increased durability/make existing items have more durrablity Remove durability entirely: c_select():RemoveComponent("finiteuses") 13 hours ago, Insertnamehere2 said: Make an circle of an prefab Something like this? First run this in Remote: function c_makecircle(prefab, count) count = count or 16 local r = 4 for theta = 0, PI2, PI2 / count do local inst = DebugSpawn(prefab) local x,y,z = inst.Transform:GetWorldPosition() inst.Transform:SetPosition(x + math.cos(theta) * r, y, z + math.sin(theta) * r) end end Then you and anyone running Remote can use the following format to create a circle of the prefab around your cursor. c_makecircle "berries" c_makecircle("wall_moonrock", 30) 13 hours ago, Insertnamehere2 said: Delete multiple objects around an certain radius. First run this in Remote: local REMOVE_CANT_TAGS={"CLASSIFIED", "player"} function c_removenearby(rad) local x,y,z = ConsoleWorldPosition():Get() local ents = TheSim:FindEntities(x,y,z, rad or 2, nil, REMOVE_CANT_TAGS) for k,v in pairs(ents) do v:Remove() end end Then you and anyone running Remote can use the following format to remove entities around your cursor: c_removenearby() --Specify remove radius in units (1/4 tiles) c_removenearby(4) Alright that's all, I don't have all day! Link to comment Share on other sites More sharing options...
Boogiepop210 Posted August 19, 2022 Author Share Posted August 19, 2022 2 hours ago, Friendly Grass said: The easiest way to do this is to c_select() them first and then call c_give. Same here you can c_select() them and run c_speedmult(4) Remove durability entirely: c_select():RemoveComponent("finiteuses") Something like this? First run this in Remote: function c_makecircle(prefab, count) count = count or 16 local r = 4 for theta = 0, PI2, PI2 / count do local inst = DebugSpawn(prefab) local x,y,z = inst.Transform:GetWorldPosition() inst.Transform:SetPosition(x + math.cos(theta) * r, y, z + math.sin(theta) * r) end end Then you and anyone running Remote can use the following format to create a circle of the prefab around your cursor. c_makecircle "berries" c_makecircle("wall_moonrock", 30) First run this in Remote: local REMOVE_CANT_TAGS={"CLASSIFIED", "player"} function c_removenearby(rad) local x,y,z = ConsoleWorldPosition():Get() local ents = TheSim:FindEntities(x,y,z, rad or 2, nil, REMOVE_CANT_TAGS) for k,v in pairs(ents) do v:Remove() end end Then you and anyone running Remote can use the following format to remove entities around your cursor: c_removenearby() --Specify remove radius in units (1/4 tiles) c_removenearby(4) Alright that's all, I don't have all day! Ty I'm guessing replace prefab would be similar then. Link to comment Share on other sites More sharing options...
hhh2 Posted August 19, 2022 Share Posted August 19, 2022 18 hours ago, Bumber64 said: Can't (legally) be done. Can I really be sent to prison or fined for not paying for don't starve skins? Link to comment Share on other sites More sharing options...
Dextops Posted August 19, 2022 Share Posted August 19, 2022 5 minutes ago, hhh2 said: Can I really be sent to prison or fined for not paying for don't starve skins? No, they'll send you to the electric chair right away. Link to comment Share on other sites More sharing options...
hhh2 Posted August 19, 2022 Share Posted August 19, 2022 Just now, Dextops said: No, they'll send you to the electric chair right away. The death penalty doesn't exist in my country. Link to comment Share on other sites More sharing options...
Dextops Posted August 19, 2022 Share Posted August 19, 2022 Just now, hhh2 said: The death penalty doesn't exist in my country. Stealing skins is the only exception. Link to comment Share on other sites More sharing options...
Mysterious box Posted August 19, 2022 Share Posted August 19, 2022 8 minutes ago, hhh2 said: Can I really be sent to prison or fined for not paying for don't starve skins? I mean depends if stealing is legal wherever you are. Link to comment Share on other sites More sharing options...
Bumber64 Posted August 19, 2022 Share Posted August 19, 2022 15 minutes ago, hhh2 said: The death penalty doesn't exist in my country. J1-M1 INBOUND. PREPARE FOR DRONE STRIKE, FLESHLING! Link to comment Share on other sites More sharing options...
Boogiepop210 Posted August 19, 2022 Author Share Posted August 19, 2022 I'm surprised this would turn from command talk to death penalty. Talk about this somewhere else. Also ty friendly grass the commands work perfectly and I didn't know you could make custom commands till now. Link to comment Share on other sites More sharing options...
hhh2 Posted August 19, 2022 Share Posted August 19, 2022 Here's one that makes a spiral function c_spiral(prefab,count,radius,loops) count = count or 16 radius = radius or 4 loops = loops or 3 local inst = SpawnPrefab(prefab) if inst == nil then return nil end local x,y,z = ThePlayer.Transform:GetWorldPosition() local step = PI2 / count inst.Transform:SetPosition( x + 0, y, z + radius ) for theta = 0, PI2 * loops + step, step do radius = radius + step inst = SpawnPrefab(prefab) inst.Transform:SetPosition( x + radius * math.sin(theta), y, z + radius * math.cos(theta) ) end end Like removing a component from an entity, you can add components to entities, too. Allow characters other than wicker to read books: ThePlayer:AddComponent("reader") Link to comment Share on other sites More sharing options...
Boogiepop210 Posted August 19, 2022 Author Share Posted August 19, 2022 1 hour ago, hhh2 said: Here's one that makes a spiral function c_spiral(prefab,count,radius,loops) count = count or 16 radius = radius or 4 loops = loops or 3 local inst = SpawnPrefab(prefab) if inst == nil then return nil end local x,y,z = ThePlayer.Transform:GetWorldPosition() local step = PI2 / count inst.Transform:SetPosition( x + 0, y, z + radius ) for theta = 0, PI2 * loops + step, step do radius = radius + step inst = SpawnPrefab(prefab) inst.Transform:SetPosition( x + radius * math.sin(theta), y, z + radius * math.cos(theta) ) end end Like removing a component from an entity, you can add components to entities, too. Allow characters other than wicker to read books: ThePlayer:AddComponent("reader") Wow funny think I already knew the spiral one as an non function but this seems even better 1 hour ago, hhh2 said: ThePlayer:AddComponent("reader") If I added remove instead of add I could stop grierfers Link to comment Share on other sites More sharing options...
hhh2 Posted August 20, 2022 Share Posted August 20, 2022 function c_replaceprefabs(prefab, radius, around, count) radius = radius or 4 around = around or ThePlayer local x,y,z = around.Transform:GetWorldPosition() local target_ents = TheSim:FindEntities(x,y,z, radius, count or nil, {"CLASSIFIED", "player"} ) for _,ent in pairs(target_ents) do local x,y,z = ent.Transform:GetWorldPosition() ent:Remove() SpawnPrefab(prefab).Transform:SetPosition(x,y,z) end end Link to comment Share on other sites More sharing options...
Boogiepop210 Posted August 20, 2022 Author Share Posted August 20, 2022 7 minutes ago, hhh2 said: function c_replaceprefabs(prefab, radius, around, count) radius = radius or 4 around = around or ThePlayer local x,y,z = around.Transform:GetWorldPosition() local target_ents = TheSim:FindEntities(x,y,z, radius, count or nil, {"CLASSIFIED", "player"} ) for _,ent in pairs(target_ents) do local x,y,z = ent.Transform:GetWorldPosition() ent:Remove() SpawnPrefab(prefab).Transform:SetPosition(x,y,z) end end Ty, I can't wait to try it. Link to comment Share on other sites More sharing options...
hhh2 Posted August 20, 2022 Share Posted August 20, 2022 6 hours ago, Insertnamehere2 said: Ty, I can't wait to try it. Oh, I should mention, this function also replaces items in players inventories too (That's why there was a meatball at Wicker's feet in the second image). Another check can be inserted at the beginning of the for-loop to skip past inventory items if this is undesirable: if t.components.inventoryitem and t.components.inventoryitem:IsHeld() then continue end Apply freeze effect to everything except the player. I haven't tested this one but it seems OK: function c_freeze(radius,thawtime) radius = radius or 12 local x,y,z = ThePlayer.Transform:GetWorldPosition() local targets = TheSim:FindEntities(x,y,z, radius,nil,nil) for _,t in pairs(targets) do if t.components.freezable and t ~= ThePlayer then t.components.freezable:Freeze(thawtime) end end end Link to comment Share on other sites More sharing options...
Boogiepop210 Posted August 20, 2022 Author Share Posted August 20, 2022 52 minutes ago, hhh2 said: Oh, I should mention, this function also replaces items in players inventories too (That's why there was a meatball at Wicker's feet in the second image). Another check can be inserted at the beginning of the for-loop to skip past inventory items if this is undesirable: I didn't have items in my inventory so I didn't know, this also seems to happen with the delete command too. 52 minutes ago, hhh2 said: function c_freeze(radius,thawtime) radius = radius or 4 x,y,z = ThePlayer.Transform:GetWorldPosition() targets = TheSim:FindEntities(x,y,z, radius,nil,nil) table.remove(targets, 1) -- First element will always be ThePlayer. for _,t in pairs(targets) do if t.components.freezable then t.components.freezable:Freeze(thawtime) end end end I'll try it tomorrow Edit: the replace command worked prefectly Link to comment Share on other sites More sharing options...
hhh2 Posted August 20, 2022 Share Posted August 20, 2022 Okay, last one for me. Here's a function that makes a sine wave: function c_sinewave(prefab, length, amplitude, resolution) if prefab == nil then return nil end amplitude = amplitude or 5 resolution = resolution or 0.25 length = length or 10 local x,y,z = ThePlayer.Transform:GetWorldPosition() for s = x - length / 2, x + length / 2, resolution do local lx,lz lx = s lz = z + amplitude * math.sin(s) SpawnPrefab(prefab).Transform:SetPosition(lx,y,lz) end end Link to comment Share on other sites More sharing options...
Boogiepop210 Posted August 20, 2022 Author Share Posted August 20, 2022 I found the play animation command so that's nice Link to comment Share on other sites More sharing options...
Boogiepop210 Posted August 21, 2022 Author Share Posted August 21, 2022 20 hours ago, hhh2 said: function c_freeze(radius,thawtime) radius = radius or 12 local x,y,z = ThePlayer.Transform:GetWorldPosition() local targets = TheSim:FindEntities(x,y,z, radius,nil,nil) for _,t in pairs(targets) do if t.components.freezable and t ~= ThePlayer then t.components.freezable:Freeze(thawtime) end end end Sadly it didn't work. imma find the freeze name so I can fix it Link to comment Share on other sites More sharing options...
hhh2 Posted August 21, 2022 Share Posted August 21, 2022 Just now, Insertnamehere2 said: Sadly it didn't work. imma find the freeze name so I can fix it Check my post. My mistakes are fixed. 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.