Good catch. Can I apply it to myself? FYI, the only place I see lightLevel being called is in assets/monsters/sensors.lua
lightLevel, windLevel, tempLevel, and breathable all accept a 2d vector as arguments. The following code gives this result: local light = world.lightLevel({0,0}) local wind = world.windLevel({0,0}) local temp = world.temperature({0,0}) local breathe = world.breathable({0,0}) 0 0 25 true Now I just need to find out how to read your own vector position.
Also, have a look in assets\npcs\main.lua, line 364: playerIds = world.playerQuery(entity.position(), self.noticePlayersRadius, { inSightOf = entity.id() }) Might be able to grab your playerId this way.
I tried local position = entity.position() but the position constantly changed even as I stood still. But local light = world.lightLevel({position[1],position[2]}) changed the light level as it moved.
Success! I think I've found my playerId, and also my position. My code: local playerIds = world.playerQuery(entity.position(), 100000) pos = world.entityPosition(playerIds[1]) local light = world.lightLevel({pos[1], pos[2]}) print(playerIds[1], pos[1], pos[2]) print("Light = ", light) returns: -65536, 0, 1255.5 Light = 0.5 (approx) As I move around, x and y change! And as I dig a pit, the light goes down!!! Now if I were in a server with multiple people, I couldn't guarantee the person would be me. Single player would be easy though.
Also, world.spawnItem("torch", pos) works! edit: an unlit torch for picking up, that is. edit2: every time a torch spawns, everything around you pauses but you can move freely.
Hey nice work. I was trying to find a clean way of getting a reference to players but couldn't find anything.
Forgot to mention that all you need is this: local playerIds = world.playerQuery({0,0}, 100000) That'll give you every playerId in the server. Not sure if 100000 is too big (or too small on certain planets), but I set it high just in case. My next mission is to find out how to spawn a lit torch attached to the wall. From there, I'm going to make a tech that automatically lights a torch when it's dark.
I don't think we can access spawnItem, it's listed in severedskullz API doc, but he says it's not part of the world object. I wonder if you can make projectiles glow though? You can spawn projectiles. Maybe you can make a projectile with no velocity that emits light. The tech could drop one every few seconds, and the projectile lifespan would be around the same time. If we could access the projectile itself and move it around, you wouldn't need to spawn new ones, but I don't think we can right now.
I have though. world.spawnItem("platinumpickaxe", pos) game me about 30 pickaxes before I turned it off. Do you know the IRC channel where the devs are? I might politely ask if they know how to activate an item.
Try it yourself. Put this code in groundMonster.lua local playerIds = world.playerQuery({0,0}, 100000) pos = world.entityPosition(playerIds[1]) local light = world.lightLevel({pos[1], pos[2]}) print(playerIds[1], pos[1], pos[2]) print("Light = ", light) world.spawnItem("platinumpickaxe", pos) I bet spawnItem has a 3rd optional argument, one of them being active!
No need to get snarky. One, you didn't post the actual code you used. This guy did, so props to him. Second, it's easy to miss posts when there are so many new things being discovered all the time. We should be respectful of each other and appreciate the effort they put into trying to communicate their findings, otherwise people will just not post to avoid sarcasm just in case their post is slightly redundant.
I made a couple small improvements to the basic script. I'm a Lua newbie; hadn't touched it until a couple days ago while making my Chicken Gun. Code: print("**** DUMPING object TABLE ****"); a = {} count = 1 for n in pairs(object) do table.insert(a, n) end table.sort(a) for i,n in ipairs(a) do count = count + 1 print(n) end print("**** END object TABLE DUMP " .. count .. " ENTRIES ****") It sorts the table. It counts the entries. It doesn't print the addresses. I don't know any use for them yet, so for me they are superfluous. Counting the entries gives us a quick method for establishing any major changes after a patch.
Also, the arguments for spawnItem( name, position, count, level) level is a table, like { level = 1, definition = crappyhammer} dunno what other options there are for 4th arg. I'm no expert but wouldn't it be considered an object if it is placed? Idk how spawnItem would be able to do that. EDIT: I was able to make it spawn randomly generated guns, spawnItem is fun! Code: world.spawnItem("generatedgun", object.toAbsolutePosition({ 0.0, 6.0 }), 1, { level = 5} ) I use it with my edited decoyprincess.
I've been tempted to go into a random server and just dump super powerful stuff on people, then pull out my 100x100 copper pickaxe and destroy the landscape.
Is this implementable in an object (but with random levels)? Such as the money capsules for example. At the moment I can spawn random gen guns from breakable objects without a script, but they must spawn with a fixed level.
You seriously bumped this topic with a completely unrelated question? Set the player's position to desired position on each update.