Grimtongue Posted July 29, 2014 Share Posted July 29, 2014 BufferedAction(self, doer, target, action, invobject, pos, recipe, distance)Alright, so most of those arguments are self-explanatory. In the brains of creatures that pick stuff up or eat things, the function is typically called like this:BufferedAction(inst,target,ACTIONS.PICKUP)However, what do I do when I have no target? I tried writing this short mod to test placing a grass tuft when the game starts, but nothing happens. No error code, no console output - just nothing at all.SpawnPrefab = GLOBAL.SpawnPrefabBufferedAction = GLOBAL.BufferedActionfunction SimInit(player) local invobject = "dug_grass" local prefab = SpawnPrefab(invobject) local playerposition = player:GetPosition() player.components.inventory:GiveItem(prefab) BufferedAction(player, player, GLOBAL.ACTIONS.DEPLOY, invobject, playerposition)endAddSimPostInit(SimInit) Link to comment Share on other sites More sharing options...
plaidman Posted July 30, 2014 Share Posted July 30, 2014 It looks like your code isn't actually doing anything with the BufferedAction, it's just creating the object and ending. You need to save your BufferedAction object to a variable (local action = BufferedAction...), then call a function on your BufferedAction (action:Do()). That'll probably give a good error to go off of.I suspect your 'player' that you're using for the target might not go over too well. I think it might be looking for a ground tile.Edit: I was wrong. Player as the target is fine, since the DEPLOY action is only concerned with the 'pos' and 'doer' arguments. You could use anything for target, in theory, probably even nil.However, it doesn't like the invobject argument, since that's a string, and that argument is looking for an already-created prefab object. I tried it with 'prefab' and it seems to be working. Here's my code: SpawnPrefab = GLOBAL.SpawnPrefabBufferedAction = GLOBAL.BufferedAction function SimInit(player) local invobject = "dug_grass" local prefab = SpawnPrefab(invobject) local playerposition = player:GetPosition() player.components.inventory:GiveItem(prefab) local action = BufferedAction(player, player, GLOBAL.ACTIONS.DEPLOY, prefab, playerposition) action:Do()end AddSimPostInit(SimInit) Link to comment Share on other sites More sharing options...
Grimtongue Posted July 30, 2014 Author Share Posted July 30, 2014 Thank you so much! I've been trying to figure this out for a while now. I've been working on a mod to that builds nice long rows of stuff (grass, walls, saplings, trees, etc), but I was stuck on how to make the player actually deploy stuff. 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.