Mys 1.3.6 Shop NPC & In-Shop Descriptions

Forum
Last Post
Threads / Messages

Constellraetion

Member
Member
Joined
May 6, 2022
Messages
20
Points
3
Mysidian Dollar
208
This not being an already present feature frustrated me enough that i stayed up way too late to get it working, full disclaimer i am not at all experienced with php so this is just me trying my best over here. Anyway.

Start by adding two columns to your _shops table:
shoptalk (varchar 500), which will be our shop description, and
shopkeeper (varchar 150) which will be our NPC image.

In model/domainmodel/shop.php, add the following functions:

PHP:
    public function getTalk(){
        return $this->shoptalk;
    }

    public function getShopKeeper(){
        return $this->shopkeeper;     
    }

This lets us call the values for the NPC and shop description onto our shop's pages. Now to add them to the pages themselves.

In view/main/shopview.php, add the following under public function browse directly under $document->setTitle($shop->getShopname());

Code:
        $document->addLangvar("<img src='{$shop->getShopKeeper()}'> <br><br>");
        $document->addLangvar($shop->getTalk());

This adds the shopkeeper and shop description to the pages. By now that's really all you need to do to give shops their new customized facelift, but to make things easier let's add this to the ACP so that the shop NPC and description can be added and modified natively.

Go to controller/admincp/shopcontroller.php and add the following to public function add and public function edit. Preferably after description or imageurl but I'm not sure if it matters too much.

Code:
"shopkeeper" => $mysidia->input->post("shopkeeper"), "shoptalk" => $mysidia->input->post("shoptalk"),

Now go over to view/admincp/shopview.php and add the following in public function add under $shopForm->buildDropdownList("existingimageurl", "ImageList");

Code:
        $shopForm->add(new Comment("Shopkeeper Image: ", FALSE));
        $shopForm->add(new TextField("shopkeeper"));
        $shopForm->add(new Comment("Shopkeeper Text:"));
        $shopForm->add(new TextArea("shoptalk", "Here you can enter a shopkeeper's text for your shop", 4, 50));

and this in public function edit under $shopForm->buildDropdownList("existingimageurl", "ImageList", $shop->getImageURL());

Code:
            $shopForm->add(new Comment("Shopkeeper Image: ", FALSE));
            $shopForm->add(new TextField("shopkeeper", $shop->getShopKeeper()));
            $shopForm->add(new Comment("Shopkeeper Text:"));
            $shopForm->add(new TextArea("shoptalk", $shop->getTalk(), 4, 50));

And with that we're done. In the ACP when you go to add or edit a new shop you should have an additional box for adding an image url for the shop NPC and a box for some flavor text for the shop itself. Here's how things should look when you're all done.

In the ACP:
Screen Shot 2022-05-21 at 11.15.02 AM.png

On the shop page itself:
Screen Shot 2022-05-21 at 11.56.40 AM.png
 
Last edited:

Constellraetion

Member
Member
Joined
May 6, 2022
Messages
20
Points
3
Mysidian Dollar
208
This one looks interesting, seems its your first time making a mod and hope you had fun doing this.
it was actually incredibly irritating to do because of how little info there is on how or where all the files which are connected to a series of pages are located but i guess i got it eventually and didn't destroy the site in the process and learned a bit about how to start making things work the way i want instead of just feeling like screaming both internally and externally intermittently so, progress was made
 

GeneticAlpha

Loving Mysidia!
Member
Joined
May 24, 2020
Messages
235
Points
18
Age
29
Location
Tennessee
Mysidian Dollar
12,911
it was actually incredibly irritating to do because of how little info there is on how or where all the files which are connected to a series of pages are located but i guess i got it eventually and didn't destroy the site in the process and learned a bit about how to start making things work the way i want instead of just feeling like screaming both internally and externally intermittently so, progress was made
In 1.3.5 we have regular php files and then view files and with 1.3.6 the file names were changed and moved around so I was lost. Hoping by the time I start a 1.3.6 site there might be some documentation on it somewhere lol.
 

Constellraetion

Member
Member
Joined
May 6, 2022
Messages
20
Points
3
Mysidian Dollar
208
In 1.3.5 we have regular php files and then view files and with 1.3.6 the file names were changed and moved around so I was lost. Hoping by the time I start a 1.3.6 site there might be some documentation on it somewhere lol.
if i keep progressing at my current rate i'lll probably end up putting something like that together eventually lol
 

Similar threads

Users who are viewing this thread

  • Forum Contains New Posts
  • Forum Contains No New Posts

Forum statistics

Threads
4,187
Messages
32,473
Members
1,553
Latest member
Polymori
BETA

Latest Threads

Top