Chessnut / NutScript

A free role-play framework for Garry's Mod.
http://nutscript.rocks
MIT License
94 stars 77 forks source link

Bug: Custom character vars can't be saved #163

Closed Spoffy closed 9 years ago

Spoffy commented 10 years ago

Replicate: Add a new character variable in plugin using the 'CreateCharacterVars' hook, and character:NewVar.

This will be unable to be saved, as there's no entry for the variable in the database schema.

I /believe/ you can use :SetData to get around this persistance issue, but it's worth pointing out. I don't see an easy fix other than constructing the schema/reconstructing it on the fly.

Chessnut commented 10 years ago

Did you modify the SQL structure to allow saving?

On Tuesday, July 8, 2014, Spoffy notifications@github.com wrote:

Replicate: Add a new character variable in plugin using the 'CreateCharacterVars' hook, and character:NewVar.

This will be unable to be saved, as there's no entry for the variable in the database schema.

I /believe/ you can use :SetData to get around this persistance issue, but it's worth pointing out. I don't see an easy fix other than constructing the schema/reconstructing it on the fly.

— Reply to this email directly or view it on GitHub https://github.com/Chessnut/NutScript/issues/163.

Spoffy commented 10 years ago

I didn't, I mentioned that it was caused by the lack of an entry in the schema. But you have to modify the core gamemode directly for that. You could just override it with a new table, but you'd have to copy all the code that creates the table. Personally, I think it should either modify the schema on the fly, handle it in another way, or not exist as a public function.

Chessnut commented 10 years ago

I think you're over complicating things. There's another bool argument to not save it.

On Thu, Jul 10, 2014 at 2:07 PM, Spoffy notifications@github.com wrote:

I didn't, I mentioned that it was caused by the lack of an entry in the schema. But you have to modify the core gamemode directly for that. You could just override it with a new table, but you'd have to copy all the code that creates the table. Personally, I think it should either modify the schema on the fly, handle it in another way, or not exist as a public function.

— Reply to this email directly or view it on GitHub https://github.com/Chessnut/NutScript/issues/163#issuecomment-48664489.

Chessnut commented 10 years ago

Also you can just do an sql query if you want to modify the tables. You don't need to edit the core tables.

On Thu, Jul 10, 2014 at 10:01 PM, Brian Hang chessnutist@gmail.com wrote:

I think you're over complicating things. There's another bool argument to not save it.

On Thu, Jul 10, 2014 at 2:07 PM, Spoffy notifications@github.com wrote:

I didn't, I mentioned that it was caused by the lack of an entry in the schema. But you have to modify the core gamemode directly for that. You could just override it with a new table, but you'd have to copy all the code that creates the table. Personally, I think it should either modify the schema on the fly, handle it in another way, or not exist as a public function.

— Reply to this email directly or view it on GitHub https://github.com/Chessnut/NutScript/issues/163#issuecomment-48664489.

Spoffy commented 10 years ago

I did want it to save, but valid point on the last one. Fair enough, I'll close this. :) Might be worth adding a comment above the function though. :)

Sorry, I just thought, why not have it update the schema from the call to NewVar? :P