Jump to content

Encountering something odd.

Recommended Posts

So when I'm in-game if I try to execute a console command remotely I get:


 [string "scripts/consolecommands.lua"]:3: attempt to index a number value


If I try many commands from the server console I'm getting:


 [string "scripts/mainfunctions.lua"]:365: attempt to index upvalue 'debug_entity' (a number value)


I can't quite figure out what's changed, the things I'm trying used to work.  (like "c_select(AllPlayers[x] c_give("$foo")" or something as simple as "c_setsanity(1)".)


Clearly something has changed but I am afraid I'm too slow to have caught exactly what's changed, or what I need to change in my commandlines to make them work.


Anyone got a clue-bat to use on me?



Link to comment
Share on other sites

You c_select'd a number, then c_sel() would return a number, not an entity, and would screw the HasTag("player").

c_select something else, like c_select(ThePlayer).


Also, -c_select(AllPlayers[x] c_give("$foo")- is missing a ), it's -c_select(AllPlayers[x]) c_give("goldnugget")-, which may have caused the error.

Link to comment
Share on other sites

The missing bracket could well be me fat-fingering the command, though I thought I saw it many times over several different attempted commands including PushEvents and .component actions as well.  But I can't prove it, and it would explain why I was choking on a simple thing like giving so let's ignore that as user error.


But I'm still not clear on why trying something like c_godmode() or c_setsanity(1) remotely from an in-game console would result in the "[string "scripts/consolecommands.lua"]:3: attempt to index a number value" error.  I know I wasn't fat-fingering something that simple, and there aren't any parameters getting passed by me in something like c_godmode().  It's especially confusing to me as they'd worked previously.


I was wondering if maybe I had a client that was out of sync somehow, but I couldn't figure out how that'd work as I can't connect to servers running differing versions.

Link to comment
Share on other sites

c_godmode() makes use of ConsoleCommandPlayer(). ConsoleCommandPlayer() makes use of c_sel(). c_sel() makes use of GetDebugEntity(). GetDebugEntity() returns debug_entity. debug_entity gets set in SetDebugEntity(inst).


You somehow passed a number as an inst, so when you used c_sel(), you couldn't index the HasTag, or do anything that required asking for the debug_entity, really, because you didn't have an entity. So c_godmode(), c_setsanity(x) would all fail.


This is why I made myself custom commands that doesn't make use of c_select or c_sel. I only use c_select to pop up the debug info.


Do you still have this issue? Did you "c_select(ThePlayer) c_godmode()"?


Maybe Klei should improve SetDebugEntity like making a

if type(inst) == "table" and inst.entity then    debug_entity = inst else    debug_entity = nil end

to avoid this.

Link to comment
Share on other sites

I'm not in-game, try not to do that during work, so I can't test c_godmode() from the console in-game via remote execution.


I suspect it'll work as I was able to "c_select(AllPlayers[1]) c_setsanity(1)" from the console.  I also tested that I could c_select(AllPlayers[1]) c_give("flint") correctly.


Hrmm, that sequence starting with SetDebugEntity(inst) is getting a bit too deep in the weeds for someone who's just a sysad at heart and mostly scripts.  I'm afraid I'm just not clear on how c_sel() transformed an inst for GetDebugEntity() into a number, but casting has always been a weak spot of mine.


I have to assume that something changed down there in FooDebugEntity() stack, since what worked changed to not work, and seems to have changed back again.  (at least for the console commands I've tested)


I guess I should look more clearly into how to make myself custom commands, and how to do it without getting a server that lists as modded.  (since I want my servers to not be modded)  I know rezecib has suggested I do this, in another thread of mine.  Guess it's time to figure it out.

Link to comment
Share on other sites

Ah, I assumed you were also playing in the server. Indeed, AllPlayers[1] is the way to go.


If you have the log of the server, maybe you can post it so we can pinpoint the command that made inst into a number. If you edit consolecommands.lua directly (or any game file), your server won't appear as modded, you will want to back your functions up in case there is an update or the file may be overwritten.

Link to comment
Share on other sites

It's that simple?  Just modifying the local copy of consolcommands.lua????  Okay, rezecib was right, I really need to get off my ash and do that.  Keeping a local copy of consolecommands.lua in an svn checkout and upping it every time it gets overwritten during an update should be trivially simple.  (and unless the changes break my custom commands should be all I need)


I could go troll back in my logs, might be more effort than this is worth unless someone else is interested for other reasons.  It looks like (from the console) the issues I was seeing seem to have been fixed, and that they were based on things deep enough in the knowledge-base that I wouldn't have grokked them anyways.

Link to comment
Share on other sites

Actually, because I like completeness, here's a set of the fails.  These were all from the in-game console, using ctl to tag them for remote execution.  I've also stripped out multiple duplicate lines (and all intervening lines):


[08:29:20]: [absimiliard:KU_AeGl9oQP] ReceiveRemoteExecute(c_godmode()) @(-89.76, 109.98)
[08:29:20]: [string "scripts/consolecommands.lua"]:3: attempt to index a number value
[08:29:41]: [absimiliard:KU_AeGl9oQP] ReceiveRemoteExecute(c_setsanity(1)) @(-89.76, 109.98)
[08:29:41]: [string "scripts/consolecommands.lua"]:3: attempt to index a number value
[08:30:50]: [absimiliard:KU_AeGl9oQP] ReceiveRemoteExecute(c_gonext("cookpot")) @(-94.78, 70.16)
[08:30:50]: [string "scripts/consolecommands.lua"]:3: attempt to index a number value
[08:31:48]: [absimiliard:KU_AeGl9oQP] ReceiveRemoteExecute(c_gonext("firepit")) @(-119.33, 100.57)
[08:31:48]: [string "scripts/consolecommands.lua"]:3: attempt to index a number value
Link to comment
Share on other sites

You can pretty much edit the entire game locally if you don't add new assets.

Those fails don't tell me anything, if anything, the lines with c_select would be the ones.


Don't you get a log generated automatically in the server folder where the saves and settings go?

Link to comment
Share on other sites

Those are cut and pastes from ServerFiles/log.txt.  The only other files in that directory are a chat_log.txt my server token and a worldgenoverride.lua.


Both my dedicated servers are remotely hosted -- one by KillServers.com and the other by Citadel Servers.  (both the hosts who have pinned posts in the forum about hosting, and both partly because I wanted to test out how easy using them would be for a user in case people wanted to know how it went for me;  went well in general)  My understanding is that Citadel Servers is hosting them off a windows box of some sort, and given that the UI for administration is nearly identical for both hosts I'm guessing KillServers is doing likewise.


However, it does mean I can't use my normal linux commandline skeeziness to do tricky things.  (and I am a total skeeze on the command line, comes from being a sysad for a living)

Link to comment
Share on other sites


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...