danielpa

  • Content count

    15
  • Joined

  • Last visited

Community Reputation

4 Neutral

About danielpa

  • Rank
    Junior Member

Recent Profile Visitors

123 profile views
  1. Yeah that solve it , thanks a lot @Serpens. How do I mark a (forum) thread as solved?
  2. I've seen some mods use the `Sleep` function, but when I try to use it in the modmain.lua file I get an error: modmain.lua: function main() AddPlayerPostInit( function() GLOBAL.TheInput:AddKeyDownHandler( string.byte("z", 1), function() print("BEFORE") Sleep(10) print("AFTER") end ) end ) end main() Error: [00:16:44]: [string "../mods/lib/modmain.lua"]:9: attempt to call global 'Sleep' (a nil value) LUA ERROR stack traceback: ../mods/lib/modmain.lua:9 in (field) fn (Lua) <7-11> scripts/events.lua:46 in (method) HandleEvent (Lua) <42-49> scripts/input.lua:187 in (method) OnRawKey (Lua) <184-191> scripts/input.lua:396 in () ? (Lua) <395-397> EDIT: using GLOBAL.Sleep: [00:02:53]: attempt to yield across metamethod/C-call boundary LUA ERROR stack traceback: =[C]:-1 in (field) yield (C) <-1--1> scripts/scheduler.lua:339 in (field) Sleep (Lua) <336-343> ../mods/lib/modmain.lua:6 in (field) fn (Lua) <4-8> scripts/events.lua:46 in (method) HandleEvent (Lua) <42-49> scripts/input.lua:187 in (method) OnRawKey (Lua) <184-191> scripts/input.lua:396 in () ? (Lua) <395-397>
  3. I already do this, look at the end of the function. I use it in my mod to select the best tool for the job, I need not only the usage percent but also the armor reduction, weapon damage and others. I infer other values from the usage percent as well https://github.com/danielpza/dst-omnikey/blob/master/src/modmain.ts#L176-L185 The thing I did similar to Item Info is creating a prefab to cache it's components, I don't need/use/calculate other values like Item Info does
  4. This is my latest revision on the code: local prefabCache function getPrefabCopy(prefab) if prefabCache[prefab] == nil then local isMasterSim = GLOBAL.TheWorld.ismastersim GLOBAL.TheWorld.ismastersim = true local copy = GLOBAL.SpawnPrefab(prefab) local cache = {prefab = prefab, components = {}} if copy.components.finiteuses then local ____ = copy.components.finiteuses local current = ____.current local total = ____.total local consumption = ____.consumption cache.components.finiteuses = {current = current, total = total, consumption = consumption} end if copy.components.tool then local ____ = copy.components.tool local actions = ____.actions cache.components.tool = {actions = actions} end if copy.components.weapon then local ____ = copy.components.weapon local damage = ____.damage cache.components.weapon = {damage = damage} end if copy.components.armor then local ____ = copy.components.armor local absorb_percent = ____.absorb_percent local condition = ____.condition local maxcondition = ____.maxcondition cache.components.armor = {absorb_percent = absorb_percent, condition = condition, maxcondition = maxcondition} end if copy.components.healer then local ____ = copy.components.healer local health = ____.health cache.components.healer = {health = health} end if copy.components.edible then local ____ = copy.components.edible local healthvalue = ____.healthvalue local hungervalue = ____.hungervalue local sanityvalue = ____.sanityvalue local ismeat = ____.ismeat local foodtype = ____.foodtype cache.components.edible = {healthvalue = healthvalue, hungervalue = hungervalue, sanityvalue = sanityvalue, ismeat = ismeat, foodtype = foodtype} end copy:Remove() GLOBAL.TheWorld.ismastersim = isMasterSim prefabCache[prefab] = cache end return prefabCache[prefab] end
  5. Is there a way to make the created prefab "invisible", maybe move it very fay way in the world?
  6. How can I do this (get a component property) with RPC? do you have any examples of it besides https://forums.kleientertainment.com/forums/topic/47353-guide-getting-started-with-modding-dst-and-some-general-tips-for-ds-as-well/
  7. yes, you must remove the items, the original mods just cache the variables it needs and then destroys it.
  8. I found a workaround in other mod (Item Info), it doesn't seem the best way, but it works for me: local prefabCache function getPrefabCopy(prefab) if prefabCache[prefab] == nil then local isMasterSim = GLOBAL.TheWorld.ismastersim GLOBAL.TheWorld.ismastersim = true prefabCache[prefab] = GLOBAL.SpawnPrefab(prefab) GLOBAL.TheWorld.ismastersim = isMasterSim end return prefabCache[prefab] end -- then use getPrefabCopy("axe").components
  9. I've read the starting guides to modding and some explications for the replica and classifieds, but still haven't found a way to make it work: local healthvalue = item.components.edible && item.components.edible.healthvalue It worked when playing alone in my server, but if I'm playing multiplayer or in a game with caves it doesn't work.
  10. Version 0.4.0

    17 downloads

    OmniKey A Don't Starve Together Mod. Add keybindings to use with tools, weapons, armor and much more. Usage Keybindings can be changed in the configuration: Default Key Function G Equip best weapon by damage C Equip best armor V Equip best helmet 1 Equip best axe 2 Equip best pickaxe 3 Equip best shovel 4 Equip best scythe, requires scythes mod H Use best healing item J Eat food Also when unequiping the hand slot using the keybindings it automatically equips a cane if available Installing Download latest release from github
  11. This is my first mod, I'm not sure if it's supposed to be announced here, but here you go: EDIT: https://github.com/danielpza/dst-omnikey OmniKey A Don't Starve Together Mod. Add keybindings to use with tools, weapons, armor and much more. Usage Keybindings can be changed in the configuration: Default Key Function G Equip best weapon by damage C Equip best armor V Equip best helmet 1 Equip best axe 2 Equip best pickaxe 3 Equip best shovel H Use best healing item J Eat food Also when unequiping the hand slot using the keybindings it automatically equips a cane if available Installing Download latest release from github Made in typescript, transpiled to lua. Inspired by Fast Equipment.
  12. Anyway, here is a little improvement on the code, in case someone finds it useful function generateKeys(result, from, to) local s = string.byte(from, 1) local e = string.byte(to, 1) do local i = s while i <= e do local key = string.char(i) result[#result + 1] = {description = key, data = key} i = i + 1 end end end string = "" local keys = {} generateKeys(keys, "0", "9") generateKeys(keys, "a", "z")
  13. Like the selector don't starve provides for changing his keybindings, like attack, rotate etc...
  14. I see a lot of mods generate a list of keys when they want to add a keybinding like so: local FIRST_NUMBER = 48 local FIRST_LETTER = 65 for i = 1, 10 do local ch = string.char(FIRST_NUMBER + i - 1) keyslist[i] = {description = ch, data = ch} end for i = 11, 36 do local ch = string.char(FIRST_LETTER + i - 11) keyslist[i] = {description = ch, data = ch} end Is there a better way to assign a keybinding for your mod?