Jump to content

How to make a boomerang like item


Recommended Posts

I did put the boomerang code in the scripts .wand but all that did was make my inventor invisible i should note i deleted all the code in the wand.lua replaced it with the boomerang code and renamed everything to wand and WAND etc

Link to comment
Share on other sites

I'm not sure what you mean by "make my inventor invisible"

If it's invisible in your inventory, then there's an issue with the inventory image part.
If it's invisible when you throw it, then there's an issue with the animations.
If it makes your entire inventory disappear, then you've certainly done something very wrong.

Link to comment
Share on other sites

Yeah, the HUD does disappear, but the whole game also crashes. Looking at the log, we can see this is the error:

Spoiler

[00:10:00]: ...starve/data/../mods/clacker/scripts/prefabs/wand.lua:91: attempt to perform arithmetic on field 'WAND_DISTANCE' (a nil value)
LUA ERROR stack traceback:
E:/Gamez/SteamLibrary/steamapps/common/dont_starve/data/../mods/clacker/scripts/prefabs/wand.lua:91 in (field) fn (Lua) <74-118>
   Sim = Sim (1B5055D0)
   inst = 134622 -  (valid:true)
   trans = Transform (8F73CCB8)
   anim = AnimState (8F73CD18)
E:/Gamez/SteamLibrary/steamapps/common/dont_starve/data/scripts/mainfunctions.lua:137 in () ? (Lua) <126-161>
   name = wand
   prefab = Prefab wand - 
=[C]:-1 in (method) SpawnPrefab (C) <-1--1>
E:/Gamez/SteamLibrary/steamapps/common/dont_starve/data/scripts/mainfunctions.lua:178 in (global) SpawnPrefab (Lua) <172-210>
   name = wand
E:/Gamez/SteamLibrary/steamapps/common/dont_starve/data/scripts/util.lua:51 in (global) DebugSpawn (Lua) <48-58>
   prefab = wand
E:/Gamez/SteamLibrary/steamapps/common/dont_starve/data/scripts/consolecommands.lua:20 in (global) c_spawn (Lua) <16-26>
   prefab = wand
   count = 1
   inst = nil
   i = 1
c_spawn("wand"):1 in () ? (main) <0-0>
=[C]:-1 in (global) pcall (C) <-1--1>
E:/Gamez/SteamLibrary/steamapps/common/dont_starve/data/scripts/screens/consolescreen.lua:45 in (global) ExecuteConsoleCommand (Lua) <39-50>
   fnstr = c_spawn("wand")
E:/Gamez/SteamLibrary/steamapps/common/dont_starve/data/scripts/screens/consolescreen.lua:319 in (method) Run (Lua) <314-320>
   self =
      edit_bg = Image - images/ui.xml:textbox_long_over.tex
      suggest_replace = 
      shown = true
      autocompleteObjName = 
      autocompleteOffset = -1
      inst = 134602 -  (valid:true)
      focus = true
      handlers = table: 12C0AA20
      children = table: 12C0A408
      enabled = true
      focus_target = false
      root = 
      suggest_text = table: 12C0D450
      parent = screenroot
      name = ConsoleScreen
      suggesting = false
      focus_flow = table: 12C0A890
      focus_flow_args = table: 12C0A8B8
      console_edit = Text - 
      callbacks = table: 12C0A688
   fnstr = c_spawn("wand")
E:/Gamez/SteamLibrary/steamapps/common/dont_starve/data/scripts/screens/consolescreen.lua:409 in (method) OnTextEntered (Lua) <408-415>
   self =
      edit_bg = Image - images/ui.xml:textbox_long_over.tex
      suggest_replace = 
      shown = true
      autocompleteObjName = 
      autocompleteOffset = -1
      inst = 134602 -  (valid:true)
      focus = true
      handlers = table: 12C0AA20
      children = table: 12C0A408
      enabled = true
      focus_target = false
      root = 
      suggest_text = table: 12C0D450
      parent = screenroot
      name = ConsoleScreen
      suggesting = false
      focus_flow = table: 12C0A890
      focus_flow_args = table: 12C0A8B8
      console_edit = Text - 
      callbacks = table: 12C0A688
E:/Gamez/SteamLibrary/steamapps/common/dont_starve/data/scripts/screens/consolescreen.lua:471 in (field) OnTextEntered (Lua) <471-471>

[00:10:00]: Last called Lua: SpawnPrefabFromSim
[00:10:00]: scripts/mainfunctions.lua(946,1) LUA ERROR stack traceback:
        E:/Gamez/SteamLibrary/steamapps/common/dont_starve/data/scripts/mainfunctions.lua(946,1)
        =[C] in function 'SpawnPrefab'
        E:/Gamez/SteamLibrary/steamapps/common/dont_starve/data/scripts/mainfunctions.lua(178,1) in function 'SpawnPrefab'
        E:/Gamez/SteamLibrary/steamapps/common/dont_starve/data/scripts/util.lua(51,1) in function 'DebugSpawn'
        E:/Gamez/SteamLibrary/steamapps/common/dont_starve/data/scripts/consolecommands.lua(20,1) in function 'c_spawn'
        c_spawn("wand")(1,1) in main chunk
        =[C] in function 'pcall'
        E:/Gamez/SteamLibrary/steamapps/common/dont_starve/data/scripts/screens/consolescreen.lua(45,1) in function 'ExecuteConsoleCommand'
        E:/Gamez/SteamLibrary/steamapps/common/dont_starve/data/scripts/screens/consolescreen.lua(319,1) in function 'Run'
        E:/Gamez/SteamLibrary/steamapps/common/dont_starve/data/scripts/screens/consolescreen.lua(409,1) in function 'OnTextEntered'
        E:/Gamez/SteamLibrary/steamapps/common/dont_starve/data/scripts/screens/consolescreen.lua(471,1) in function 'OnTextEntered'
        E:/Gamez/SteamLibrary/steamapps/common/dont_starve/data/scripts/widgets/textedit.lua(59,1) in function 'OnProcess'
        E:/Gamez/SteamLibrary/steamapps/common/dont_starve/data/scripts/widgets/textedit.lua(70,1) in function 'OnRawKey'
        E:/Gamez/SteamLibrary/steamapps/common/dont_starve/data/scripts/widgets/widget.lua(94,1) in function 'OnRawKey'
        E:/Gamez/SteamLibrary/steamapps/common/dont_starve/data/scripts/widgets/widget.lua(94,1) in function 'OnRawKey'
        E:/Gamez/SteamLibrary/steamapps/common/dont_starve/data/scripts/widgets/widget.lua(94,1) in function 'OnRawKey'
        E:/Gamez/SteamLibrary/steamapps/common/dont_starve/data/scripts/screens/consolescreen.lua(121,1) in function 'OnRawKey'
        E:/Gamez/SteamLibrary/steamapps/common/dont_starve/data/scripts/frontend.lua(755,1) in function 'OnRawKey'
        E:/Gamez/SteamLibrary/steamapps/common/dont_starve/data/scripts/frontend.lua(122,1) in function 'fn'
        E:/Gamez/SteamLibrary/steamapps/common/dont_starve/data/scripts/events.lua(46,1) in function 'HandleEvent'
        E:/Gamez/SteamLibrary/steamapps/common/dont_starve/data/scripts/input.lua(186,1) in function 'OnRawKey'
        E:/Gamez/SteamLibrary/steamapps/common/dont_starve/data/scripts/input.lua(403,1)	
[00:10:00]: scripts/mainfunctions.lua(947,1) ...starve/data/../mods/clacker/scripts/prefabs/wand.lua:91: attempt to perform arithmetic on field 'WAND_DISTANCE' (a nil value)
LUA ERROR stack traceback:
    E:/Gamez/SteamLibrary/steamapps/common/dont_starve/data/../mods/clacker/scripts/prefabs/wand.lua:91 in (field) fn (Lua) <74-118>
    E:/Gamez/SteamLibrary/steamapps/common/dont_starve/data/scripts/mainfunctions.lua:137 in () ? (Lua) <126-161>
    =[C]:-1 in (method) SpawnPrefab (C) <-1--1>
    E:/Gamez/SteamLibrary/steamapps/common/dont_starve/data/scripts/mainfunctions.lua:178 in (global) SpawnPrefab (Lua) <172-210>
    E:/Gamez/SteamLibrary/steamapps/common/dont_starve/data/scripts/util.lua:51 in (global) DebugSpawn (Lua) <48-58>
    E:/Gamez/SteamLibrary/steamapps/common/dont_starve/data/scripts/consolecommands.lua:20 in (global) c_spawn (Lua) <16-26>
    c_spawn("wand"):1 in () ? (main) <0-0>
    =[C]:-1 in (global) pcall (C) <-1--1>
    E:/Gamez/SteamLibrary/steamapps/common/dont_starve/data/scripts/screens/consolescreen.lua:45 in (global) ExecuteConsoleCommand (Lua) <39-50>
    E:/Gamez/SteamLibrary/steamapps/common/dont_starve/data/scripts/screens/consolescreen.lua:319 in (method) Run (Lua) <314-320>
    E:/Gamez/SteamLibrary/steamapps/common/dont_starve/data/scripts/screens/consolescreen.lua:409 in (method) OnTextEntered (Lua) <408-415>
    E:/Gamez/SteamLibrary/steamapps/common/dont_starve/data/scripts/screens/consolescreen.lua:471 in (field) OnTextEntered (Lua) <471-471>

 

The first line says that on line 91 in wand.lua, you are using a variable called WAND_DISTANCE, which is apparently nil, in a calculation. See my newcomer post for more great information about how to debug your mods.

Also, your modinfo.lua says that the mod is DST compatible, which it is not.

Link to comment
Share on other sites

3 hours ago, noobyt4 said:

Removed the dst compatible

Great :)

3 hours ago, noobyt4 said:

could you just tell me what code i need to put im not the best at following tutorials if you can't then il just follow the guide

You need to know LUA if you're going to make a mod. Making a projectile weapon isn't simple, let alone one that can return to the caster. Your current error says that you're using an undeclared variable. If your don't know what to do about that, then we're going to spend way too much time going back and forth, or I'm going to end up writing the whole mod (which I do not have time for, but others might).

I'm sure you can do it if you put in some more time. You might find it more fun than you think :)

 

Link to comment
Share on other sites

14 minutes ago, noobyt4 said:

Also turns out the problem was lines 90,95,964 didn't have a number so i guess that was "simple"

What i was talking about

    inst.components.weapon:SetDamage(30)

    inst.components.finiteuses:SetMaxUses(50)
    inst.components.finiteuses:SetUses(50)

Link to comment
Share on other sites

7 hours ago, noobyt4 said:

the only problem i have is the images dont appear do you want the script or whole file?

Whole mod in a zip. Which images do not appear? There are many different images for an item mod. Is the inventory image missing? Or is it the image on the ground? Also, it seems you don't have any modicon files, or you haven't changed the filenames in your modinfo.lua

Link to comment
Share on other sites

Well, first of all, your inventory image folder is not names correctly: wand\images\inventoryimages_2

It should just be inventoryimages.

You never add the inventory image or atlas to your inventoryitem component. You also do not properly include them in the "assets" list at the top of the prefab file. Please see this example mod Cactus Armor - DST.zip. It's for DST, so don't mind the extra stuff. Just look at the "assets" list and line 55 in the armor_cactus.lua.

Are you also going to add a recipe for this wand? If so, I can shared the code for that, as well.

Link to comment
Share on other sites

1 hour ago, Ultroman said:

Are you also going to add a recipe for this wand? If so, I can shared the code for that, as well.

Yes i am if you could share the code please do

1 hour ago, Ultroman said:

Well, first of all, your inventory image folder is not names correctly: wand\images\inventoryimages_2

i did update the file but i guess you got the old file

either way il try and fix it il update you

Link to comment
Share on other sites

Waiting for the updated file, then.

Recipe code:

-- Recipe has the following parameters:
-- Recipe(name, ingredients, tab, level, game_type, placer, min_spacing, nounlock, numtogive, aquatic, distance, decor, flipable, image, wallitem, alt_ingredients)
-- If your image is named the same as the prefab, then you do not need to set the image manually.
-- We only set the first 4 parameters, and then ignore the rest completely.
local armor_cactus = Recipe("armor_cactus", { Ingredient("armorwood", 1), Ingredient("cactus_meat", 12)}, RECIPETABS.WAR, {SCIENCE = 1})

-- If your image is not named the same as the prefab, then you need to specify the image.
-- We only set the first 4 parameters and the image parameter, and then ignore the last 2 completely.
local armor_cactus = Recipe("armor_cactus", { Ingredient("armorwood", 1), Ingredient("cactus_meat", 12)}, RECIPETABS.WAR, {SCIENCE = 1}, nil, nil, nil, nil, nil, nil, nil, nil, nil, "armor_cactus")

-- If your atlas is also named differently, then you have to set the atlas after calling Recipe, like this:
armor_cactus.atlas = "images/inventoryimages/armor_cactus.xml"

 

Link to comment
Share on other sites

I see the folder name was changed, but you don't seem to have done this part:

Quote

You never add the inventory image or atlas to your inventoryitem component. You also do not properly include them in the "assets" list at the top of the prefab file. Please see this example mod Cactus Armor - DST.zip. It's for DST, so don't mind the extra stuff. Just look at the "assets" list and line 55 in the armor_cactus.lua

 

Link to comment
Share on other sites

It's really simple. Download my zip file and look at armor_cactus.lua in the "scripts\prefabs" folder. Look at the "assets" list at the top of the file and look at line 55. You have the "anim" parts of your "assets" list, but the INV_IMAGE part is wrong. See how it should look like in my file. Keep in mind what the folder structure is, understand that all you're supposed to do is provide file paths for the game to the files you have, and then look at the parts I mentioned. It should pop out at you. Line 55 is almost the same thing. Just copy the lines from my mod, and make sure to change the path to have your file names in them.

I'll do it for you if you really can't get it to work, but I think you're dumbing yourself down a little or don't feel too confident in doing this. That'll never get better if you don't work at it ;) If that's too forward, I do apologize. I just like to push people just a little bit.

Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

Please be aware that the content of this thread may be outdated and no longer applicable.

×
  • Create New...