Cyde042 Posted August 7, 2015 Share Posted August 7, 2015 I have no idea why it won't work. It's asking for a GLOBAL.MakeLoot but that doesn't make sense (I tried it and it still didn't work, it was looking for the variable). local function New_OnGetItemFromPlayer(inst, giver, item) if inst.components.sleeper:IsAsleep() then inst.components.sleeper:WakeUp() end if item:HasTag("sunken_boat_special") then --Spawn some special item, say some special string. local str, loot = item:GiveCluefn() inst.components.talker.colour = GLOBAL.Vector3(1 ,0.5, 0.5) inst.components.talker:Say(str) giftprefab = loot delay = TUNING.TOTAL_DAY_TIME * 4.75 fly_off_time = 6 else local str = SquawkScript(STRINGS.SUNKEN_BOAT_ACCEPT_TRADE[math.random(#STRINGS.SUNKEN_BOAT_ACCEPT_TRADE)]) inst.components.talker.colour = GLOBAL.Vector3(1 ,1, 1) inst.components.talker:Say(str) delay = TUNING.TOTAL_DAY_TIME * 0.75 end if item.components.tradable.goldvalue > 0 then for k = 1, item.components.tradable.goldvalue do local item = nil print(num_trades) MakeLoot(inst) --This one here, it creates the items that will drop from trader dropitem(inst) num_trades = num_trades - 1 print(num_trades) CanLeave(inst) end endAnd here is the function that creates the table.local function MakeLoot(inst) local possible_loot = { {chance = 20, item = "rope"}, {chance = 30, item = "seeds"}, {chance = 5, item = "purplegem"}, {chance = 5, item = "bluegem"}, {chance = 5, item = "redgem"}, {chance = 2, item = "orangegem"}, {chance = 2, item = "yellowgem"}, {chance = 2, item = "greengem"}, {chance = 30, item = "seeds"}, {chance = 33, item = "feather_robin"}, {chance = 5, item = "beardhair", "beardhair"}, {chance = 5, item = "blueprint"}, {chance = 30, item = "goldnugget"}, } local totalchance = 0 for m, n in ipairs(possible_loot) do totalchance = totalchance + n.chance end inst.loot = {} local next_loot = nil local next_chance = nil local num_loots = 2 while num_loots > 0 do next_chance = math.random()*totalchance next_loot = nil for m, n in ipairs(possible_loot) do next_chance = next_chance - n.chance if next_chance <= 0 then next_loot = n.item break end end if next_loot ~= nil then table.insert(inst.loot, next_loot) num_loots = num_loots - 1 end endendI feel like I'm missing something really small. Link to comment https://forums.kleientertainment.com/forums/topic/56866-mod-doesnt-read-local-function/ Share on other sites More sharing options...
Mobbstar Posted August 7, 2015 Share Posted August 7, 2015 (edited) Can I safely assume you put them in the right order? *looking into it* EDIT: You have "seeds" twice and "beardhair" contains a redundant copy of the string. Edited August 7, 2015 by Mobbstar Link to comment https://forums.kleientertainment.com/forums/topic/56866-mod-doesnt-read-local-function/#findComment-660862 Share on other sites More sharing options...
Cyde042 Posted August 7, 2015 Author Share Posted August 7, 2015 (edited) Can I safely assume you put them in the right order? *looking into it* EDIT: You have "seeds" twice and "beardhair" contains a redundant copy of the string. What do you mean by right order? The functions are written down in the shown order NewGetItem then Make Loot. Unrelated question but, do you happen to know how to add to componentactions.lua? Edited August 7, 2015 by Cyde042 Link to comment https://forums.kleientertainment.com/forums/topic/56866-mod-doesnt-read-local-function/#findComment-660892 Share on other sites More sharing options...
Mobbstar Posted August 7, 2015 Share Posted August 7, 2015 What do you mean by right order? The functions are written down in the shown order NewGetItem then Make Loot. Unrelated question but, do you happen to know how to add to componentactions.lua? What do you mean by what do I mean by right order? You're calling a function that has not been constructed yet. That's like feeding a child that hasn't been born into the world yet: it doesn't work. And what is componentactions.lua? I never heard of that before, and I never really studied DST code, let alone modded for it. Link to comment https://forums.kleientertainment.com/forums/topic/56866-mod-doesnt-read-local-function/#findComment-660920 Share on other sites More sharing options...
Cyde042 Posted August 7, 2015 Author Share Posted August 7, 2015 What do you mean by what do I mean by right order? You're calling a function that has not been constructed yet. That's like feeding a child that hasn't been born into the world yet: it doesn't work. And what is componentactions.lua? I never heard of that before, and I never really studied DST code, let alone modded for it.Oh wow. I understood, I forgot about this, for some reason I thought it would just scan through the file and search for the function. I changed order and it worked. Componentactions is in the scripts folder, it's in base game too. It assigns actions to prefabs that have a specific component. I know there is a snowball mod so I'll take a look at that later since I need a throw action. Thanks! Link to comment https://forums.kleientertainment.com/forums/topic/56866-mod-doesnt-read-local-function/#findComment-660932 Share on other sites More sharing options...
Mobbstar Posted August 8, 2015 Share Posted August 8, 2015 Oh wow. I understood, I forgot about this, for some reason I thought it would just scan through the file and search for the function. I changed order and it worked. Componentactions is in the scripts folder, it's in base game too. It assigns actions to prefabs that have a specific component. I know there is a snowball mod so I'll take a look at that later since I need a throw action. Thanks! It's not in the base game on my screen, component actions get created in actions.lua in the basegame. And they only get created, not assigned (for instance "dryer" also uses the harvestable action).I think the snowball mod uses the existing projectile weapon type, or at least that's what I used in similiar context in the [CLASSIFIED] mod. Good luck! Link to comment https://forums.kleientertainment.com/forums/topic/56866-mod-doesnt-read-local-function/#findComment-661116 Share on other sites More sharing options...
Cyde042 Posted August 8, 2015 Author Share Posted August 8, 2015 It's not in the base game on my screen, component actions get created in actions.lua in the basegame. And they only get created, not assigned (for instance "dryer" also uses the harvestable action).I think the snowball mod uses the existing projectile weapon type, or at least that's what I used in similiar context in the [CLASSIFIED] mod. Good luck! Yea, it was in DST, not the base game. But got that figured out already, just need to add separate Collect"type"Actions in a component. Can you take a look at the progress so far? For now it's messy since I copied some of the changed components just to see if it works but it doesn't. I added everything that has to do with the waterballoon except the fx splash. The issue seems to be with the action. 1Water Baloons.zip Link to comment https://forums.kleientertainment.com/forums/topic/56866-mod-doesnt-read-local-function/#findComment-661180 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