• Content count

  • Joined

  • Last visited

Community Reputation

30 Excellent

About BakaSchwarz

  • Rank
    Junior Member

Recent Profile Visitors

764 profile views
  1. Sounds like the most optimal solution. I'm all for it!
  2. Multi-Character Interactions

    Ah, okay. In that case you may want to look at playercontroller.lua. You could add your code to the OnLeftClick function like so: AddClassPostConstruct("components/playercontroller", function(self) local oldleftclickfn = self.OnLeftClick self.OnLeftClick = function(self, down) -- Your code here oldleftclickfn(self, down) end end) In your code you check that the currently played character is your character. Get yourself the ThePlayer variable and check its prefab. Does this go in the direction you intended? I am not sure the playercontroller is networked as is though. Never needed to do stuff with it. Maybe someone else can say more about this.
  3. Learning to mod.

    Yeah, seems like a typo. What really grinds my gears is that you always need to restart the whole game when something crashes. A debug mode would be awesome...
  4. Multi-Character Interactions

    With target object, do you mean something like a staff? Not sure i understand your main problem. Could you rephrase?
  5. Learning to mod.

    I wish you the best of luck and don't give up! You can do it if you try long enough. A lot of DST modding (and programming in general) is trying over and over again and debugging errors. It can be frustrating, but it will pay off in the end.
  6. Hello everyone! Some time ago i started working on a script that fully automates the procedure of running and updating a server. The following script is my as of now final result (fixes may occur if needed). It does the following in its current configuration: Update the game Start the Caves Start the Master Wait for 20 minutes Check for an update. If an update is not needed, go to 4. is needed, go to 6. Announce on the server that an update is needed and that the server will restart in 15 minutes Repeat the warning 5 and 1 minute/s before the shutdown so every player can plan ahead Shut down the Caves Shut down the Master Go to 1. You can also force a shutdown using the Ctrl + C command in the terminal window of the running script. The log gets hidden away. If you need to check it, you must open the server_log.txt files. If you followed this guide here, you should have everything correctly in place for the script to work. Remember to change your_cluster_name to the folder name of your cluster in ~/.klei/DoNotStarveTogether. For this script to work you need screen installed on your system, but chances are you already have it. #!/bin/bash #### User Variables; Set your preferences #### CLUSTER_NAME="your_cluster_name" MASTER_NAME="Master" CAVE_NAME="Caves" CHECK_UPDATE_FREQ="20m" DONT_STARVE_CLUSTER_DIR="$HOME/.klei/DoNotStarveTogether" DONT_STARVE_DIR="$HOME/dontstarvetogether_dedicated_server" #### Script Variables; Do not modify #### lv_file="/tmp/${CLUSTER_NAME}_latest_version" DONT_STARVE_BIN="./dontstarve_dedicated_server_nullrenderer" #### Functions #### function needs_update() { klei_url="" latest_version=$(curl -s $klei_url | grep -Po "\s+\d{6,}$" | head -n 1) if [[ -e $lv_file ]]; then current_version=$(head -n 1 $lv_file) fi echo $latest_version > $lv_file if [[ $current_version -lt $latest_version ]]; then echo "1" else echo "-1" fi } function exists() { if [[ ! -e $1 ]]; then failed "File/Dir not found: $1" fi } function failed() { echo "Error: $@" >&2 exit 1 } function command_m() { screen -S ${CLUSTER_NAME}_${MASTER_NAME} -p 0 -X stuff "$1^M" } function command_c() { screen -S ${CLUSTER_NAME}_${CAVE_NAME} -p 0 -X stuff "$1^M" } function stop_server() { command_m 'c_announce("Server stopped by force! Shutting down!")' sleep "2s" command_c 'c_shutdown()' command_m 'c_shutdown()' # The server gets 20 seconds to shutdown normally # sleep "20s" # Should the server still be running; Kill it # if screen -list | grep -q ${CLUSTER_NAME}; then command_c "^C" command_m "^C" fi exit 1 } #### Script routine #### trap stop_server 2 # Check for missing files # exists "$DONT_STARVE_CLUSTER_DIR/$CLUSTER_NAME/cluster.ini" exists "$DONT_STARVE_CLUSTER_DIR/$CLUSTER_NAME/cluster_token.txt" exists "$DONT_STARVE_CLUSTER_DIR/$CLUSTER_NAME/$MASTER_NAME/server.ini" exists "$DONT_STARVE_CLUSTER_DIR/$CLUSTER_NAME/$CAVE_NAME/server.ini" # Check for an update beforehand # needs_update 2>&1 >/dev/null while [[ true ]]; do # Force an update # mv "$DONT_STARVE_DIR/mods/dedicated_server_mods_setup.lua" "$DONT_STARVE_DIR/mods/dedicated_server_mods_setup.lua.bak" echo "Start updating the game." steamcmd +force_install_dir $DONT_STARVE_DIR +login anonymous +app_update 343050 validate +quit mv "$DONT_STARVE_DIR/mods/dedicated_server_mods_setup.lua.bak" "$DONT_STARVE_DIR/mods/dedicated_server_mods_setup.lua" # Check for DST binary # exists "$DONT_STARVE_DIR/bin" # Run Shards # cd "$DONT_STARVE_DIR/bin" echo "Starting ${CAVE_NAME}." screen -d -m -S ${CLUSTER_NAME}_${CAVE_NAME} $DONT_STARVE_BIN -cluster $CLUSTER_NAME -shard $CAVE_NAME echo "Starting ${MASTER_NAME}." screen -d -m -S ${CLUSTER_NAME}_${MASTER_NAME} $DONT_STARVE_BIN -cluster $CLUSTER_NAME -shard $MASTER_NAME # Checks for updates # while [[ true ]]; do # Check for updates every 20 minutes # sleep $CHECK_UPDATE_FREQ # If there is an update, we will start the shutdown process # result=$(needs_update) if [[ $result -gt 0 ]]; then echo "The server needs an update. Will restart in 15 minutes." command_m 'c_announce("Klei released an update! The server restarts in 15 minutes!")' sleep "10m" command_m 'c_announce("Klei released an update! The server restarts in 5 minutes!")' sleep "4m" command_m 'c_announce("Klei released an update! The server restarts in 1 minute!")' sleep "1m" command_m 'c_announce("Restarting now!")' command_c 'c_shutdown()' command_m 'c_shutdown()' break fi done # We wait till the game shuts down # echo "Waiting for shards to shut down." while [[ true ]]; do if ! screen -list | grep -q ${CLUSTER_NAME}; then echo "Shards are down. Restarting." break fi done done
  7. I am bumping this as well because i never managed to get it working as well...
  8. Hi, at the moment i use the "ms_playerjoined" and "ms_playerleft" events to call my function whenever someone leaves or joins the game: inst:ListenForEvent("ms_playerjoined", eventfn, GLOBAL.TheWorld) inst:ListenForEvent("ms_playerleft", eventfn, GLOBAL.TheWorld) "inst" in this case is an icebox standing anywhere in the world/caves. The problem i have is that these aren't the right events i think... because ms_playerleft gets only called when someone leaves the caves or logs out from the caves. If the player joined in the overworld and never goes underground, neither event gets called. I need an event that fires when a player logs in and that i can catch regardless if the player joins in the overworld or caves and a similar event for a leaving player. Is there anything i can use? As a temporary fix i use periodic tasks to check for players, but this is pretty bad for performance considering i only care when a player joins or leaves.
  9. inst.components.eater:SetDiet({ FOODGROUP.OMNI }, nil) because the SetDiet function is defined as follows: function Eater:SetDiet(caneat, preferseating) self.caneat = caneat self.preferseating = preferseating or caneat end You can ignore the preferseating argument and just set it to nil, because it will then assume caneat is also what the character prefers to eat. With this setup your character will be able to eat the "default" stuff (as defined in constants.lua): FOODGROUP = { OMNI = { name = "OMNI", types = { FOODTYPE.MEAT, FOODTYPE.VEGGIE, FOODTYPE.INSECT, FOODTYPE.SEEDS, FOODTYPE.GENERIC, FOODTYPE.GOODIES, }, } }
  10. Like AkaiNight already said: If you just want to make your character do different stuff (like a transformation) based on the food item, then you would be better of to supply an oneatfn. For this you put the following in your master_postinit: inst.components.eater:SetOnEatFn(OnEat) where OnEat is something like the following function: local function OnEat(inst, food) if not food:HasTag("spoiled") then if food.prefab == "seeds" then inst.components.sanity:DoDelta(2) elseif food.prefab == "dragonfruit_seeds" then inst.components.sanity:DoDelta(-5) inst.components.temperature:DoDelta(20) elseif food.prefab == "carrot_seeds" then inst.components.sanity:DoDelta(6) elseif food.prefab == "durian_seeds" then inst.components.sanity:DoDelta(-9999) inst.components.hunger:DoDelta(9999) elseif food.prefab == "eggplant_seeds" then inst.components.hunger:DoDelta(10) elseif food.prefab == "pomegranate_seeds" then elseif food.prefab == "pumpkin_seeds" then inst.components.sanity:DoDelta(10) elseif food.prefab == "watermelon_seeds" then inst.components.sanity:DoDelta(-5) inst.components.temperature:DoDelta(-5) elseif food.prefab == "sweet_potato_seeds" then inst.components.sanity:DoDelta(5) inst.components.hunger:DoDelta(1) elseif food.prefab == "corn_seeds" then inst.components.sanity:DoDelta(1) end end end This OnEat function is from my character Avia. She can only eat seeds, but each different seed gives her extra benefits. You could use this function to do the transformation, deal punishment for eating non fruit items, etc. This function gets called AFTER you eat the food item. Also i am not really sure what you mean with "normal diet's coding"?
  11. Like Lumina said, this is normally handled with the foodtype. My idea to solve this would be to overwrite the PrefersToEat function in the eater component. Include a list of acceptable foods inside your mod and check for it in there.
  12. PC has this ability, but you need to use a controller.
  13. I kinda solved my problem by bypassing it i guess. I had a backup from 12 hours prior to the updates that came in the last 24 hours. Using it made the server show up again. This is strange, though, because no one was on the server in that time until i needed to restart it because of the updates. So is it possible that an update corrupted the save somehow?
  14. Can confirm, i have the same problem. My server is dedicated and runs on linux, mods enabled, caves enabled and mode is endless. If i may add: The server only doesn't show up. It still accepts commands from the console like before.