Grimtongue Posted July 29, 2014 Share Posted July 29, 2014 (edited) 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) Edited July 29, 2014 by Grimtongue Link to comment https://forums.kleientertainment.com/forums/topic/39050-help-trying-to-understand-bufferedaction/ Share on other sites More sharing options...
plaidman Posted July 30, 2014 Share Posted July 30, 2014 (edited) 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) Edited July 30, 2014 by plaidman Link to comment https://forums.kleientertainment.com/forums/topic/39050-help-trying-to-understand-bufferedaction/#findComment-517937 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 https://forums.kleientertainment.com/forums/topic/39050-help-trying-to-understand-bufferedaction/#findComment-518040 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