Jump to content

[SOLVED] Sanity Aura Code Crashing


Recommended Posts

3 minutes ago, Ultroman said:

AH! So it was ME who was coding C# instead of Lua. I guess I have no knowledge of Lua syntax ;)

That description could probably do with an update. Sorry about that. Nevertheless, there's only one way to be sure whether you have a server log or not, which is important when debugging to establish where the error occurred. The fact that you have a server log tells us that the server was started successfully, which it does before the host-player gets to the character-select screen. Once the host-player is at the character-select screen, the server has started and is waiting for the first player to join and pick a character, before it "unpauses" (starts its game timer, starts all entities, etc.).

Anyway, in your first server log, there it is:


[string "../mods/wolyo/scripts/prefabs/wolyo.lua"]:61: unexpected symbol near '!'
LUA ERROR stack traceback:
        =[C] in function 'assert'
        scripts/mainfunctions.lua(150,1)
        =(tail call) ?
        =[C] in function 'xpcall'
        scripts/mods.lua(161,1)
        scripts/mods.lua(603,1) in function 'RegisterPrefabs'
        scripts/gamelogic.lua(231,1) in function 'LoadAssets'
        scripts/gamelogic.lua(1057,1) in function 'DoResetAction'
        scripts/gamelogic.lua(1076,1) in function 'complete_callback'
        scripts/upsell.lua(13,1) in function 'UpdateGamePurchasedState'
        scripts/gamelogic.lua(1100,1) in function 'callback'
	...
        =[C] in function 'GetPersistentString'
        scripts/saveindex.lua(278,1) in function 'Load'
        scripts/gamelogic.lua(1117,1) in function 'callback'
        scripts/playerprofile.lua(997,1) in function 'Set'
        scripts/playerprofile.lua(852,1)
        =[C] in function 'GetPersistentString'
        scripts/playerprofile.lua(850,1) in function 'Load'
        scripts/gamelogic.lua(1116,1) in main chunk
        =[C] in function 'require'
        scripts/mainfunctions.lua(940,1)	

It is an ! on line 61. That should probably be a ~

That was the old log before I changed the "!" to a "~". I'm gonna take a step back to when I said I tried this, had the server launch successfully, but there was no sanity regen around the set entities. Basically nothing happens even though the code was in the .lua, WITH the "~".

 

I noticed in Willow's she has an "if" statement, but the one you composed does not. Please correct me, but is there not one needed? :confused:

I'm not sure if logs would help here since there is no error occuring (I think), but if there is I will be sure to attach them if you need them.

 

I'm really curious to see the final result of this code :o

Link to comment
Share on other sites

2 hours ago, Cthonicus said:

I noticed in Willow's she has an "if" statement, but the one you composed does not. Please correct me, but is there not one needed? :confused:

It doesn't really work that way. My code does something entirely different from hers. You have to look at what the code does, not what it looks like.

2 hours ago, Cthonicus said:

I'm not sure if logs would help here since there is no error occuring (I think), but if there is I will be sure to attach them if you need them.

Logs always help, but in this case, you have to read further in the newcomer post about print-statements. We need to find out what the code is doing. Since it isn't producing any errors, it doesn't write anything in the log. We can do that with print-statements. You can either give it a go yourself, or you can zip up the whole mod and send it to me, so I can debug it for you, and then explain how I did it and what was wrong afterwards.

  • Thanks 1
Link to comment
Share on other sites

39 minutes ago, Ultroman said:

or you can zip up the whole mod and send it to me, so I can debug it for you, and then explain how I did it and what was wrong afterwards.

Your willingness to help me is just astonishing :D

I'll attach it for you. but I'm definitely gonna try to see if I can find the problem myself! I see how to do so in your post.

 

The only reason I make comparisons are to try to compare and contrast code (see why this code has this line, why the other doesn't, and vice versa) and try to figure out what they do by that alone. It's kind of a "hands-on" way of learning things for me. By doing this it helps me understand things better rather than looking at a bunch of code and trying to dissect it. But that's just me.

 

wolyo.zip

Edited by Cthonicus
Link to comment
Share on other sites

46 minutes ago, Cthonicus said:

The only reason I make comparisons are to try to compare and contrast code (see why this code has this line, why the other doesn't, and vice versa) and try to figure out what they do by that alone. It's kind of a "hands-on" way of learning things for me. By doing this it helps me understand things better rather than looking at a bunch of code and trying to dissect it. But that's just me.

I understand. But if you haven't yet, do take the Lua Crash Course. It's not very long and since you've already read a bunch of it you should have an easier start. It will help you tremendously in understanding what is happening.

The error is again mine. This is an explanation of FindEntities I wrote once.

Quote

Description of TheSim:FindEntities function:
TheSim:FindEntities(x, y, z, radius, mustHaveTags, cantHaveTags, mustHaveOneOfTheseTags)
x, y and z should be the position of the center of the circle/sphere which FindEntities should use to check for entities.
radius is of course the radius of that circle/sphere.
In order to use any of the ***Tags parameters, give them a list of tags e.g. {"tag1", "tag2"}
Putting in nil for either of them completely skips the check for them, so omitting all of them simply includes all entities.

We are supposed to be using the mustHaveOneOfTheseTags parameter and not the mustHaveTags. So:

local ents = TheSim:FindEntities(x, y, z, max_rad, nil, nil, {
	"bee", "flower", "butterfly", "rabbit", "koalefant_summer",
	"koalefant_winter", "chester", "squid", "glommer", "hutch", "mole"
})

 

Edited by Ultroman
  • Thanks 1
Link to comment
Share on other sites

OOOH! IT'S WORKING!! :D

I guess that was it! So you added the two "nil"s to fill in the blanks for the unused parameters and that's what solved it?

I'm just really thankful you took your time to help me with this, and also educate me at the same time! I'll be sure to check out the crash course sometime. I definitely took a lot from this and will make the process next time significantly easier for me. You've been a huge help and I in no way or form could've done this without you. I can finally complete the mod!

 

I wish I could've contributed more to solving the mystery, but I honestly feel this was a tough code to try at such an early stage of my LUA career xD

 

Again, thanks.

Edited by Cthonicus
  • Like 1
Link to comment
Share on other sites

It did it again with your post. The crazy wide browser page thing.

 

5 minutes ago, Cthonicus said:

I guess that was it! So you added the two "nil"s to fill in the blanks for the unused parameters and that's what solved it?

Yep

6 minutes ago, Cthonicus said:

I'm just really thankful you took your time to help me with this, and also educate me at the same time! I'll be sure to check out the crash course sometime. I definitely took a lot from this and will make the process next time significantly easier for me. You've been a huge help and I in no way or form could've done this without you. I can finally complete the mod!

You're very welcome! :) I hope you take the time to learn programming. It's really fun to create something and just "see it go" as you test things out. I'm making an awesome game at work with a bunch of connected machines, and it's just so satisfying to make each one and see it work in tandem with the other machines. If you like that sort of thing and have a lot of patience for it, you should have a great time with all sorts of projects. Once you've learned your first programming language, all the other languages are MUCH easier to learn.

Congratulations on your first mod :)

Link to comment
Share on other sites

9 minutes ago, Ultroman said:

It did it again with your post. The crazy wide browser page thing.

 

Yep

You're very welcome! :) I hope you take the time to learn programming. It's really fun to create something and just "see it go" as you test things out. I'm making an awesome game at work with a bunch of connected machines, and it's just so satisfying to make each one and see it work in tandem with the other machines. If you like that sort of thing and have a lot of patience for it, you should have a great time with all sorts of projects. Once you've learned your first programming language, all the other languages are MUCH easier to learn.

Congratulations on your first mod :)

I agree! The concept of seeing words and images work together to create motion is really neat. It's for sure something I'd be interested in expanding on.

 

Before I can put this thread as solved, I have one one quickie little question. I noticed the scaling on headware on my character is a little larger than it is on other characters, so, is there a way to scale it smaller? I think I remember seeing a rather simple method for this, but I just want to make sure :p

  • Like 1
Link to comment
Share on other sites

16 hours ago, Cthonicus said:

Before I can put this thread as solved, I have one one quickie little question. I noticed the scaling on headware on my character is a little larger than it is on other characters, so, is there a way to scale it smaller? I think I remember seeing a rather simple method for this, but I just want to make sure :p

No idea at all. You should start a new topic, so people knowledgeable about character sprites can chime in. This thread should be considered solved. Feature-creeping threads only creates confusion, and this thread is already SO LONG because of all my mistakes :)

  • Like 1
  • Haha 1
Link to comment
Share on other sites

3 minutes ago, Ultroman said:

No idea at all. You should start a new topic, so people knowledgeable about character sprites can chime in. This thread should be considered solved. Feature-creeping threads only creates confusion, and this thread is already SO LONG because of all my mistakes :)

We all learned from this :D

And okay, will do. The problem has been solved!

  • Like 1
Link to comment
Share on other sites

Just now, Ultroman said:

For completion's sake,

Here's the final character code we ended up with:

wolyo.lua

I hope you don't mind me posting the example, @Cthonicus. Let me know, and I will remove it. It's just a great example, because the rest of the character code is close to standard, so it's easy to figure out what's happening.

Not at all! I hope people in the future that want to have a sanity aura have smooth sailing because of this.

  • Like 2
Link to comment
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
 Share

×
  • Create New...