Can't Get Modify Web Portal Tutorial To Work

It’s weird because I can get the modify web portal to work if I don’t use the listed data(goals). I can get it to read a PDF document in an iframe but if I try to do the tutorial exactly as listed(I literally just copy and paste every piece of information) it does not work. The tab shows up on the web portal, I can set and view the Goals information on the game, but the information does not populate in the tab on the web portal. I’ve tried both on my private heroes game and on a blank DB I set up just to test this tutorial. Tab shows up, no data is displayed(even though I can set it and view it on the MUSH). Any thoughts?

If you put something random like CATS in the HBS file does it show up?

Oh also - try load profile in game. That step is missing from the tutorial, sorry.

Ah. That got the singular tab of Goals to work. What I’m actually attempting to do is create multiple custom tabs and it doesn’t seem to be working. I can see the tabs but only Goals loads. Is there anything special one should keep in mind when trying to add multiple tabs in this fashion?

The tab shows up but no data populates(I can set and view the data on the MUSH though). I’ve simply gone through all the steps in the tutorial again appending them to what I did for goals. For example:

 <div id="systemgoals" class="tab-pane fade">
    {{{ansi-format text=char.custom.goals}}}

 <div id="trait_skills" class="tab-pane fade">
    {{{ansi-format text=char.custom.sht_skills}}}

Check to make sure none of your methods have multiple return statements.

Won’t work:

return { goals: xxx }
return { other: xxx }

Will work:

return {
   goals: xxx,
   other: xxx

That’s what I needed. Thanks. :slight_smile:

Well, I hate to be the guy who keeps asking stupid questions but…

Everything seems to be working okay except when I set the fields in character generation via the web and click save it kicks the player to the main screen with an error message. The fields seem to save okay, however. This is what I get from the log.

2020-02-11 20:47:29 ERROR - Error in Web Request: client= error=undefined method any?' for #<AresMUSH::Character:0x0000000005149fd8> backtrace=["/home/ares/aresmush/plugins/chargen/helpers.rb:125:in save_char’", “/home/ares/aresmush/plugins/chargen/web/chargen_save_request_handler.rb:18:in handle'", "/home/ares/aresmush/engine/aresmush/commands/dispatcher.rb:145:in block (2 levels) in on_web_request’”, “/home/ares/aresmush/engine/aresmush/commands/dispatcher.rb:139:in each'", "/home/ares/aresmush/engine/aresmush/commands/dispatcher.rb:139:in block in on_web_request’”, “/home/ares/aresmush/engine/aresmush/error_block.rb:6:in with_error_handling'", "/home/ares/aresmush/engine/aresmush/commands/dispatcher.rb:138:in on_web_request’”, “/home/ares/aresmush/engine/aresmush/web/engine_api_server.rb:79:in block in handle_request'", "/home/ares/aresmush/engine/aresmush/error_block.rb:6:in with_error_handling’”, “/home/ares/aresmush/engine/aresmush/web/engine_api_server.rb:71:in `handle_request’”]

2020-02-11 20:47:29 ERROR - Unhandled web request: {“cmd”=>“chargenSave”, “args”=>{“char”=>{“id”=>“22”, “demographics”=>{“played by”=>{“name”=>“Played By”, “value”=>""}, “hair”=>{“name”=>“Hair”, “value”=>""}, “eyes”=>{“name”=>“Eyes”, “value”=>""}, “skin”=>{“name”=>“Skin”, “value”=>""}, “height”=>{“name”=>“Height”, “value”=>""}, “physique”=>{“name”=>“Physique”, “value”=>""}, “full name”=>{“name”=>“Full Name”, “value”=>""}, “gender”=>{“name”=>“Gender”, “value”=>""}, “codename”=>{“name”=>“Codename”, “value”=>""}, “age”=>{“name”=>“Age”, “value”=>“0”}}, “groups”=>{“type”=>{“name”=>“Type”, “value”=>“Hero”, “desc”=>“Seekers of truth and justice.”}}, “desc”=>"", “shortdesc”=>"", “rp_hooks”=>"", “profile_image”=>"", “background”=>"", “lastwill”=>"", “fs3”=>"", “custom”=>{“sht_skills”=>“Test Skills34”, “sht_abilities”=>“Test Abiliites For The Win”, “sht_advantages”=>"", “sht_drawbacks”=>""}, “traits”=>""}}, “api_key”=>“c7fafa20-8c06-4aa1-ba32-450f4d9afb9d”, “auth”=>{“authenticator”=>“authenticator:ares”, “token”=>“f99d8c9b-7981-41cb-8525-bf68fc91d503”, “name”=>“Eric”, “id”=>“22”, “is_approved”=>“false”, “is_admin”=>“false”, “is_coder”=>“false”}}.

If it helps this is my onUpdate in chargen-custom.js.

onUpdate: function() {
// Return a hash containing your data. Character data will be in ‘char’. For example:
// return { goals: this.get(‘char.custom.goals’) };
return {
sht_skills: this.get(‘char.custom.sht_skills’),
sht_abilities: this.get(‘char.custom.sht_abilities’),
sht_advantages: this.get(‘char.custom.sht_advantages’),
sht_drawbacks: this.get(‘char.custom.sht_drawbacks’)

It looks like you’re returning a character object from save_char instead of a list of errors. Check out your Profile::CustomCharFields.save_fields_from_chargen method and make sure that the return value is either an empty list [] if everything’s cool, or a list of error messages like [ "Can't save the thingy for reasons.", "Can't save the other thingy for other reasons." ]

Hmmm, here is what I have…

Save fields and return an array of any error messages.

  # Note Custom fields will be in chargen_data[:custom]
  # Example: char.update(goals: chargen_data[:custom][:goals])
  def self.save_fields_from_chargen(char, chargen_data)
    char.update(sht_skills: chargen_data[:custom][:sht_skills])
    char.update(sht_abilities: chargen_data[:custom][:sht_abilities])
    char.update(sht_advantages: chargen_data[:custom][:sht_advantages])
    char.update(sht_drawbacks: chargen_data[:custom][:sht_drawbacks])

Yeah just add

return []

under your updates.

So simple. Thanks again! :slight_smile:

1 Like