MySpoon Posted November 9, 2013 Share Posted November 9, 2013 This is my first post here... woo (sorry if posted in wrong forum...) Anyway, I have little scripting knowledge on LUA (or most other languages for that matter...) so my scripts are terrible. I am making a character that has movement speed based around the current health, e.g. if its above 60 then the movement speed is 9 e.t.c But I'm not too sure if my scripting is correct and I need something to constantly check and display certain variable during the game. (in this case I need to check "runspeed" and "walkspeed") Does anyone know of a program, script or console command that can do this? Link to comment https://forums.kleientertainment.com/forums/topic/29527-how-to-check-certain-values-in-game/ Share on other sites More sharing options...
Developer Cheerio Posted November 11, 2013 Developer Share Posted November 11, 2013 This is my first post here... woo (sorry if posted in wrong forum...) Anyway, I have little scripting knowledge on LUA (or most other languages for that matter...) so my scripts are terrible. I am making a character that has movement speed based around the current health, e.g. if its above 60 then the movement speed is 9 e.t.c But I'm not too sure if my scripting is correct and I need something to constantly check and display certain variable during the game. (in this case I need to check "runspeed" and "walkspeed") Does anyone know of a program, script or console command that can do this?Could you upload what you have so far so that I can take a look? Link to comment https://forums.kleientertainment.com/forums/topic/29527-how-to-check-certain-values-in-game/#findComment-366872 Share on other sites More sharing options...
MySpoon Posted November 11, 2013 Author Share Posted November 11, 2013 (edited) Could you upload what you have so far so that I can take a look? Ok, but i warn you... this was literally my first scripting attempt so try not to laugh too hard...local MakePlayerCharacter = require "prefabs/player_common"local assets = { Asset( "ANIM", "anim/player_basic.zip" ), Asset( "ANIM", "anim/player_idles_shiver.zip" ), Asset( "ANIM", "anim/player_actions.zip" ), Asset( "ANIM", "anim/player_actions_axe.zip" ), Asset( "ANIM", "anim/player_actions_pickaxe.zip" ), Asset( "ANIM", "anim/player_actions_shovel.zip" ), Asset( "ANIM", "anim/player_actions_blowdart.zip" ), Asset( "ANIM", "anim/player_actions_eat.zip" ), Asset( "ANIM", "anim/player_actions_item.zip" ), Asset( "ANIM", "anim/player_actions_uniqueitem.zip" ), Asset( "ANIM", "anim/player_actions_bugnet.zip" ), Asset( "ANIM", "anim/player_actions_fishing.zip" ), Asset( "ANIM", "anim/player_actions_boomerang.zip" ), Asset( "ANIM", "anim/player_bush_hat.zip" ), Asset( "ANIM", "anim/player_attacks.zip" ), Asset( "ANIM", "anim/player_idles.zip" ), Asset( "ANIM", "anim/player_rebirth.zip" ), Asset( "ANIM", "anim/player_jump.zip" ), Asset( "ANIM", "anim/player_amulet_resurrect.zip" ), Asset( "ANIM", "anim/player_teleport.zip" ), Asset( "ANIM", "anim/wilson_fx.zip" ), Asset( "ANIM", "anim/player_one_man_band.zip" ), Asset( "ANIM", "anim/shadow_hands.zip" ), Asset( "SOUND", "sound/sfx.fsb" ), Asset( "SOUND", "sound/wilson.fsb" ), Asset( "ANIM", "anim/beard.zip" ), Asset( "ANIM", "anim/dane.zip" ),}local prefabs = {}--This part below is what I'm trying to do.local function spd(inst, data) if inst.health.currenthealth >= 60 then inst.walkspeed = 9 inst.runspeed = 9 elseif inst.components.health.currenthealth >= 40 and inst.components.health.currenthealth < 60 then inst.walkspeed = 7 inst.runspeed = 7 elseif inst.components.health.currenthealth < 40 then inst.walkspeed = 5 inst.runspeed = 5 endend--================================================================local start_inv ={ "hoodie",}local fn = function(inst) inst.soundname = "wilson" inst.MiniMapEntity:SetIcon("wilson.png") inst.components.health.maxhealth = 80 inst.components.hunger.SetMax = 100 inst.components.locomotor.walkspeed = 9 inst.components.locomotor.runspeed = 9 inst.components.health.currenthealth = math.random(40,55) inst:ListenForEvent(spd)end STRINGS.CHARACTER_TITLES.dane = "Dane"STRINGS.CHARACTER_NAMES.dane = "Dane"STRINGS.CHARACTER_DESCRIPTIONS.dane = ""STRINGS.CHARACTER_QUOTES.dane = "\"\""STRINGS.CHARACTERS.DANE = require "dane_speech" return MakePlayerCharacter("dane", prefabs, assets, fn, start_inv) Edited November 11, 2013 by MySpoon Link to comment https://forums.kleientertainment.com/forums/topic/29527-how-to-check-certain-values-in-game/#findComment-366901 Share on other sites More sharing options...
Malacath Posted November 11, 2013 Share Posted November 11, 2013 Could you upload what you have so far so that I can take a look?Maybe you should set up a bot for this forum that automatically replies with this post to every new thread including the word "help" : P Link to comment https://forums.kleientertainment.com/forums/topic/29527-how-to-check-certain-values-in-game/#findComment-366902 Share on other sites More sharing options...
Developer Cheerio Posted November 11, 2013 Developer Share Posted November 11, 2013 Maybe you should set up a bot for this forum that automatically replies with this post to every new thread including the word "help" : PThe future of mod support: http://www.youtube.com/watch?v=Xw-OqcOjGLc Link to comment https://forums.kleientertainment.com/forums/topic/29527-how-to-check-certain-values-in-game/#findComment-366966 Share on other sites More sharing options...
Malacath Posted November 11, 2013 Share Posted November 11, 2013 (edited) @MySpoonlocal MakePlayerCharacter = require "prefabs/player_common" local assets ={ Asset( "ANIM", "anim/player_basic.zip" ), Asset( "ANIM", "anim/player_idles_shiver.zip" ), Asset( "ANIM", "anim/player_actions.zip" ), Asset( "ANIM", "anim/player_actions_axe.zip" ), Asset( "ANIM", "anim/player_actions_pickaxe.zip" ), Asset( "ANIM", "anim/player_actions_shovel.zip" ), Asset( "ANIM", "anim/player_actions_blowdart.zip" ), Asset( "ANIM", "anim/player_actions_eat.zip" ), Asset( "ANIM", "anim/player_actions_item.zip" ), Asset( "ANIM", "anim/player_actions_uniqueitem.zip" ), Asset( "ANIM", "anim/player_actions_bugnet.zip" ), Asset( "ANIM", "anim/player_actions_fishing.zip" ), Asset( "ANIM", "anim/player_actions_boomerang.zip" ), Asset( "ANIM", "anim/player_bush_hat.zip" ), Asset( "ANIM", "anim/player_attacks.zip" ), Asset( "ANIM", "anim/player_idles.zip" ), Asset( "ANIM", "anim/player_rebirth.zip" ), Asset( "ANIM", "anim/player_jump.zip" ), Asset( "ANIM", "anim/player_amulet_resurrect.zip" ), Asset( "ANIM", "anim/player_teleport.zip" ), Asset( "ANIM", "anim/wilson_fx.zip" ), Asset( "ANIM", "anim/player_one_man_band.zip" ), Asset( "ANIM", "anim/shadow_hands.zip" ), Asset( "SOUND", "sound/sfx.fsb" ), Asset( "SOUND", "sound/wilson.fsb" ), Asset( "ANIM", "anim/beard.zip" ), Asset( "ANIM", "anim/dane.zip" ), } local prefabs = {} --This part below is what I'm trying to do. local function spd(inst, data) --This function seems fine to me ^^ --The current code will call this function whenever the players health changes and set the speed accordingly if inst.health.currenthealth >= 60 then inst.walkspeed = 9 inst.runspeed = 9 elseif inst.components.health.currenthealth >= 40 and inst.components.health.currenthealth < 60 then inst.walkspeed = 7 inst.runspeed = 7 elseif inst.components.health.currenthealth < 40 then inst.walkspeed = 5 inst.runspeed = 5 endend--================================================================local start_inv ={ "hoodie",} local fn = function(inst) inst.soundname = "wilson" inst.MiniMapEntity:SetIcon("wilson.png") inst.components.health.maxhealth = 80 inst.components.hunger:SetMax(100) --SetMax is a function, to call it you'll need to use the : instead of a . and give it an argument via the (...) inst.components.locomotor.walkspeed = 9 inst.components.locomotor.runspeed = 9 inst.components.health.currenthealth = math.random(40,55) --Nothing wrong here, just wanted to say that this creates a random integer between 40 and 55. inst:ListenForEvent("healthdelta" ,spd) --ListenForEvent listens for an event (as the name suggests) The first argument is said event and the second argument is the function called once the event is "heard" --note that the function passed in the second argument must have the signature (inst, data)end STRINGS.CHARACTER_TITLES.dane = "Dane"STRINGS.CHARACTER_NAMES.dane = "Dane"STRINGS.CHARACTER_DESCRIPTIONS.dane = ""STRINGS.CHARACTER_QUOTES.dane = "\"\"" STRINGS.CHARACTERS.DANE = require "dane_speech" return MakePlayerCharacter("dane", prefabs, assets, fn, start_inv) I marked the changed parts with comments, denoted by -- at the beginning of a line. Comments will be ignored when compiling scripts so you can write them anywhere. I hope I didn't make a mistake myself. Also I'd suggest you use a text editor with code highlighting (or whatever it's called) if you don't already do that. Like NotePad++ or Sublime. It will make coding a lot easier. Edited November 11, 2013 by Malacath Link to comment https://forums.kleientertainment.com/forums/topic/29527-how-to-check-certain-values-in-game/#findComment-366976 Share on other sites More sharing options...
Nycidian Posted November 11, 2013 Share Posted November 11, 2013 This is my first post here... woo (sorry if posted in wrong forum...) Anyway, I have little scripting knowledge on LUA (or most other languages for that matter...) so my scripts are terrible. I am making a character that has movement speed based around the current health, e.g. if its above 60 then the movement speed is 9 e.t.c But I'm not too sure if my scripting is correct and I need something to constantly check and display certain variable during the game. (in this case I need to check "runspeed" and "walkspeed") Does anyone know of a program, script or console command that can do this?Yes my mod http://forums.kleientertainment.com/index.php?/files/file/362-n-tools/ will allow you to through the "dig" tool though it helps if you know where you should be looking in the case of things about your character you need to look in the character tables and go from there. Link to comment https://forums.kleientertainment.com/forums/topic/29527-how-to-check-certain-values-in-game/#findComment-367199 Share on other sites More sharing options...
MySpoon Posted November 11, 2013 Author Share Posted November 11, 2013 (edited) @MySpoonlocal MakePlayerCharacter = require "prefabs/player_common" local assets ={ Asset( "ANIM", "anim/player_basic.zip" ), Asset( "ANIM", "anim/player_idles_shiver.zip" ), Asset( "ANIM", "anim/player_actions.zip" ), Asset( "ANIM", "anim/player_actions_axe.zip" ), Asset( "ANIM", "anim/player_actions_pickaxe.zip" ), Asset( "ANIM", "anim/player_actions_shovel.zip" ), Asset( "ANIM", "anim/player_actions_blowdart.zip" ), Asset( "ANIM", "anim/player_actions_eat.zip" ), Asset( "ANIM", "anim/player_actions_item.zip" ), Asset( "ANIM", "anim/player_actions_uniqueitem.zip" ), Asset( "ANIM", "anim/player_actions_bugnet.zip" ), Asset( "ANIM", "anim/player_actions_fishing.zip" ), Asset( "ANIM", "anim/player_actions_boomerang.zip" ), Asset( "ANIM", "anim/player_bush_hat.zip" ), Asset( "ANIM", "anim/player_attacks.zip" ), Asset( "ANIM", "anim/player_idles.zip" ), Asset( "ANIM", "anim/player_rebirth.zip" ), Asset( "ANIM", "anim/player_jump.zip" ), Asset( "ANIM", "anim/player_amulet_resurrect.zip" ), Asset( "ANIM", "anim/player_teleport.zip" ), Asset( "ANIM", "anim/wilson_fx.zip" ), Asset( "ANIM", "anim/player_one_man_band.zip" ), Asset( "ANIM", "anim/shadow_hands.zip" ), Asset( "SOUND", "sound/sfx.fsb" ), Asset( "SOUND", "sound/wilson.fsb" ), Asset( "ANIM", "anim/beard.zip" ), Asset( "ANIM", "anim/dane.zip" ), } local prefabs = {} --This part below is what I'm trying to do. local function spd(inst, data) --This function seems fine to me ^^ --The current code will call this function whenever the players health changes and set the speed accordingly if inst.health.currenthealth >= 60 then inst.walkspeed = 9 inst.runspeed = 9 elseif inst.components.health.currenthealth >= 40 and inst.components.health.currenthealth < 60 then inst.walkspeed = 7 inst.runspeed = 7 elseif inst.components.health.currenthealth < 40 then inst.walkspeed = 5 inst.runspeed = 5 endend--================================================================local start_inv ={ "hoodie",} local fn = function(inst) inst.soundname = "wilson" inst.MiniMapEntity:SetIcon("wilson.png") inst.components.health.maxhealth = 80 inst.components.hunger:SetMax(100) --SetMax is a function, to call it you'll need to use the : instead of a . and give it an argument via the (...) inst.components.locomotor.walkspeed = 9 inst.components.locomotor.runspeed = 9 inst.components.health.currenthealth = math.random(40,55) --Nothing wrong here, just wanted to say that this creates a random integer between 40 and 55. inst:ListenForEvent("healthdelta" ,spd) --ListenForEvent listens for an event (as the name suggests) The first argument is said event and the second argument is the function called once the event is "heard" --note that the function passed in the second argument must have the signature (inst, data)end STRINGS.CHARACTER_TITLES.dane = "Dane"STRINGS.CHARACTER_NAMES.dane = "Dane"STRINGS.CHARACTER_DESCRIPTIONS.dane = ""STRINGS.CHARACTER_QUOTES.dane = "\"\"" STRINGS.CHARACTERS.DANE = require "dane_speech" return MakePlayerCharacter("dane", prefabs, assets, fn, start_inv) I marked the changed parts with comments, denoted by -- at the beginning of a line. Comments will be ignored when compiling scripts so you can write them anywhere. I hope I didn't make a mistake myself. Also I'd suggest you use a text editor with code highlighting (or whatever it's called) if you don't already do that. Like NotePad++ or Sublime. It will make coding a lot easier. Thanks for the help, but after I fixed up my script I got an error on line 45 which was:if inst.health.currenthealth >= 60 then It stopped giving an error when I commented out:inst:ListenForEvent("healthdelta" ,spd) *If there is an error log in the game folder... Then I can find it, so im typing it all out.* ...s/Dane - Playable Character/scripts/prefabs/dane.lua:45: attempt to index field 'health'(a nil value)LUA ERROR stac traceback:C:/Program File (x86)/Steam/steamapps/common/dont_starve/data/../mods/Dane - Playable Character/prefabs/dane.lua(45,1) in funtion 'fn'C:/Program File (x86)/Steam/steamapps/common/dont_starve/data/scripts/entryscript.lua(634,1) in funtion 'PushEvent'C:/Program File (x86)/Steam/steamapps/common/dont_starve/data/scripts/components/health.lua(264,1)in function 'DoDelta'C:/Program File (x86)/Steam/steamapps/common/dont_starve/data/scripts/components/health.lua(46,1)in function 'RecalculatePenalty'C:/Program File (x86)/Steam/steamapps/common/dont_starve/data/scripts/gamelogic.lua(770,1)in function 'DoInitGame'C:/Program File (x86)/Steam/steamapps/common/dont_starve/data/scriptsgamelogic.lua(914,1)in function 'cb'C:/Program File (x86)/Steam/steamapps/common/dont_starve/data/scripts/svaeindex.lua(549,1)=[C] in funtion 'SetPersistentString' Also I do use notepad++ as I have had I little bit of experience scripting, so I can wrap my head around the basic logic and order. Its just learning a new scripting language... But still, thanks for all the little pointers you gave within the script and such. Yes my mod http://forums.kleientertainment.com/index.php?/files/file/362-n-tools/ will allow you to through the "dig" tool though it helps if you know where you should be looking in the case of things about your character you need to look in the character tables and go from there.Ha ha, I once downloaded your mod a while ago but had no Idea what it was for!But now of course I do, but I'm having quite a hard time trying to find what I'm looking for... (runspeed & walkspeed) Edited November 11, 2013 by MySpoon Link to comment https://forums.kleientertainment.com/forums/topic/29527-how-to-check-certain-values-in-game/#findComment-367403 Share on other sites More sharing options...
Craig_Perry Posted November 11, 2013 Share Posted November 11, 2013 snip*can you post the whole log? since that part doesn't contain the line causing the error, just what it did Link to comment https://forums.kleientertainment.com/forums/topic/29527-how-to-check-certain-values-in-game/#findComment-367407 Share on other sites More sharing options...
MySpoon Posted November 11, 2013 Author Share Posted November 11, 2013 can you post the whole log? since that part doesn't contain the line causing the error, just what it did Right, well in that case I have no idea what i'm doing. Where can I find this log? Link to comment https://forums.kleientertainment.com/forums/topic/29527-how-to-check-certain-values-in-game/#findComment-367410 Share on other sites More sharing options...
Malacath Posted November 11, 2013 Share Posted November 11, 2013 (edited) Right, well in that case I have no idea what i'm doing. Where can I find this log?Not necessary, I simply dumbed out... it should beinst.components.health.healthcurrentcomponents was the thing missing inbetween.Don't forget to fix the other places where that occcured. And you can find the log in your documents folder Klei/DoNotStarve/log.txt Also, how did you break the formating on your post up there that bad o.0 Edited November 11, 2013 by Malacath Link to comment https://forums.kleientertainment.com/forums/topic/29527-how-to-check-certain-values-in-game/#findComment-367418 Share on other sites More sharing options...
MySpoon Posted November 11, 2013 Author Share Posted November 11, 2013 (edited) how did you break the formating on your post up there that bad o.0 Bad things happen when I'm tired... Edit, Everything now works perfectly thanks!Only thing im trying to do is just find the variables in Nycidian's mod and that's that. Thanks for all your help! Edited November 11, 2013 by MySpoon Link to comment https://forums.kleientertainment.com/forums/topic/29527-how-to-check-certain-values-in-game/#findComment-367430 Share on other sites More sharing options...
Nycidian Posted November 11, 2013 Share Posted November 11, 2013 Bad things happen when I'm tired... Edit, Everything now works perfectly thanks!Only thing im trying to do is just find the variables in Nycidian's mod and that's that. Thanks for all your help!The mod is really only helpful if you are unsure what your looking for or if you want to see how the variables are changing in the game without writing in a lot of print() statements in your code. as for finding what your looking for, in... inst.components.health.healthcurrent ...the inst is a variable which in this case stands for your character so with my mod you want to start at "character" (not GLOBAL or World) and choose table variables click "components" then "health" then switch to number variables and look at "healthcurrent." Link to comment https://forums.kleientertainment.com/forums/topic/29527-how-to-check-certain-values-in-game/#findComment-367479 Share on other sites More sharing options...
MySpoon Posted November 11, 2013 Author Share Posted November 11, 2013 The mod is really only helpful if you are unsure what your looking for or if you want to see how the variables are changing in the game without writing in a lot of print() statements in your code. as for finding what your looking for, in... inst.components.health.healthcurrent ...the inst is a variable which in this case stands for your character so with my mod you want to start at "character" (not GLOBAL or World) and choose table variables click "components" then "health" then switch to number variables and look at "healthcurrent." AH! Thanks, i've found what i'm looking for. And by the way your mod is great! Link to comment https://forums.kleientertainment.com/forums/topic/29527-how-to-check-certain-values-in-game/#findComment-367505 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