• Content Count

  • Joined

  • Last visited

 Content Type 




Klei Bug Tracker

Game Updates

Hot Lava Bug Reporter

Posts posted by Blueberrys

  1. the one I wrote I tried to "optimize space"

    You can't just cut out parts of the code to optimise space xD It has to make sense too.


    works perfectly in DS, but if I put the same code in DST...

    I see. First of all, fix the if statement. Either write them all out correctly, or use one of the shorter methods I suggested.


    The builditem event is still being used in DST through the builder component.

    The armor component still has a operational SetPercent function.

    I think the issue may be related to the networking aspect. Perhaps the code isn't executing because it's not running on the host. I suggest you post on the DST mod forums. Include your full code, logs, etc.

  2. what variable should I use to identify the item?

    You mean prefab name? Not sure what you're looking for, but that if statement won't work how you think.

    if data.item.prefab == "armorwood" or "armormarble" ...

    Means "if the name is 'armorwood', OR if 'armormarble exists..."


    Should be:

    if data.item.prefab == "armorwood" or data.item.prefab == "armormarble" ...



    if data.item.prefab:sub(1, 5) == "armor" ...

    for everything starting with "armor"




    More code.

    -- ending in hatif data.item.prefab:sub(-3) == "hat" ...-- containing armorif data.item.prefab:find("armor", 1, true) ...-- containing hatif data.item.prefab:find("hat", 1, true) ...
    • Like 1

  3. @jimmosio See Mobbstar's solution above.


    Also.. where is armor_inst coming from? Are you doing something like "armor_inst = data.item"? If what you provided here is all you have in your event function, it should probably crash with "attempt to index armor_inst a nil value". Considering that isn't happening, there may be another issue.

    Testing the event myself to confirm.


    Edit: data.item contains the prefab name, not the instance of the item. armor_inst still needs to come from somewhere though.


    Edit 2: Nope, actually it is the instance. You would need to use data.item.prefab to check if you've got the right item. Testing to confirm.


    Edit 3: Works.

    inst:ListenForEvent("builditem", function(inst, data)	if (data.item.prefab == "armorwood") then		data.item.components.armor:SetPercent(1.35)	endend)
    • Like 1

  4. @jimmosio Use the hungerdelta event, it updates whenever the hunger value is changed.

    local function check_light(inst, data)	if GetClock():IsNight() and inst.components.hunger.current > 104 then		-- if light off, enable light	else		-- if light on, disable light	endendinst:ListenForEvent("hungerdelta", check_light)-- To ensure it's working even if the hunger doesn't change at night/dayinst:ListenForEvent("nighttime", check_light)inst:ListenForEvent("daytime", check_light)



    Not sure what approach you want to take on that, but here's how you can change the durability.

    -- 135% of original durabilityarmor_inst.components.armor:SetPercent(1.35)

    You can do it upon crafting with:

    inst:ListenForEvent("builditem", function(inst, data)	if data.item.prefab == "armor_prefab" then		-- ...	endend)

    Edit: Fixed data.item.prefab. (see below)

    • Like 1

  5. Dumb question, but is this all about my mod or another issue?

     It's about your mod, but not the issue you mentioned. Corrosive found something else in your mod and we started talking about that, but he edited the original post now.


    I've thought about what you stated, and it's probably a lot more stable and efficient to store all of the ongoing effects in Profile, if only I would build up the courage and free time to mess with those systems. Maybe tomorrow

    Er, again, have you tried using that module? xD It's fairly straight forward, should only take you about 5 minutes to figure it out. Or are you talking about the second issue, too?


    Also, on a scale from 1 to 10, how aching is the fact that I construct a new class for every effect on every instance? (stacks act as one instance, so it's suprisingly tame so far)

    That doesn't sound right.. I think I'll have a look at your code. >->

    If 1 is "unconcerned" and 10 is "Noo whyyyyyyyy" then probably 9.

  6. @Corrosive Thank you for pointing that out. It persuaded me to research more on how upvalues work.

    if anyone else is interested, here's a long explanation which I found quite helpful.


    As for SpawnPrefab, wouldn't the reference to the upvalue be stored within the function's own scope? What do you mean by "longer than the original context of SpawnPrefab", is it being changed or removed anywhere?


    Edit: Just saw your edit. You probably should've left the original post too so people know what you're referring to, haha.

  7. @Mobbstar Have you seen/tried this?

    Nevermind, ignore that!


    Edit: No wait, don't ignore that. Why exactly is that crossed out? Did it not work?


    Edit 2: If you were referring to that as the former alternative (as opposed to the OnSave things mentioned previously in the thread) then.. I can't say how it will be affected performance wise, but it just seems to make more sense than having an empty prefab that doesn't do anything else in the game.

    If you don't want to make a new file for your data, you can even use one of the existing files. Just be sure to check which keys are empty.

  8. I believe there is already a project on this (here), but it does not look like much (any?) progress was made.

    The progress is slow, but definitely has been on-going. There are currently 80+ completed pages (including many components with descriptions, methods, etc).


    @Pymous I definitely think it is a good idea and would be helpful, but you might wanna check out the other site first. You seem to be trying to accomplish the same task, documenting the API. You can post on the thread if you have any questions, concerns, ideas, etc.

  9. @silktie That is correct. Components are added to the components table in the player's instance (which is also a table).

    player_inst = GLOBAL.GetPlayer()-- You can also write it like this:player_inst.components.example



    The AddComponent function is located in entityscript.lua

    function EntityScript:AddComponent(name)    if self.components[name] then        print("component "" already exists!")    end    local cmp = LoadComponent(name)    assert(cmp, "component ".. name .. " does not exist!")        local loadedcmp = cmp(self)    self.components[name] = loadedcmp    local postinitfns = ModManager:GetPostInitFns("ComponentPostInit", name)    for k,fn in ipairs(postinitfns) do        fn(loadedcmp,self)    endend

  10. Hehe.. Be nice to the new kid, he'll learn eventually.

    Also, I don't think that new members with a low post count have edit permissions.


    @NyerxD We can't help you much without a log file. Please attach it to your next post (click more options below).

    If you look through the forums, you'll probably find solutions to most of these small issues easily, as they are mentioned frequently.


    Next time, just say whatever mistake you made instead of quoting the whole thing. For example,


    Hi my name is Bop.


    Sorry, I meant "Bob"*


    It's much easier to read and understand this way, and doesn't look spammy.


    Also, we can read your post just fine without the massive fonts. In fact, it's more distracting than anything.