Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[RDY] Adds tostring on humanoid #1355

Merged
merged 3 commits into from Mar 15, 2018
Merged

Conversation

pschoffer
Copy link
Contributor

@pschoffer pschoffer commented Feb 17, 2018

Fixes #1353


-- METAMETHODS

local Humanoid_mt = Humanoid._metatable
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Figure out how to make metatables inherit form super metattable

@@ -22,6 +22,13 @@ SOFTWARE. --]]
-- classes.

require("busted")
-- local say = require("say")
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Remove this I guess

@@ -23,10 +23,24 @@ require("class_test_base")
require("entity")
require("entities.humanoid")


-- TODO figure out how to move out of this test
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

TODO

@@ -23,10 +23,16 @@ require("class_test_base")
require("entity")
require("entities.humanoid")

assert:register("assertion", "matches", assertion_matches, "assertion.matches")
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This I am still not happy about, but I am not sure how to solve it. It would be best to register the assertion inside the class_test_base, but the assert table isn't defined there (I don't know why:() Any Ideas?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Did you try adding local assert = require("luassert") to class_test_base?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Awesome it worked! Thanks man. How come i don't need to require luassert inside the test classes? Is it some internal magic?

@pschoffer pschoffer changed the title [WiP] Adds tostring on humanoid [RfC] Adds tostring on humanoid Feb 18, 2018
@pschoffer pschoffer changed the title [RfC] Adds tostring on humanoid [RDY] Adds tostring on humanoid Mar 5, 2018
@TheCycoONE
Copy link
Member

TheCycoONE commented Mar 9, 2018

Mostly good, this is how the resulting error looks to me:

Error in timer handler: 
...ephen/github/CorsixTH/CorsixTH/Lua/entities/humanoid.lua:870: Action queue was empty. This should never happen. <LocalisedString> Current value:WHITHAM - class: Doctor
Warmth: 0.212   Happiness: 0.999   Fatigue: 0.000  Thirst: 0.000  Toilet_Need: 0.000   Health: 0.930
Actions: [walk - going to 65:59   must_happen, meander]
Skills: (0.519)  Surgeon (0.000)  Psych (0.000)  Researcher (0.000)
stack traceback:
        [C]: in function 'error'
        ...ephen/github/CorsixTH/CorsixTH/Lua/entities/humanoid.lua:870: in method 'getCurrentAction'
        .../stephen/github/CorsixTH/CorsixTH/Lua/entities/staff.lua:265: in method 'isTiring'
        .../stephen/github/CorsixTH/CorsixTH/Lua/entities/staff.lua:161: in method 'tick'
        /home/stephen/github/CorsixTH/CorsixTH/Lua/world.lua:1036: in method 'onTick'
        /home/stephen/github/CorsixTH/CorsixTH/Lua/app.lua:1014: in function </home/stephen/github/CorsixTH/CorsixTH/Lua/app.lua:1011>
        (...tail calls...)
        /home/stephen/github/CorsixTH/CorsixTH/Lua/app.lua:915: in function </home/stephen/github/CorsixTH/CorsixTH/Lua/app.lua:910>

I think a newline and a label is warranted in the error, maybe something like:

Error in timer handler: 
...ephen/github/CorsixTH/CorsixTH/Lua/entities/humanoid.lua:870: Action queue was empty. This should never happen.
humanoid:
<LocalisedString> Current value:WHITHAM - class: Doctor
Warmth: 0.212   Happiness: 0.999   Fatigue: 0.000  Thirst: 0.000  Toilet_Need: 0.000   Health: 0.930
Actions: [walk - going to 65:59   must_happen, meander]
Skills: (0.519)  Surgeon (0.000)  Psych (0.000)  Researcher (0.000)
stack traceback:
        [C]: in function 'error'
        ...ephen/github/CorsixTH/CorsixTH/Lua/entities/humanoid.lua:870: in method 'getCurrentAction'
        .../stephen/github/CorsixTH/CorsixTH/Lua/entities/staff.lua:265: in method 'isTiring'
        .../stephen/github/CorsixTH/CorsixTH/Lua/entities/staff.lua:161: in method 'tick'
        /home/stephen/github/CorsixTH/CorsixTH/Lua/world.lua:1036: in method 'onTick'
        /home/stephen/github/CorsixTH/CorsixTH/Lua/app.lua:1014: in function </home/stephen/github/CorsixTH/CorsixTH/Lua/app.lua:1011>
        (...tail calls...)
        /home/stephen/github/CorsixTH/CorsixTH/Lua/app.lua:915: in function </home/stephen/github/CorsixTH/CorsixTH/Lua/app.lua:910>

let me know what you think.

@pschoffer
Copy link
Contributor Author

Good point. I added a new line and some more logic to the name of the humanoid. This is the current state. What do you think?

A stack trace is included below, and the handler has been disconnected.
./CorsixTH/Lua/entities/humanoid.lua:868: Action queue was empty. This should never happen.
<LocalisedString> Current value:humanoid (MANMOOR) - class: Nurse
Warmth: 0.290   Happiness: 1.000   Fatigue: 0.000  Thirst: 0.000  Toilet_Need: 0.000   Health: 0.970
Actions: [meander]
stack traceback:
	[C]: in function 'error'
	./CorsixTH/Lua/entities/humanoid.lua:868: in function 'getCurrentAction'
	./CorsixTH/Lua/entities/staff.lua:265: in function 'isTiring'
	./CorsixTH/Lua/entities/staff.lua:161: in function 'tick'
	./CorsixTH/Lua/world.lua:1036: in function 'onTick'
	./CorsixTH/Lua/app.lua:1014: in function <./CorsixTH/Lua/app.lua:1011>
	(...tail calls...)
	./CorsixTH/Lua/app.lua:915: in function <./CorsixTH/Lua/app.lua:910>

@TheCycoONE
Copy link
Member

I don't like that <LocalisedString> Current value: noise, but I don't know where that is coming from.

@TheCycoONE
Copy link
Member

Actually it comes from

static int l_str_tostring(lua_State *L)
- but why?

@Alberth289346
Copy link
Contributor

Alberth289346 commented Mar 10, 2018

Perhaps to distinguish between a literal English sentence and an English translation of a sentence.

@pschoffer
Copy link
Contributor Author

pschoffer commented Mar 10, 2018

With @TheCycoONE we figured out that it comes from the profile.name when the code does "humanoid" .. " (" .. self.profile.name.. ")" Where the name is localized string so colling implicit metatable tostring on it generates that extra <LocalisedString> Current value:. I still don't fully understand why is it at the beginning of the whole line and if there is a way to suppress that

@TheCycoONE TheCycoONE merged commit f6c6cb4 into CorsixTH:master Mar 15, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants