SMF Shop

SMFShop => Coding => Topic started by: Basil Beard on February 23, 2007, 11:45:18 am

Title: Making Packages?
Post by: Basil Beard on February 23, 2007, 11:45:18 am
Is there a guide on how to make packages somewhere? I am almost done with my pets mod, and wanted to package it up for everyone to be happy with.  :coolsmiley: But yeah. I donno how and I am sure you all don't want to install it by hand. (Even though only three files actually get edited, the rest is new stuff and database stuff).

But yeah. I still need to iron out a few kinks, but everybody should have pets... early next week  :angel:
Title: Re: Making Packages?
Post by: xfollowthereaperx on February 23, 2007, 04:20:09 pm
Pet mod?

My god, someone link this man
Title: Re: Making Packages?
Post by: Martin on February 23, 2007, 05:57:12 pm
Here's a package SDK if it helps, http://www.simplemachines.org/community/index.php?topic=20319.0
Title: Re: Making Packages?
Post by: Basil Beard on February 24, 2007, 01:59:15 am
Yeah. I saw that. But it didn't help much.

If all else fails, I can just post the files and Daniel or someone else who knows how to create packages can like, package it up XD
Title: Re: Making Packages?
Post by: feeble on February 24, 2007, 06:12:38 am
Yeah. I saw that. But it didn't help much.

If all else fails, I can just post the files and Daniel or someone else who knows how to create packages can like, package it up XD

i recommend just pulling apart other ppl packages. learn alot faster that way.

SMFShops package is pretty good, covers most things, also g2+smf package is very nice to looks at as well.
Title: Re: Making Packages?
Post by: Basil Beard on February 25, 2007, 11:16:06 am
Yeah. I guess I should try that. One question I did have was the id numbers I see on files... its late... I just got back and don't really feel like loading up everything right now, but all the items will have like shop-inventory.php (idstuff). What should I use for that? Does it matter at all(like, maybe its just stuck there for fun by the coder) or am I supposed to follow some convention there?

Oh yeah, anyone who wants to see the petmod in action can visit forum.nomicville.com. Hopefully i'll be able to release a package in the next few days.
Title: Re: Making Packages?
Post by: feeble on February 25, 2007, 12:29:07 pm
im really not sure what you are refering to, maybe daniel15 would know.

but are you just refering to how SMFShop stores members item purchases/their inventory in shop_inventory table, if so

basically it stores the ownerid(who owns the item) and itemid(id refering to table shop_items(which hows info on how the item work, information etc) and trading info.

Quote
Oh yeah, anyone who wants to see the petmod in action can visit forum.nomicville.com. Hopefully i'll be able to release a package in the next few days.
went to this website but couldnt find any info on the pet mod.
Title: Re: Making Packages?
Post by: TechnoDragon on February 25, 2007, 01:35:28 pm
Actually, I could help you Basil Beard...I have gotten very proficient at making packages...mostly by just doing what was previously suggested...pulling apart other packages...but I would still love to help you either way!
Title: Re: Making Packages?
Post by: Daniel15 on February 25, 2007, 05:14:45 pm
If you need any help packaging it up, just ask :).
The best way to learn is by pulling apart other packages, and also looking at the samples in the Package SDK.

Quote
Yeah. I guess I should try that. One question I did have was the id numbers I see on files... its late... I just got back and don't really feel like loading up everything right now, but all the items will have like shop-inventory.php (idstuff)
You mean this?
Quote
$Id:: Shop.php 79 2007-01-18 08:26:55Z daniel15                               $
It's automatically inserted by Subversion (source control system I use). The format of the ID is:
$Id: <file name> <revision> <date> <time> <author>$
The revision numbers correspond to those at http://server.daniel15.com/cgi-bin/viewvc.cgi/smfshop/trunk/ (this is a subversion web interface). It's there to help me (so I know which revision of the file I have), and to help beta testers (so they know exactly which version of the file they have).
Again, these are inserted and updated automatically, if you're not using Subversion, don't worry about it ;)
Title: Re: Making Packages?
Post by: Basil Beard on February 26, 2007, 01:16:21 am
im really not sure what you are refering to, maybe daniel15 would know.

but are you just refering to how SMFShop stores members item purchases/their inventory in shop_inventory table, if so

basically it stores the ownerid(who owns the item) and itemid(id refering to table shop_items(which hows info on how the item work, information etc) and trading info.

Quote
Oh yeah, anyone who wants to see the petmod in action can visit forum.nomicville.com. Hopefully i'll be able to release a package in the next few days.
went to this website but couldnt find any info on the pet mod.

Its in the shop. Go there and you can see a pet hatchery. You cant actually buy pets though, cause I made them cost alot :angel: You can also view my pets by visiting my(Clucky's) profile.

Thanks Daniel. I'll try to package it up based on examples of other packages, and let you know if I have any more questions.  O0
Title: Re: Making Packages?
Post by: TechnoDragon on February 26, 2007, 01:22:37 am
Nice mod (just registered) will this work with any version of the shop, or does it HAVE to have the most recent version?
Title: Re: Making Packages?
Post by: Basil Beard on February 26, 2007, 01:28:28 am
I can't say for sure either way. I have not tested in on any version lower than the most recent one, but I see no reason why it *wouldn't* work on such a version.

Anyways, I just realized that I wasn't logged into the SMF community forums when I clicked the package SDK link. So it didn't show me the attachment XD! It should be much easier to make the package now ;-).
Title: Re: Making Packages?
Post by: TechnoDragon on February 26, 2007, 01:30:42 am
well, good luck!  Like i said earlier...if you need help I am willing!
Title: Re: Making Packages?
Post by: GhostWriter on February 26, 2007, 04:53:34 am
I would like to get my hands on this mod. Pets have been something I have heard talk about on other boards. Could I ask one questions, what type of pets did you happen to make?
Title: Re: Making Packages?
Post by: TechnoDragon on February 26, 2007, 05:44:39 am
Go to his site to check them out...though I believe they are more placeholders than anything...
Title: Re: Making Packages?
Post by: Basil Beard on February 26, 2007, 08:29:33 am
Ok. Question. How do I test to see if the package actually works? Should I like, create a second forum with just SMFShop 3.0 and SMF on it? I mean, if I were to try and run the package now, it would all like double up everything. And I really would be surprised if the package works on the first try.
Title: Re: Making Packages?
Post by: TechnoDragon on February 26, 2007, 08:33:46 am
Our illustrious admin has created a tool that you can use to test your packages...

http://server.daniel15.com/smf/package.php

that should help you at least see if it will work...

Title: Re: Making Packages?
Post by: Basil Beard on February 26, 2007, 08:48:49 am
Ah, very nice. *looks in horror at all the errors*

Is there a way to tell where in the code these errors are being generated? Because there are alot of them and I can't find whats causes them.
Title: Re: Making Packages?
Post by: TechnoDragon on February 26, 2007, 08:49:30 am
I could take a look at it for you...if you like...
Title: Re: Making Packages?
Post by: Basil Beard on February 26, 2007, 09:02:22 am
I think I figured out one of the main errors. (I commented out most of the file edits so that I had a smaller section to search for the problem). I'll let you know if I get stuck. I'll also, of course, need a way to test if the package actually does what it is supposed to do.
Title: Re: Making Packages?
Post by: TechnoDragon on February 26, 2007, 09:03:43 am
well, a good first start is to get it to pass daniels package thing...once that is done I can install it on my test forum
Title: Re: Making Packages?
Post by: Basil Beard on February 26, 2007, 09:13:50 am
Ok. It has now passed Daniel's package thing. (Two errors. One time I ended the whole CDATA tag stuff with one ] instead of two. The other time I forgot a quote after my search position="after").

I'll upload the package and get you the link for the download. Keep in my this is a few steps away from the final release(for example, the food items are not coded yet). Also, assuming it doesn't work(which it most likely will not) feel free to fix any obvious errors on your own. =)

www.nomicville.com/SMFPets 1.0.zip

That should give you the package.
Title: Re: Making Packages?
Post by: xfollowthereaperx on February 26, 2007, 11:31:17 am
Ok. It has now passed Daniel's package thing. (Two errors. One time I ended the whole CDATA tag stuff with one ] instead of two. The other time I forgot a quote after my search position="after").

I'll upload the package and get you the link for the download. Keep in my this is a few steps away from the final release(for example, the food items are not coded yet). Also, assuming it doesn't work(which it most likely will not) feel free to fix any obvious errors on your own. =)

www.nomicville.com/SMFPets 1.0.zip

That should give you the package.
I hope these are your fault because I don't wanna fix them  :'(

1.     Execute Code     installScript.php     
2.    Extract Tree    ./Sources/shop/pets_breeds    
3.    Extract Tree    ./Sources/shop/pet_images    
4.    Extract File    ./Sources/shop/Shop-Pets.php    
5.    Extract File    ./Sources/shop/pet_engine.php    
6.    Execute Modification    ./Sources/ManagePermissions.php    Test failed
7.    Execute Modification    ./Themes/default/Profile.template.php    Test failed
8.    Execute Modification    ./Themes/default/languages/ManagePermissions.english.php    Test failed
9.    Execute Modification    ./Themes/default/languages/Shop.english.php    Test successful
10.    Execute Modification    ./Themes/default/Shop.template.php    Test failed
11.    Execute Modification    ./Sources/shop/Shop.php    Test failed
12.    Execute Modification    ./Sources/shop/Shop-Subs.php    Test failed
13.    Execute Modification    ./Sources/Profile.php    Test failed
Title: Re: Making Packages?
Post by: Basil Beard on February 26, 2007, 11:45:37 am
So 1/8 of them worked? <_<. I probably accidentally changed my code around while trying to fix it =(. I'll see if I can fix it tomorrow.
Title: Re: Making Packages?
Post by: Daniel15 on February 26, 2007, 06:12:04 pm
Quote
Should I like, create a second forum with just SMFShop 3.0 and SMF on it?
Yes, this is the recommended way of testing a package. Your package must work on an unedited (well, except for SMFShop) SMF installation.

Quote
I probably accidentally changed my code around while trying to fix it =(. I'll see if I can fix it tomorrow.
The most likely problem is whitespace - Missing a tab in a <search> section, putting a line break when there is no line break, etc. test_modification.php from the Package SDK is very helpful for tracking down problems like this ;)

I only took a very quick look at your package (don't have very much free time), and I think this may be causing the problem:
Code: [Select]
<search position="after"><![CDATA[
'shop_senditems',
'shop_bank',
// End SMFShop code
]]>
</search>
It should be formatted something like:
Code: [Select]
<search position="after"><![CDATA[
'shop_senditems',
'shop_bank',
// End SMFShop code
]]></search>

The stuff outside the <![CDATA[ .... ]]> is still counted in the <search>. So, in this case, it's looking for that text folowed by two line breaks. You'll need to put the </search> straight after the ]]>.

Oh, and you may find WinMerge (http://winmerge.org/) handy - Open your edited file, and the same file from a fresh SMF + SMFShop installation. It will show you exactly what has been changed :)
Title: Re: Making Packages?
Post by: Basil Beard on February 26, 2007, 10:49:13 pm
Ok. I see yeah, I changed tabs and stuff around to make it easier to debug. Oops =P. It shouldn't be too hard to fix though... I hope. Thanks =)
Title: Re: Making Packages?
Post by: TechnoDragon on February 27, 2007, 04:04:47 am
Ok, I have begun attempting to integrate this into a 2.3 version of the shop (3.0 will not install no matter what I do) but I am getting some errors regarding some of the functions in the pet mod....mainly is that it keeps telling me undefinied function BLAH assumed  BLAH and they are related to the if (!class_exists( parts of the files...there are others, but these seem to be the most annoying...
Title: Re: Making Packages?
Post by: Basil Beard on February 27, 2007, 04:51:19 am
One problem could be the difference between php 4 and php 5. I think some of my classes could require php 5. I really didn't even consider this while writing it... *hopes this isnt the case*

Anyways, I have updated my code, making sure everything is like, searchable---but it still doesn't seem to work. How does the CDATA thing work?

If my code says
Code: [Select]
APPLE


And I want to make it say

Code: [Select]
APPLE

BANANA

I should use
Code: [Select]
<operation>
<search position="before"><![CDATA[APPLE
]]>
</search>
<add><![CDATA[BANANA]]>
</add>
</operation>

Right?

(I have done this, and double checked that I can like, find the search values manually---but still I get an error for each modification when trying to upload the package.)
(I have also uploaded the new zip file, not many changes but enough that if someone wants to figgure out what I am doing wrong, they should have the newest stuff).

----

Anyways, the if_class_exists function is used to prevent class duplication(which will cause errors, I think). So if you want to get around it... thats what it needs to do. =)
Title: Re: Making Packages?
Post by: TechnoDragon on February 27, 2007, 05:00:17 am
ok, figured out what the error for the class_exists issue (was missing ' ' around the class name) now I get this error when I go to buy a pet

parse error, unexpected T_STRING in /BLAH/BLAH/BLAH/Sources/shop/Shop-Pets.php(175) : eval()'d code on line 2

which is this line:
Code: [Select]
if (eval($code) !== FALSE) {

Any ideas?
Title: Re: Making Packages?
Post by: Basil Beard on February 27, 2007, 05:11:37 am
Looks like part of the code I copied from Daniel. Actually, unexpected T_STRING probably means there is a dumb error(lack of semicolon, missing quote or bracket...) because it worked fine for me, it probably got broken while packaging it. I'll look into after I find out why the installscript wont work. (I got the package to install, sans the install script =P)

And I can't spell unsigned. hehe. Now to see why other stuff are not working  :idiot2:

o_0. Like, it worked for me. I adopted pets. And now its not working for me at all  :buck2: I am doing the exact same thing daniel did in his admin code, and it still isn't working.

AHHAH! I figured it out! Dern whitespace! One sec, should be fixed and soon as I brushup on preg_replace.

Eh... the more I think about it, I think I did the same thing more than once and I am too lazy to fix my code right now. So for now, the solution will be: No breed names with whitespace  :knuppel2:
Title: Re: Making Packages?
Post by: Basil Beard on February 27, 2007, 06:05:00 am
Ok. New problem. Txt isn't loading right. It appears that profile.php won't load shop.english.php

Is there any easier way to do that than to move all the needed txt lines into profile.english.php?
Title: Re: Making Packages?
Post by: TechnoDragon on February 27, 2007, 06:30:30 am
Ahhh, so the error is caused by whitespace in the breed name?

EDIT:

OK, great news!  after correcting all of the erros i could find and a few tweaks here and there I have sucessfully integrated this into shop version 2.3!  Now about those food and cage items...

Oh, and how do I create additional skills for the pets?

EDIT EDIT:

Ok, nevermind, figured that part out, and OOOOOHHHHH am I going to have fun with this!

EDITEDITEDIT:

Yes there is basil...use this right above the lines you want to use the shop language file:
loadLanguage('Shop');
Title: Re: Making Packages?
Post by: Basil Beard on February 27, 2007, 10:45:42 am
Ok. Awesome thanks.

Food and cage are easy to code, I just havn't done it yet.

Basically, food should increase the hunger and happy by values(ones hopefully set by the admin). Users, on use, will be asked which pet they want to feed.

Cage will increase the maxpets value in the member database by one. It will include a preset "Maxmaxpets" which puts a maximum on the number of maxpets(so like, say you want a user to have no more than three pets but start with one pet. You set maxmaxpets at three for the cage item. Or, if you want each pet to cost progressivly more, you make multiple cages each with a higher maxmaxpets value).

My plan is to finish coding these items, add the loadLanguage line, and release the 0.0 version tonight. I'll then keep it here for a couple of months as people find any holes in it and I make it easier to add and manage pets. Once that is all done, I'll submit the 1.0 version to the official smf mods website.

Also keep in mind that I will probably, for ease of use, remain with SMF Shop 3.0 and SMF 1.1.2 for the time being, unless any large updates are released, simply because I really don't want to manage multiple updates nor trying to fix it so that it works with the newer update. I mean, once it is at a more done stage I can update it, but I probably won't before then. =)

Anyways, I'll hopefully be creating an actual topic for it later tonight =) 

Edit: Oops. I forgot to replace the uninstallscript. Thus I just cleared all my shop databases. I can't uninstall smfshop because it can't delete the databases, and I can't uninstall smfshop pets for the same reason. I aslo cannot reinstall either. This is why you use a test forum, XD. Meebee have it fixed now.
Title: Re: Making Packages?
Post by: TechnoDragon on February 27, 2007, 12:02:06 pm
Ahhh, so I could basically translate say the increasekarma item to do what you suggest...so yes that would be easy...one suggestion I may add...to put an admin panel in the shops area (or even one of your own) so that the admin can change settings theough there without having to edit the databse...  use the $modSettings concept...love the mod though...now that i have it on my ancient smfshop version it is truely a great shop mod!

EDIT

Ok I have created several items for the pets...let me know what you think!

EDIT EDIT

Found a typo and modified the cage item to have a max allowed....

updated attachment
Title: Re: Making Packages?
Post by: Basil Beard on February 27, 2007, 12:26:00 pm
Awesome. You do know that curap gets reset each day, right?

Anyways, I would like to direct you all here:
http://www.daniel15.com/forum/index.php/topic,642.0.html

Have fun everyone.

Oh, and one last thing. Whitespace is allowed in breednames afterall(just not in filenames). It turns out it was another bug causing this error =D
Title: Re: Making Packages?
Post by: TechnoDragon on February 27, 2007, 12:26:57 pm
Where does that get done at? (the reset)
Title: Re: Making Packages?
Post by: Basil Beard on February 27, 2007, 12:36:05 pm
Code is found in shop-subs.php, because that is where code like that goes. it gets called in shop.php. Please note that it will only work if someone visits your shop that day. I didn't want to do a cron job, because I know some people cannot use them, and I dislike they anyways. But yeah, if no one visits any shop files on a given day, pets will not age and hunger/happiness will not decrease. This will be one of the first things I look to fix. Shouldn't be too hard, just the new years will be annyoying.
Title: Re: Making Packages?
Post by: TechnoDragon on February 27, 2007, 12:43:24 pm
thing is, depending on what kind of "actions" you give skills, that item could still come in handy...at least my concept of what I plan on doing with the pets...
Title: Re: Making Packages?
Post by: Alexander on March 03, 2007, 06:17:03 am
TechnoDragon, the pet items you made are pretty cool, but it affects all the pets the owner has instead of just one.
Title: Re: Making Packages?
Post by: TechnoDragon on March 03, 2007, 06:26:46 am
hmmm, I hadn't tested that yet (only have one pet myself...let me take a look at it and see if i can fix that

EDIT:

Ok, updated the pet items to allow the member to select whic pet to use it on attached to this post (note, in the future you can always pick up the most recent pet items at my forum in my downloads section.)
Title: Re: Making Packages?
Post by: Basil Beard on March 11, 2007, 08:34:25 am
What do I need to do different for updates? Like, I am working on an update for the petmod, but when I try to install it, I get a blank screen. =(
Title: Re: Making Packages?
Post by: TechnoDragon on March 11, 2007, 09:32:32 am
basically only package up the update, then apply it...that should work.
Title: Re: Making Packages?
Post by: Basil Beard on March 11, 2007, 09:56:41 am
I did. Its very strange. Should the XML file for the update be any different.
Title: Re: Making Packages?
Post by: Daniel15 on March 11, 2007, 11:06:08 am
Quote
(note, in the future you can always pick up the most recent pet items at my forum in my downloads section.)
/me points to http://dev.dansoftaustralia.net/projects/smfpets/
Sign up on dev.dansoftaustralia.net, and get Basil Beard to add you as a developer of SMFPets. Then, you can upload all your items there (into a seperate 'package') :D

Quote
What do I need to do different for updates? Like, I am working on an update for the petmod, but when I try to install it, I get a blank screen. =(
You can do what I do with SMFShop (update package), although it's not recommended (I have my reasons for doing it ;)).
In the package itself, add an <upgrade> section. Something like:
Code: [Select]
<!-- Upgrade from version 1.0 -->
<upgrade from="1.0">
<readme>upgrade_1-0_1-1-readme.txt</readme>
<modification format="xml" type="file">upgrade_1-0_1-1.xml</modification>
<code>upgrade_1-0_1-1.php</code>
</upgrade>
would be fine. Basically, add a <require-file> line for each changed file, put all the modifications needed into a seperate .xml file, and all the database changes needed into a seperate .php file.
Title: Re: Making Packages?
Post by: Basil Beard on March 12, 2007, 05:47:19 am
Yeah. I copied it based on yours. Yet I still get a blank screen when clicking the "apply link"

Your sever thing for like, testing packages doesn't appear to be on line. Maybe I made a dumb error and trying that(when it is back) will help figgure out what is up.
Title: Re: Making Packages?
Post by: Daniel15 on March 30, 2007, 07:33:18 pm
Basil Beard, I guess you got this sorted out eventually?