Sign in to follow this  
Joachim

[Problem] AddLocation doesn't work?

Recommended Posts

Joachim    351

Dear fellow modders (and perhaps the Klei developers if they are reading this),

I have been into modding for a few weeks now. I am learning something new every day and feeling more confident each time. I have been into creating new thematic worlds. Adding new rooms, tasks, tasksets, levels, prefabs, etc. I managed to add something new every time. The world I am working on right now involves a lot of snow.

While studying the code, I noticed that I could have even more control over my world by creating my own location for it by using AddLocation. I called this location forest_snow. I simply copied the code from the forest location and see what I could do with it. I noticed that each location had its own associated prefab, which is generated based on the name of the location. So I created a prefab accordingly and called it forest_snow. Since my mod is made for DST, I noticed I also had to create a network prefab for it, so I created a forest_snow_network prefab as well. All code has been copied from forest and forest_network respectively. To make the distinction between this location and the other locations, I added a world temperature to the snow forest with a temperature modifier of 0.1, thus making it very cold. I mainly used this for testing, so that I would get cold in autumn on day 1, I would know the location works correctly.

However, the location did not appear in the UI. At first, I thought there was simply no support for it in the interface, so I decided to test it on my dedicated server instead. On my dedicated server, I got this error, almost as if it wasn't loaded at all:

 

[00:00:04]:#######
#
# Generating SURVIVAL Mode Level
#
#######
    
[00:00:04]: DoLuaFile Error: #[string "scripts/map/level.lua"]:103: bad argument #1 to 'pairs' (table expected, got nil)
#LUA ERROR stack traceback:
@=[C]:-1 in (global) pairs (C) <-1--1>
@scripts/map/level.lua:103 in (method) ChooseTasks (Lua) <86-145>
   self =
      min_playlist_position = 0
      max_playlist_position = 999
      id = SURVIVAL_TOGETHER
      required_prefabs = table: 0xe8533af8
      version = 2
      hideminimap = false
      override_level_string = false
      numrandom_set_pieces = 5
      name = Default
      substitutes = table: 0xe76c43c8
      location = forest
      random_set_pieces = table: 0xe8534298
      desc = The standard Don't Starve experience.
      overrides = table: 0xe76c4bd8
   taskdefinitions = nil
   tasklist = table: 0xe76e0f78
   task_set = snowy
   task_set_data = nil
   modfns = table: 0xe76e0fe8
@scripts/worldgen_main.lua:327 in () ? (Lua) <315-426>
   debug = false
   world_gen_data = table: 0xe85319b8
   level = table: 0xe76e0a78
@=(tail call):-1 in ()  (tail) <-1--1>
@=(tail call):-1 in ()  (tail) <-1--1>
[00:00:04]: #[string "scripts/map/level.lua"]:103: bad argument #1 to 'pairs' (table expected, got nil)
#LUA ERROR stack traceback:
@=[C]:-1 in (global) pairs (C) <-1--1>
@scripts/map/level.lua:103 in (method) ChooseTasks (Lua) <86-145>
   self =
      min_playlist_position = 0
      max_playlist_position = 999
      id = SURVIVAL_TOGETHER
      required_prefabs = table: 0xe8533af8
      version = 2
      hideminimap = false
      override_level_string = false
      numrandom_set_pieces = 5
      name = Default
      substitutes = table: 0xe76c43c8
      location = forest
      random_set_pieces = table: 0xe8534298
      desc = The standard Don't Starve experience.
      overrides = table: 0xe76c4bd8
   taskdefinitions = nil
   tasklist = table: 0xe76e0f78
   task_set = snowy
   task_set_data = nil
   modfns = table: 0xe76e0fe8
@scripts/worldgen_main.lua:327 in () ? (Lua) <315-426>
   debug = false
   world_gen_data = table: 0xe85319b8
   level = table: 0xe76e0a78
@=(tail call):-1 in ()  (tail) <-1--1>
@=(tail call):-1 in ()  (tail) <-1--1>
[00:00:04]: Error loading worldgen_main.lua
[00:00:04]: WorldSim::SimThread::Main() ERROR
[00:00:04]: WorldSim::SimThread::Main() complete
[00:00:04]: Worldgen had an error, displaying...    
[00:00:04]: #[string "scripts/map/level.lua"]:103: bad argument #1 to 'pairs' (table expected, got nil)

#[string "scripts/map/level.lua"]:103: bad argument #1 to 'pairs' (table expected, got nil)


#LUA ERROR stack traceback:
@=[C]:-1 in (global) pairs (C) <-1--1>
@scripts/map/level.lua:103 in (method) ChooseTasks (Lua) <86-145>
   self =
      min_playlist_position = 0
      max_playlist_position = 999
      id = SURVIVAL_TOGETHER
      required_prefabs = table: 0xe8533af8
      version = 2
      hideminimap = false
      override_level_string = false
      numrandom_set_pieces = 5
      name = Default
      substitutes = table: 0xe76c43c8
      location = forest
      random_set_pieces = table: 0xe8534298
      desc = The standard Don't Starve experience.
      overrides = table: 0xe76c4bd8
   taskdefinitions = nil
   tasklist = table: 0xe76e0f78
   task_set = snowy
   task_set_data = nil
   modfns = table: 0xe76e0fe8
@scripts/worldgen_main.lua:327 in () ? (Lua) <315-426>
   debug = false
   world_gen_data = table: 0xe85319b8
   level = table: 0xe76e0a78
@=(tail call):-1 in ()  (tail) <-1--1>
@=(tail call):-1 in ()  (tail) <-1--1>    

Note that this is all working if I replace forest_snow by forest!

I have even been looking at the Up and Away mod to see what they did to solve the problem, but as far as I can see, they are not adding their location to the game (even though it has been defined). It almost seems as if AddLocation itself is not working (why else would they define but not use it?). If this is true, this would be bad news...

P.S. I made sure that everything was imported. I checked the PrefabFiles, I checked the modworlddgenmain to make sure that everything was loaded in the correct order. I cannot see any mistake there.

What I mainly want to know: is AddLocation supported at all? Can I even hope to get this to work?

Apparently: yes. But... (see below)

Edited by Joachim

Share this post


Link to post
Share on other sites
Joachim    351

Never mind the previous error. I got it to work after all. I feel so stupid. It turns out I forgot to enable the correct mod. >_>

However, now a different issue appeared for the client side. If the client attempts to view the world settings in the lobby, it crashes the game for them. This is highly undesirable. Any way to fix this?

[00:05:21]: [string "scripts/map/customise.lua"]:313: attempt to index local 'locationdata' (a nil value)


LUA ERROR stack traceback:
scripts/map/customise.lua:313 in (field) GetOptionsWithLocationDefaults (Lua) <308-319>
   location = forest_snow
   is_master_world = true
   options = table: 0x11ebd278
   locationdata = nil
   i = 1
   option = table: 0xb8e0e20
scripts/screens/viewcustomizationmodalscreen.lua:131 in (method) Refresh (Lua) <129-167>
   self =
      callbacks = table: 0xde5c288
      clickroot = clickroot
      inst = 101398 -  (valid:true)
      focus = false
      button = OK
      children = table: 0xbc6f8f8
      focus_flow_args = table: 0xc4d70e8
      focus_target = false
      leveldata = table: 0xdb7a890
      currentmultilevel = 1
      multileveltabs = multileveltabs
      can_fade_alpha = true
      optionspanelbg = NineSlice
      enabled = true
      name = ViewCustomizationModalScreen
      optionspanel = optionspanel
      focus_flow = table: 0xb5fa2b8
      black = Image - images/global.xml:square.tex
      shown = true
      root = root
   location = forest_snow
scripts/screens/viewcustomizationmodalscreen.lua:94 in (field) _ctor (Lua) <20-107>
   self =
      callbacks = table: 0xde5c288
      clickroot = clickroot
      inst = 101398 -  (valid:true)
      focus = false
      button = OK
      children = table: 0xbc6f8f8
      focus_flow_args = table: 0xc4d70e8
      focus_target = false
      leveldata = table: 0xdb7a890
      currentmultilevel = 1
      multileveltabs = multileveltabs
      can_fade_alpha = true
      optionspanelbg = NineSlice
      enabled = true
      name = ViewCustomizationModalScreen
      optionspanel = optionspanel
      focus_flow = table: 0xb5fa2b8
      black = Image - images/global.xml:square.tex
      shown = true
      root = root
   leveldata = table: 0xd96e348
scripts/class.lua:181 in (upvalue) ViewCustomizationModalScreen (Lua) <171-184>
   class_tbl = table: 0xfa1e298
   arg = nil
   obj = ViewCustomizationModalScreen
scripts/screens/serverlistingscreen.lua:465 in (method) ViewServerWorld (Lua) <462-467>
   self =
      viewtags_button = BUTTON
      view_offset = 0
      servers = table: 0xb988ae8
      intentions_overlay = IntentionPicker
      join_button = Join
      column_buttons = table: 0xd5482d0
      details_button = Server Details
      fg = foreground
      bg = background
      enabled = true
      cancel_button = Back
      root = scaleroot
      checkbox_has_password = detail_icon
      sort_ascending = true
      filters_scroll_list = ScrollBar
      title = Text - Cooperative Servers
      focus_flow = table: 0xe530fb0
      details_servername = Text - [TESTING] Multi-World 
Server ALPHA
      filters_shown = false
      day_description = daydesc
      list_widgets = table: 0xc666cf8
      default_focus = Online
      callbacks = table: 0xcba6de0
      DETAILS = control
      nav_bar = nav_bar
      inst = 100227 -  (valid:true)
      cb = function - scripts/screens/multiplayermainscreen.lua:435
      PLAYERS = control
      focus_target = false
      lan_button = LAN
      refresh_button = BUTTON
      can_fade_alpha = true
      checkbox_pvp = detail_icon
      prev_screen = MultiplayerMainScreen
      tickperiod = 0.5
      checkbox_dedicated_server = detail_icon
      online_button = Online
      shown = true
      server_intention = nil
      viewworld_button = BUTTON
      table = table container
      has_password_description = Text - Password Protected
      filters = table: 0xecd2f70
      onlinestatus = OnlineStatus
      server_list_background = Image - images/options_bg.xml:options_panel_bg.tex
      PING = control
      viewmods_button = BUTTON
      name = ServerListingScreen
      parent = screenroot
      last_server_click_time = 38.766668688506
      task = PERIODIC 100227: 0.500000
      filters_button = Filters
      view_online = true
      season_description = seasondesc
      server_count = Text - (1107 of 1993 shown)
      queryTokens = table: 0xb413ad8
      sessions = table: 0xecd2f98
      searchbox = searchb
[00:05:21]: [string "scripts/map/customise.lua"]:313: attempt to index local 'locationdata' (a nil value)
LUA ERROR stack traceback:
    scripts/map/customise.lua:313 in (field) GetOptionsWithLocationDefaults (Lua) <308-319>
    scripts/screens/viewcustomizationmodalscreen.lua:131 in (method) Refresh (Lua) <129-167>
    scripts/screens/viewcustomizationmodalscreen.lua:94 in (field) _ctor (Lua) <20-107>
    scripts/class.lua:181 in (upvalue) ViewCustomizationModalScreen (Lua) <171-184>
    scripts/screens/serverlistingscreen.lua:465 in (method) ViewServerWorld (Lua) <462-467>
    scripts/screens/serverlistingscreen.lua:1957 in (field) onclick (Lua) <1957-1957>
    scripts/widgets/imagebutton.lua:163 in (method) OnControl (Lua) <126-169>
    scripts/widgets/widget.lua:116 in (method) OnControl (Lua) <110-124>
    scripts/widgets/widget.lua:116 in (method) OnControl (Lua) <110-124>
    scripts/widgets/widget.lua:116 in (method) OnControl (Lua) <110-124>
    scripts/widgets/widget.lua:116 in (method) OnControl (Lua) <110-124>
    scripts/widgets/widget.lua:116 in (field) OnControl (Lua) <110-124>
    scripts/screens/serverlistingscreen.lua:2207 in (method) OnControl (Lua) <2206-2242>
    scripts/frontend.lua:322 in (method) OnControl (Lua) <308-364>
    scripts/input.lua:142 in (method) OnControl (Lua) <139-146>
    scripts/input.lua:318 in () ? (Lua) <317-319>
    
[00:05:21]: CURL ERROR: <url> malformed

Share this post


Link to post
Share on other sites

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this