rezecib Posted March 8, 2015 Share Posted March 8, 2015 @Zheng, Well... this is a little bit tricky without having a player as a reference point. But you can find the closest entity of a particular prefab, for example by using the first player as a reference point. Once you've found it, you can move it with the Transform:c_find("flower", nil, AllPlayers[1]).Transform:SetPosition(x, y, z)You could use the location of another entity directly, but note that this will bypass collision, so they will actually stack right on top of each other:c_find("flower", nil, AllPlayers[1]).Transform:SetPosition(c_find("hound"):GetPosition():Get()) Link to comment Share on other sites More sharing options...
Zheng Posted March 9, 2015 Share Posted March 9, 2015 @Zheng, Well... this is a little bit tricky without having a player as a reference point. But you can find the closest entity of a particular prefab, for example by using the first player as a reference point. Once you've found it, you can move it with the Transform:c_find("flower", nil, AllPlayers[1]).Transform:SetPosition(x, y, z)You could use the location of another entity directly, but note that this will bypass collision, so they will actually stack right on top of each other:c_find("flower", nil, AllPlayers[1]).Transform:SetPosition(c_find("hound"):GetPosition():Get())This one is really good , mind also telling me just how to move 1 player to another player's location Link to comment Share on other sites More sharing options...
DarkXero Posted March 9, 2015 Share Posted March 9, 2015 AllPlayers[x].Transform:SetPosition(AllPlayers[y].Transform:GetPosition():Get()) Link to comment Share on other sites More sharing options...
absimiliard Posted March 10, 2015 Author Share Posted March 10, 2015 I can't believe it took me this long to figure out how to give something to someone via the console..... *eye-roll* c_select(AllPlayers[X]) c_give(prefab) yah, really, that simple. I can't believe all the skeeziness I tried that didn't work, and the solution is THAT simple. *sigh* Nice to finally have figured out though. It's a needed step on the path to console wizardry. Link to comment Share on other sites More sharing options...
Jisook Posted March 11, 2015 Share Posted March 11, 2015 Looks like there's a lot more commands that are currently non existent on the wiki. This thread helped me very much. Link to comment Share on other sites More sharing options...
Jisook Posted March 11, 2015 Share Posted March 11, 2015 AllPlayers[x].Transform:SetPosition(AllPlayers[y].Transform:GetPosition():Get())I can't seem to edit my other post some reason, but this command here doesn't seem to teleport me or the listed player to the other player. It appears to take 5 posts to obtain an edit button. I figured out the issue, gotta remove the .Transform after [y]. Link to comment Share on other sites More sharing options...
rezecib Posted March 11, 2015 Share Posted March 11, 2015 @Jisook, He made a mistake, :GetPosition() exists on the entity object, while GetWorldPosition() exists on the Transform component. So it should be:AllPlayers[x].Transform:SetPosition(AllPlayers[y]:GetPosition():Get()) Link to comment Share on other sites More sharing options...
Jisook Posted March 11, 2015 Share Posted March 11, 2015 @Jisook, He made a mistake, :GetPosition() exists on the entity object, while GetWorldPosition() exists on the Transform component. So it should be:AllPlayers[x].Transform:SetPosition(AllPlayers[y]:GetPosition():Get())Yeah I noticed that and put it in my edit, but now I have a question, is it possible to spawn something via dedicated server? Probably can if I find coordinates right? But say I'm monitoring everything via the CMD prompt, how would I manage to find such coordinates and place it in game without launching the game? Link to comment Share on other sites More sharing options...
rezecib Posted March 11, 2015 Share Posted March 11, 2015 @Jisook, About the best you can do is find something, get its coordinates, and then give it coordinates somewhere near that. For example:print(c_find("wilson"):GetPosition())==> (234, 0, 468)c_spawn("researchlab2").Transform:SetPosition(235,0,469) Link to comment Share on other sites More sharing options...
Jisook Posted March 12, 2015 Share Posted March 12, 2015 Alright, last question in a long while. Is it possible to give ALL players online an item? I've tried doing for k,v in pairs(AllPlayers) and c_select(AllPlayers) c_give but doing the second one causes the game to not be able to spawn any items again until reset(true) I've done for k,v in pairs(AllPlayers) do c_give("prefab") endAnd that one doesn't work, so I figured I'd tryc_select(AllPlayers) c_give("prefab")but the second one here breaks all spawns/giving after since the original is AllPlayers[x] and I would have to c_reset(true) EDIT: Rephrasing because it seemed very sloppy lol In regards to players joining such asTheWorld:ListenForEvent("ms_playerjoined", function() c_announce("msg") end)can that also be applied to TheWorld:ListenForEvent("ms_playerjoined", function() c_give("prefab") end)EDIT2:TheWorld:ListenForEvent("ms_playerjoined", function() DebugSpawn("krampus_sack").Transform:SetPosition(-168, 0, 472) end)Would work, but is there a way to target the specific person joining once and not abuse it without modding? Because even if I targeted someone, they could simply leave and rejoin and obtain it again. Link to comment Share on other sites More sharing options...
rezecib Posted March 12, 2015 Share Posted March 12, 2015 @Jisook, Should be this (don't know why yours is breaking spawning, though, it should just fail due to syntax error):for k,v in pairs(AllPlayers) do c_select(v) c_give("dragonpie") end Link to comment Share on other sites More sharing options...
absimiliard Posted March 12, 2015 Author Share Posted March 12, 2015 @rezecib: So I was testing out spawning things and transforming their positions. Can you explain to me why this is failing? ConsoleInput: "c_spawn("campfire").Transform:SetPosition(1,1,1)"[13:41:01]: [string "scripts/mainfunctions.lua"]:365: attempt to index upvalue 'debug_entity' (a number value) I'm not seeing anything substantially different from your example with the researchlab (which for me fails the same way) and looking mainfunctions.lua leads me to the debug_entity instantiation which is a bit deep in the weeds for my knowledge base. So I'm hoping that if you can explain it to me speaking very slowly that I'll then be closer to understanding the explanation and learn some new thing. (because I fear this is beyond my level of hackery) Link to comment Share on other sites More sharing options...
DarkXero Posted March 12, 2015 Share Posted March 12, 2015 Try:DebugSpawn("campfire").Transform:SetPosition(1, 1, 1) Link to comment Share on other sites More sharing options...
absimiliard Posted March 12, 2015 Author Share Posted March 12, 2015 Fascinating, that worked, yes. Thanks DarkXero. I can't find any references to DebugSpawn outside of consolecommands.lua, which just uses it. Is it defined in a file anywhere that I can examine? (or, if not, does anyone know the syntax for using it?) Link to comment Share on other sites More sharing options...
DarkXero Posted March 12, 2015 Share Posted March 12, 2015 c_spawn, DebugSpawn and SpawnPrefab are global functions.c_spawn makes use of DebugSpawn, which is in util.lua, which makes use of SpawnPrefab, which is in mainfunctions.lua. And we can't reach TheSim. So I imagine that what basically happens is "yo, I want to make a new entity. Sure pal, let me mark you get a new entity here, and here's your id for it, go nuts". Link to comment Share on other sites More sharing options...
absimiliard Posted March 12, 2015 Author Share Posted March 12, 2015 *-abs can't believe he missed that the last result of his grep was util.lua* Thanks again, sometimes I need a "Hey, yo, ding-a-ling, look at your output again, you're missing something." Link to comment Share on other sites More sharing options...
rezecib Posted March 12, 2015 Share Posted March 12, 2015 @absimiliard, Find-in-files is your friend . It's in scripts/util.lua. Edit: Oops, weird... I don't remember all the other posts being there x_xfunction DebugSpawn(prefab) if TheSim and TheInput then TheSim:LoadPrefabs({prefab}) local inst = SpawnPrefab(prefab) if inst then SuUsed("c_spawn_" .. prefab , true) inst.Transform:SetPosition(TheInput:GetWorldPosition():Get()) return inst end endendAlthough this looks like you could actually just use SpawnPrefab directly to get rid of a bunch of unnecessary code being run. Link to comment Share on other sites More sharing options...
Jisook Posted March 15, 2015 Share Posted March 15, 2015 @rezecib Couple last questions since I'm still very old fashioned when I do things and don't rely on mod tools; just manually. 1. In regards to players joining such asTheWorld:ListenForEvent("ms_playerjoined", function() c_announce("msg") end)can that also be applied to TheWorld:ListenForEvent("ms_playerjoined", function() print(c_find("multiplayer_portal"):GetPosition())TheWorld:ListenForEvent("ms_playerjoined", function() DebugSpawn("krampus_sack").Transform:SetPosition(x, z, y) end) Would work, but is there a way to target the specific person joining once and not abuse it without modding? Because even if I targeted someone, they could simply leave and rejoin and obtain it again. 2. How would I remove a prefab in the command prompt, without the use of in game mouse? By finding coordinates again? Like say I set up a boxed arena of obelisks but everyone is separated into their own little boxes and I want them to organize their inventories to how they like it and then let loose all hell. Thanks. Link to comment Share on other sites More sharing options...
rezecib Posted March 15, 2015 Share Posted March 15, 2015 Would work, but is there a way to target the specific person joining once and not abuse it without modding? Because even if I targeted someone, they could simply leave and rejoin and obtain it again. I think you can do this (I'm using PeterA's The Hunt mod as a reference):TheWorld:ListenForEvent("ms_playerspawn", function(src, player) local OldOnNewSpawn = player.OnNewSpawn local items = {"krampus_sack","spear"} player.OnNewSpawn = function() for k,v in pairs(items) do player.components.inventory:GiveItem(SpawnPrefab(v)) end end end, TheWorld) ... that is kind of verbose, though, it really would be easier to make it a super simple mod, or at least add it to your consolecommands.lua (probably good idea to make a backup somewhere because updates to consolecommands will overwrite it). 2. How would I remove a prefab in the command prompt, without the use of in game mouse? By finding coordinates again? This is very difficult. If you're also creating them with console commands, then the easiest thing to do would be to store the references to them as you create them, for example:my_arena_obelisks = {}for ... do table.insert(obelisks, SpawnPrefab("sanityrock")) my_arena_obelisks[#my_arena_obelisks].Transform:SetPosition(...)end That way, later you can do this:for k,v in pairs(my_arena_obelisks) do v:Remove() end Link to comment Share on other sites More sharing options...
KageHiroki Posted June 7, 2015 Share Posted June 7, 2015 I know that this thread is old and all but when I try to do the c_speed(value) it doesn't work anymore, it only says that c_speed is not declared, when it worked perfectly fine before this update. Anybody have an updated command for it? Link to comment Share on other sites More sharing options...
poopmaster189 Posted June 13, 2015 Share Posted June 13, 2015 I know that this thread is old and all but when I try to do the c_speed(value) it doesn't work anymore, it only says that c_speed is not declared, when it worked perfectly fine before this update. Anybody have an updated command for it?c_speedmult(0.2,"me") Link to comment Share on other sites More sharing options...
KageHiroki Posted June 13, 2015 Share Posted June 13, 2015 c_speedmult(0.2,"me") Thanks so much! 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.