• Announcements

    • JoeW
    • JanH

      Rhymes with Play 148 - Oxygen Not Included Art Stream!   07/20/2017

      Join Oxygen Not Included artists Alex and Erica this Thursday, July 20th at 3:30 PM Pacific (10:30 PM UTC) where they will be showing off how your favourite dupes are drawn, as well as creating a summer-themed ONI illustration, only on the Rhymes with Play Dev Cast on Twitch. Where is it?
      On our official Twitch channel here:
      http://www.twitch.tv/kleientertainment
       
      When is it?
      Twitch Stream Date: July 20th, 2017 

      10:30 PM UTC (Coordinated Universal Time)
      6:30 PM ET (East)
      5:30 PM CT (Central)
      4:30 PM MT (Mountain) Here's a handy tool to figure out what time that means for you. Check out the stream announce thread for discussions!

ZupaleX

Registered Users
  • Content count

    365
  • Joined

  • Last visited

Everything posted by ZupaleX

  1. Sorry for the double post but I decided that it deserve another post instead of a third edit. Please find attached a working skeleton for a custom action not using an object and performed when pressing the space bar. You'll have to adapt it to your needs and keep it mind it will probably not work well with a gamepad (if you want to make it compatible with using a gamepad you would need to override the function corresponding to the gamepad button the same way I override the space bar in my proof of principle). This can go directly in your modmain.lua if you want to test it out. Cheers
  2. If it is not linked to a item but to the player locomotor and playeractionpicker component. It is not so trivial anymore but doable. @SuperDavid: so I looked a bit more into it because it's not something I've really done before (I worked with custom actions but always linked to an item). This will be in playeractionpicker.lua and playercontroller.lua You have in playeractionpicker.lua a function which is called each "tick" (each time the game refresh everything) to sort through the possible actions and pick the one which has the highest priority. You need to insert your action in the table which is sorted, and give it a priority which is high enough that it ends up being the first one. PICKUP action has priority 1 so anything above will be executed first. PICK doesn't have a priority specified so in this case it will be 0. (from actions.lua) Then you have in playercontroller.lua the function which is executed when you left click This will execute the action which has been tagged aas having the highest priority. BUT: you want to perform your action when you press the space bar, which is the "ActionButton". This is again a different story but the same principle. This time everything happens in playercontroller.lua When you press the space bar, this is executed: This function uses its own action picker which is the following This last function is the one you need to modify to have your jump action returned in priority. I will try to write a simple example which demonstrates how it would work.
  3. So you have several types of predefined Component Actions: SCENE: clicking on something on the screen while not having any active item USEITEM: clicking on something else on the surounding area with an object "in hand" (active item, appearing under your cursor) POINT: same as USEITEM but clicking on anywhere on the screen (like when you use the blinkstaff) EQUIPPED: if the item is equipped INVENTORY: right clicking it in your inventory Each of these types apply in specific situations when you want to use an item. AddComponentAction takes several arguments. The first one is which type of action you want to deal with and must belong to the list above. Second argument is which component you want to attach this new action. Third is a function saying which specific action you want to have as a choice and under which circumstances. Try to read again that part in my modmain and see if it makes more sense. Now you want to be able to jump while you use a special item or it's just that your character is supposed to be able to jump by default?
  4. I will write an expanation about this function soon.
  5. That's the tricky part Look at AddComponentAction
  6. That's better. You now have an action and you say what to do when this action is performed. You now need to say WHEN you can perform it
  7. Not quite, you need to define the action before adding it. Look at the items GLOBAL.Action(...)
  8. in the modmain.lua, look for the word "action" (remove the case sensitivity to find all the occurences). It is also not really well organized, sorry.
  9. The issue that you have is that you need to define your jump as an action so the game can actually prioritize them. You can find example on how to do that in various mods. Again, I am not advertising my mod, but you can see a working example in my "Archery Mod" on the workshop, which add several custom actions. You can find other mods doing it but I don't know them. It has not been updated in a while though so it is using a deprecated function to add ACTION but it is still working and the new way is almost exactly the same (save for one line). If you decide to take a look into the code and have questions let me know. If you would rather get help step by step to do it without an example, I guess we can work something out as well, it will just take more time probably.
  10. What do you do with this function? When is it called? Could you link your complete modmain.lua>
  11. You prioritize your actions so it should not happens that both are executed at the same time. Where do you implement that new action and How?
  12. For the force attack you might find what you want in playercontroller component. For the second point I am not sure I understand.
  13. Maybe add a counter on your object and a ListenForEvent which catch when a new day begin and increase that counter. Then if the counter == 10, regrow and counter = 0. EDIT: it won't be a ListenForEvent but something similar. function EntityScript:WatchWorldState(var, fn) EntityWatchWorldState(self, var, fn) TheWorld.components.worldstate:AddWatcher(var, self, fn, self) end In your prefab init function you could add inst:WatchWorldState("isday", OnNewDayFn)
  14. You need to override the playeractionpicker.
  15. OK, I just had time to look at what you posted. So dont do that in general: inst.components.container.onclosefn = function() inst.components.inventoryitem.cangoincontainer = true end This function takes an argument, even though here technically it doesn't matter so much it is a good idea to not take bad habits inst.components.container.onclosefn = function(inst_) inst_.components.inventoryitem.cangoincontainer = true end Then for your problem, what happens is that you set the InventoryItem.onputininventoryfn which is called inside InventoryItem:OnPutInInventory(owner) which is called by a container when it receives an object in Container:GiveItem(item, slot, src_pos, drop_on_fail) So your function will be called and DropItem will be executed, spawning the item and removing it from the container. But right after that, the GiveItem function continues its execution and the next line is self.inst:PushEvent("itemget", { slot = in_slot, item = item, src_pos = src_pos }) which triggers a function in the replica.container self._onitemget = function(inst, data) self.classified:SetSlotItem(data.slot, data.item, data.src_pos) if self.issidewidget and inst.components.inventoryitem.owner ~= nil and inst.components.inventoryitem.owner.HUD ~= nil then inst.components.inventoryitem.owner:PushEvent("refreshcrafting") end end self.classified:SetSlotItem(data.slot, data.item, data.src_pos) will set the item in the container to the item you just dropped and effectively duplicating the item. BTW: I am almost certain that your code currently, even fixed to account for the issues I pointed out, will only work for the host. The client is not receiving the necessary information in the way it is written right now.
  16. I will take a look at the snippet you posted but I just wanted to state something: The name of the variable doesn't matter. You could call it player if you want even though it has nothing to do with the player (That would just be confusing). That's why I asked for more details.
  17. Hi, could you post more info? Like the function where you call this, etc?
  18. Keep in mind though that adding the beaver tag will make your character trigger anything which checks for the beaver tag even stuffs you might not want.
  19. Ok, I thought it was adding it only to the registered prefab when your mod was itself registered. Thanks for the info.
  20. RPC don't accept any type of data. It would print in the client "Invalid RPC data type" if it doesn't like it. Table cannot be passed for instance. It can take basic variable types like number, book, strings, and a few userdata from Klei. I don't have the exact list. Glad you solved your issue.
  21. Yeah ok. For me "creating a new symbol" is adding something to the animation, so it seemed like a lot of work Well then I guess there is not much more you can do.
  22. Ok let's be more precise from SGWilson.lua Note how you have 2 section in the timeline. One if the actor has a "iswoodcutter", and one if not. You will notice that the timeline for the actor with "woodcutter" is much faster (after 2, 5 and 10 FRAMES something happens) than the non "woodcutter" (after 2, 9 and 14 FRAMES). Also the animation played depends on that "woodcutter". If the actor has it, it plays woodie_chop_loop otherwise it plays chop_loop. The thing is that if you want to mine faster as well or do other stuffs faster you probably don't want to redo all the animations in a faster version. I think I remember a function from the AnimState userdata which was accelerating the playback but I am not 100% positive. EDIT: I checked out quickly the metatable for AnimState You might try the FastForward? EDIT2: I did a quick in game test. You can use SetDeltaTimeMultiplier(factor) to increase or decrease the speed of an animation. You could set that multiplier to your factor upon entering the state ("chop", "mine", etc...) and reset it back to 1 when exiting the state. Practically it would be inst.AnimState:SetDeltaTimeMultiplier(2) -- to make it twice faster [... do your stuffs ...] inst.AnimState:SetDeltaTimeMultiplier(1) -- to set it back to default value
  23. You should instead go take a look inside SGwilson.lua, you will find there the details for the action CHOP
  24. But this symbol won't be present in all the base animations then. And if it's not there you cannot override it. Or maybe I just missed how you implement it.
  25. Well then a good start would be to look at woodie and his CHOP action