Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

FPSC Classic Scripts / Store Scripts - Share and Talk About

Author
Message
Flatlander
FPSC Tool Maker
17
Years of Service
User Offline
Joined: 22nd Jan 2007
Location: The Flatlands
Posted: 25th Apr 2008 08:20
I hope I am not being presumptuous but thought I would start this thread so there won't be a bunch all over the place. It would be nice to keep it in one thread. Of course if it gets to big, it will be difficult for everyone to navigate.

I have been working on some scripts and temporary huds for the scripts. It's the huds that are somewhat time consuming but I pretty much have GIMP down pat for them. Also, I will not be posting any scripts unless they actually work. No WIP's for me in here at least. However, if anybody has any ideas before testing them out I would be glad to test your idea.

If what I have scripted so far works, it is not has cumbersome as I thought it might be. However, if it doesn't work (which so often happens) then I will have to rethink the algorithm.

I don't know about the rest of you but I'm having fun.
Flatlander
FPSC Tool Maker
17
Years of Service
User Offline
Joined: 22nd Jan 2007
Location: The Flatlands
Posted: 25th Apr 2008 10:40 Edited at: 25th Apr 2008 17:10
OK, I am retired so I have a lot of time on my hands and I love programming, so here is a script for earning or retrieving money. Before I show the code, however, I want to explain that there is a lot of time involved in doing this, time that I have but not everybody does.

The first thing I did was create a bunch of huds to show. I decided to have this increment of money huds: 10+,20+,30+,40+,50+,100+,200+,300+,400+,500+,600+,700+,800+,900+,1000+

I created two scripts so far collecting money but will only show you one as they are all very similar. Here is the first one:

================================================


This does work. I will show some screenies as soon as I take some pics. I would prefer you to try and figure out how this was done, rather than my explaining it here. Of course, we need to add more lines to take care of the amounts through 1000 Kyats. That's what I am calling them each unit. This picks up 10 Kyats. I have another script that picks up 100.
Flatlander
FPSC Tool Maker
17
Years of Service
User Offline
Joined: 22nd Jan 2007
Location: The Flatlands
Posted: 25th Apr 2008 10:47
Here are the screenies. The first one is a prompt to pick up 10 Kyats.

Attachments

Login to view attachments
Flatlander
FPSC Tool Maker
17
Years of Service
User Offline
Joined: 22nd Jan 2007
Location: The Flatlands
Posted: 25th Apr 2008 10:49
This second one shows that the gold bar is gone and it shows the amount we now have. I have the plus right now in case I want to utilize 5 Kyats. Everything 50 and under is in red. Over 50 is in white.

Attachments

Login to view attachments
Flatlander
FPSC Tool Maker
17
Years of Service
User Offline
Joined: 22nd Jan 2007
Location: The Flatlands
Posted: 25th Apr 2008 10:51
I have 20 more Kyats to pick up and then there is 100 Kyats. With this one you will see the prompt to pick up the 100 Kyats and the 30+ that we already have.

Attachments

Login to view attachments
Flatlander
FPSC Tool Maker
17
Years of Service
User Offline
Joined: 22nd Jan 2007
Location: The Flatlands
Posted: 25th Apr 2008 10:53 Edited at: 25th Apr 2008 10:56
We pick up this gold bar and we now have added another 100 which is actually 130. However, the hud shown is 100+ One has to decide on the increments. The more increments the more time it will take to create the huds and more lines of code there will be. It is just a decision we have to make. I'm not even sure what I will do yet.

The next script will be the buy script. Although I'm not sure if I need to show it. It is virtually the same except for using "incvar" we would use "decvar" And of course we will have different huds. So for now I will let others interact with this thread. Hopefully there are some variations to this algorithm. But I can't think of any right now.

Each item to be picked up has to have its own script and each item you sell will have to have its own script.

Attachments

Login to view attachments
Toasty Fresh
17
Years of Service
User Offline
Joined: 10th Jun 2007
Location: In my office, making poly-eating models.
Posted: 25th Apr 2008 11:48
This is very generous of you, F l a t l a n d e r. With the buy script, will you be able to buy weapons?

Flatlander
FPSC Tool Maker
17
Years of Service
User Offline
Joined: 22nd Jan 2007
Location: The Flatlands
Posted: 25th Apr 2008 15:04
Yes, I'll show you how. One of the things I forgot to mention with the buy script is that we need to make sure that the player has enough money to buy whatever it is he wants but that's no problem.
Toasty Fresh
17
Years of Service
User Offline
Joined: 10th Jun 2007
Location: In my office, making poly-eating models.
Posted: 25th Apr 2008 15:57
Great! Can't wait.

xplosys
18
Years of Service
User Offline
Joined: 5th Jan 2006
Playing: FPSC Multiplayer Games
Posted: 25th Apr 2008 16:32 Edited at: 25th Apr 2008 16:34
FL,

Very well done. This is what I had in mind and did something similar for the store that used health to buy weapons. This is easier, *doesn't have to use the health value, and many variations can and will be created from this.

To others who would use these scripts:
Due to the way the script is displayed in the Code Snippet, the locations of files is often not displayed correctly. Many times the back slash does not get displayed, and you must remember to add them back in.

For example, "plrsound=audiobankmiscping.wav" is missing the back slash between audiobank and miscping.wav.

I just don't want a lot of "The script don't work!" responses. If you really read the script and follow what it is doing, you will see these things and have no problem. As FL said, this is one example and you should use it to see how the work is done, then make your own the way you want it.

Thanks for showing us some of the possibilities FL. I know you're retired, but your time and effort here is appreciated.

Best.

Flatlander
FPSC Tool Maker
17
Years of Service
User Offline
Joined: 22nd Jan 2007
Location: The Flatlands
Posted: 25th Apr 2008 17:16 Edited at: 25th Apr 2008 17:17
Thanks xplosys for that bit of information. I guess I just assumed people would know about the fact these are my names -- after all these years I have not learned you can't assume everything.

I think I kind of have a handle on what's going on with the code snippet. The first time you put in the backslashes it will be ok. But if you edit your post, then for some reason it will take out the backslashes when it places them into the edit window. So, if you edit the post you need to put in all of the backslashes again. They are in there now. Another one of those pain in the tush situations. I'll try to remember that if I have to edit the post again.
Plystire
21
Years of Service
User Offline
Joined: 18th Feb 2003
Location: Staring into the digital ether
Posted: 25th Apr 2008 18:29
Looking good Flatlander!

Keep at it and soon you'll have a mini-mall in here.


The one and only,
~PlystirE~

Flatlander
FPSC Tool Maker
17
Years of Service
User Offline
Joined: 22nd Jan 2007
Location: The Flatlands
Posted: 25th Apr 2008 19:54
Quote: "Keep at it and soon you'll have a mini-mall in here. "




Here is the code to buy items. The screenies will show that I am purchasing weapons. I made a couple of new huds and had to modify the earn money. This actually is for any type of item or entity. If the entity is not a weapon then you need to be sure that the entity is set to dynamic. Weapons are already dynamic. All you need to do is place the buy script in the main AI of the entity.



I quickly tested this and it seems to be working. If there are any question feel free to ask or if you are having problems. However take into consideration what xplosys had said. Screenies after I eat lunch.
Flatlander
FPSC Tool Maker
17
Years of Service
User Offline
Joined: 22nd Jan 2007
Location: The Flatlands
Posted: 25th Apr 2008 21:10 Edited at: 25th Apr 2008 21:14
Here are the screenies. Be sure and click on the thumbnails to see a much larger image.

This is how I had scripted it. Of course it can be modified anyway you choose. The first screenie asks if we want to make a purchase.



The next screenie lets the player know how much it costs. Of course the player will know if he has enough money. Here you see he has no money. He can either leave which will get rid of the prompt or press enter to purchase.



If the player presses the enter key when he doesn't have enough money he will see this.



So, he has to go off and try to find or earn some money. When he finds enough he comes back and purchases the weapon (item). On this next screenie notice the 100+.



He had earned 130 Kyats and the last screenie shows how much he has left and the weapon is now in his hands.

Plystire
21
Years of Service
User Offline
Joined: 18th Feb 2003
Location: Staring into the digital ether
Posted: 25th Apr 2008 22:04
Hmmm, can you attach that script to multiple guns for purchase? I notice taht you are loading in the huds each time and each script handles the display of remaining currency.

Also, for state 200, wouldn't it be better to destroy the script and not have them accumulating?


It looks good and best of all, it's functional.


The one and only,
~PlystirE~

Flatlander
FPSC Tool Maker
17
Years of Service
User Offline
Joined: 22nd Jan 2007
Location: The Flatlands
Posted: 25th Apr 2008 22:24 Edited at: 25th Apr 2008 22:25
Plystire, this is a generic script in the sense that I just wanted to let people know that the huds need to be loaded. This is not supposed to be a working script for a real level. When someone uses this they should modify to their way of doing things such as making sure that all huds have a unique name and loading them one time for that level. Not everyone even knows that they can do this.

I still am not familiar enough with all of the condtions/actions. I am not sure how one would destroy a script. I know you destroy and entiy with the action "destroy". I have noticed most of Lee's scripts end with "rundecal=5" Does this destroy the script? After thinking about it "none" would probably not. Just would sit there and not do anything. So, need some help with, eh?

The multiple guns question, do you mean buy multiple guns in one transaction?

Everyone, Ply's been very polite and not mentioned his mod (so I'll do it for him) which uses a normal hud method just like the lives/health/ammo huds. All it needs is one variable and a one or two line (can't remember) bit of code to update the hud and you don't have to worry about all those huds. He probably has a very easy way to buy multiple guns in one purchase as well. I think we might be able to do it with v1.09 but will have to think about it.
Plystire
21
Years of Service
User Offline
Joined: 18th Feb 2003
Location: Staring into the digital ether
Posted: 25th Apr 2008 23:05 Edited at: 25th Apr 2008 23:07
To be honest, I'm not sure what some of the scripts are actually doing when they "rundecal". In all common sense, one would think that they are... well, running a decal. They usually each incorporate some sort of HUD, though. I've never used that command, and so i don't see a use for it.

You can destroy a script with "destroy" just like you said. This should prevent the engine from ever looking at the script (for that particular entity) for the rest of the level, thus saving it some processing time in checking all those conditions.

No, I wasn't referring to buying more than one weapon in a single transaction, I meant like giving lots of gun entities this script. So the player can wander around and look at all the different guns, and choose which one they want to buy. I wasn't sure if you had tested that yet.


As for how I purchase guns using my Mod... nothing would be different (except the shop that I'm using incorporates a GUI menu to buy stuff using the cursor, and that would require my mod). All I do is create a bunch of gun entities around the shopkeeper (character entity on which I attach the shop script) and set them to spawn on activation. Then when the user makes his selection in the shop, I spawn the desired gun entity by doing a "settargetname,activatetarget" combo. I also altered each "shoppable" gun entities script, to make it so that the user won't have to move over it in order to pick it up (Just remove the check for player distance in the pickup script). That way, as soon as they buy the gun, they'll pick it up.

I'm sure you can do it that way with V109 as well. The settargetname action should still be in there.


The one and only,
~PlystirE~

puppyofkosh
17
Years of Service
User Offline
Joined: 9th Jan 2007
Location:
Posted: 26th Apr 2008 01:04
This looks excellent. Nice work Flatlander!

Toasty Fresh
17
Years of Service
User Offline
Joined: 10th Jun 2007
Location: In my office, making poly-eating models.
Posted: 26th Apr 2008 02:39 Edited at: 26th Apr 2008 03:05
This looks really good, Flatlander. I'll DL later when i'm done playing MechQuest.

EDIT: It's not working for me. I have not made any HUDs for them yet, but the problem is that when I go to pick up the money, it just acts as a normal entity in that you can push it around. What am I doing wrong?

Flatlander
FPSC Tool Maker
17
Years of Service
User Offline
Joined: 22nd Jan 2007
Location: The Flatlands
Posted: 26th Apr 2008 05:13 Edited at: 27th Apr 2008 08:15
I have it scripted to use the huds along with the player having to press the ENTER key at certain times. The huds are an indicator for when to press the ENTER key. I just got home so let me look at what I can do so you can just use the script out of the box.
Toasty Fresh
17
Years of Service
User Offline
Joined: 10th Jun 2007
Location: In my office, making poly-eating models.
Posted: 26th Apr 2008 06:09
Oh. I forgot to press enter! Whoopsies.

Flatlander
FPSC Tool Maker
17
Years of Service
User Offline
Joined: 22nd Jan 2007
Location: The Flatlands
Posted: 26th Apr 2008 12:04 Edited at: 26th Apr 2008 15:27
Plystire

Quote: "like giving lots of gun entities this script. So the player can wander around and look at all the different guns, and choose which one they want to buy"


Finally got my head wrapped around this. I don't believe The script provided will do that. will have to modify it. Sounds like a cool idea and will test it. Seems like it should work.

Addendum #1:

Ply, you are so subtle, maybe even devious.

I still think I can possibly get this to work. But if I were using Ply's mod it would be sooooooo easy. An example of what I mean:

We cannot assign variables to variables. In other words we cannot do this.

========================

;G10 = money
;G5-9 = weapons

:state=1:globalvar=5,setvar=10,globalvar=10
:state=10:decvar=globalvar=5,state=20

I actually wouldn't set variable 5 to 10 here but I would use whatever value is in variable 5. I was just testing it to see if it would actually work and I knew it wouldn't but tried.

=======================

Nor can we do any arithmetic on varialbes except to increment and decrement them using real values. So we have to come up with other ways to do this that fits within the scripting parameters.

;G10 = money
;G5-9 = weapons
;G5 = 10 if weapon selected
;G6 = 20 if weapon selected, and so on - we need to keep track of that

:state=1:globalvar=5
:state=1,vargreater=0:globalvar=10,decvar=10

we know that G5 has the value 10 if it is greater than 0 ; we could also do it this way

:state=1:globalvar=5
:state=1,varequal=10:globalvar=10,decvar=10

I believe we can do this with each of the variables as they were assigned to contain the cost of the weapon. We have to keep good track of all our variables; can you imagine if we use a 100 of them.

Each of G5-G9 will be assigned a value larger than 0 when the player selects the weapon.

I have not tested this out yet but will now. Also, we have to come up with a way to select the weapons because we don't have the GUI available to us. I think I have one way figured out. I was hoping to possibly have a hud selection and then using scancodekeypressed to determine the selected weapon. However, we would need a lot of huds to reflect the selection process.

Addendum #2

Here is my working script to select a weapon among four weapons. After all weapons have been selected then you would go to the clerk (thug in this case) and purchase all of the weapons you had selected. I have not scripted that yet. Also you will notice that a seperate script needs to be created for each of the weapons since we have to assign a certain amount to a certain global variable.



I assign this script to the weapon or ammo that you want to have in the store and you will have a duplicate weapon/ammo that will not be spawned until purchase. The weapon selected will be destroyed to indicate you had selected it. You cannot select it if there is not enough money.

My first example script is much easier to deal with. You can still have a "clerk" and interact with him. You just purchase each object one at a time.
xplosys
18
Years of Service
User Offline
Joined: 5th Jan 2006
Playing: FPSC Multiplayer Games
Posted: 26th Apr 2008 16:20 Edited at: 26th Apr 2008 16:25
Let me see if I can see this in my head. Each weapon has a value assigned to it in it's script. Var 1 or G1, G1 being the variable for money.


Obviously some things left out, but you should be able to make a custom script, where you just change the weapon value for each weapon or item..

Best.

Flatlander
FPSC Tool Maker
17
Years of Service
User Offline
Joined: 22nd Jan 2007
Location: The Flatlands
Posted: 26th Apr 2008 17:02
Sorry to ignore you xplosys but I am concentrating on a suggestion given by Plystire and believe me it is a doozy trying to code it without his mod.

The purpose of this post is that although my last code snippet works it could easily cause a logical error. I'll try to explain it.

Let's take a look at the script for a second weapon that works but using it along with the other script could cause a problem.



We have two weapons in the store. One costs 10 Kyats and the other costs 20 Kyats. Before we get to the store we pickup 20 Kyats. So far so good. We have a value of 20 in the globalvar #10. Now we go to the store and we see the rifle for only 20 Kyats. Oh, we have enough, so we select it. The code checks the money variable and sees we have 20 Kyats available. OK so it lets us select it. No problem. Then we see the pistol for 10 Kyats. Ok so we forget that we already spent our 20 Kyats and therefore, we select the pistol for 10 Kyats. Here is the problem. The code checks the money variable and it still sees that there is a value of 20 so it allows us to select it. Now we go and purchase the selected weapons. But it will decrement the value by 20+10=30 and now we will have a value of -10 in the money variable. Not good.

How do we correct for that? Well, probably by simply subtracting the amounts at the time of selection. My first instinct was to code the clerk to do the subtracting at the time of purchase because that is the normal real-life way of doing it. However, that really isn't necessary as all we need to do is spawn the correct weapon that was selected and the code will run for the player to pick up the weapons regardless of the distance he is from them.

One of the possibilities I was thinking about was to allow the player to put back a weapon and that way we wouldn't have had to worry about the money already being subtracted.

I'm doing all of this just to show you what I am going through in trying to come up with script for these different scenarios. When script is not flexible it can take a much longer time to code. Look at how long this is taking me.

@Goth If your still around and see this, it has been way more than 30 minutes.

@xpolsys As I was sitting here typing away all of this stuff, I kept looing at your little guy with his blinking eyes peeking up out of the man-hole cover.
Plystire
21
Years of Service
User Offline
Joined: 18th Feb 2003
Location: Staring into the digital ether
Posted: 26th Apr 2008 23:59
Quote: "Ply, you are so subtle, maybe even devious."


My girlfriend tells me the same thing.
Meheeheeheeheeheeeeeee


The situation you are encountering is also one of the reasons I vouched for a GUI shopping interface with a guy behind the counter. The player selects all the weapons in the same script and then, all the logical operations won't be strewn out across so many different scripts.


@xplosys:

Logical error detected within your script, please read the following:

Situation at hand - Player walks up to one item and sees the price of it (Script enters state 1), decides not to buy it, then walks over to another item and sees the price of it (That script enters state 1), the player again decides not to buy it. He does this for all the weapons at the shop, thus making it so that ALL the scripts are in state 1. Once that happens, not only are all of the HUDs being displayed, but once he presses Enter, it will purchase the FIRST scripts item that he can pay for and not necessarily the one that they were standing in front of.




The one and only,
~PlystirE~

Flatlander
FPSC Tool Maker
17
Years of Service
User Offline
Joined: 22nd Jan 2007
Location: The Flatlands
Posted: 27th Apr 2008 08:18 Edited at: 27th Apr 2008 08:18
You can download all of the huds, scripts and fpm file for my first example (scenario) by clicking on the download button. It is a zip file.

Attachments

Login to view attachments
Flatlander
FPSC Tool Maker
17
Years of Service
User Offline
Joined: 22nd Jan 2007
Location: The Flatlands
Posted: 27th Apr 2008 10:36
This example or scenario is when we have store-keeper or clerk. For my test I have two weapons a colt45 and an mas36. The pistol is 10 Kyats and the mas36 is 20 Kyats. For this example I use a script for each weapon. I am going to look at this more closely to see if I can't get something that would work in just one script for multiple items. But I wanted to at least get the code of this down. The first code snippet is for the 45 and the second is for the rifle.





We are able to select which weapons we want and the script will be able to determine if there is enough money for the selected item(s). Once the player selects the items he must go to the store-keeper and actually make the purchase. Once he makes the purchase the player will receive all of the items -- in this case weapons -- he has purchased. Here is the "clerk" code snippet.




Now, there is a lot that can be done with this. There can be more interaction with the clerk for example.

Screenies will follow and I will then follow that up with a download of all the huds and such for this example.
Plystire
21
Years of Service
User Offline
Joined: 18th Feb 2003
Location: Staring into the digital ether
Posted: 27th Apr 2008 12:11
Wow, that's a lot of code.


One question, though: What if they only buy the Colt45? Does the shopkeeper only say "Thanks" for making a big purchase?

Also, wouldn't it be easier to have a seperate entity handle what HUD gets shown for your current amount of money? Make it some invisible entity that's always active and always checks how much money you have, and then shows the correct HUD for it? Then you won't need to juggle the currency HUD code between different scripts.


It's coming along great, Flatlander. Good work so far, keep it up!


The one and only,
~PlystirE~

Flatlander
FPSC Tool Maker
17
Years of Service
User Offline
Joined: 22nd Jan 2007
Location: The Flatlands
Posted: 27th Apr 2008 16:54
Yes, Plystire it is a lot of code. But because it is all so elementary, I'll let other's modify to their hearts content.

BTW,when I code, I usually have flow charts going. I don't in this case. My goal here was to first get some working code done and an algorithm that will solve the problem as described by the client. In this case the client was Plystire. After I first initially get "working" code, I start to look at it to determine if there is a way to improve on it. Especially in terms of creating less and more efficient code. Because FPSC script is so limited by nature, one has to come up with more ingenious ways to work things out. Plystire has some interesting thoughts along this line. However, I am not going to take the time at this point to kick those ideas around in actual code. I'll let others do that. I have other projects I have to get back to and finish up. However, before I leave this thread, I will still post some screenies and the download. I will look in now and again to see if there are any specific questions regarding the code itself.

Thanks again for contributing, Plystire. I hope some other's will be able to contribute along these lines.

Quote: "One question, though: What if they only buy the Colt45? Does the shopkeeper only say "Thanks" for making a big purchase?"


Since I have kept track of what has been purchased in this code by having the global variable, say G5, either true or false (remember I set the value of G5 to 0 at the beginning and when it was selected it was changed to 1) then you can have the shopkeeper say anything you want him to based on what was purchased or how much was purchased.
Flatlander
FPSC Tool Maker
17
Years of Service
User Offline
Joined: 22nd Jan 2007
Location: The Flatlands
Posted: 27th Apr 2008 17:58 Edited at: 27th Apr 2008 20:00
Instead of including screenies, here is the download of the huds, scripts and the map file for the storekeeper script.

Attachments

Login to view attachments
xplosys
18
Years of Service
User Offline
Joined: 5th Jan 2006
Playing: FPSC Multiplayer Games
Posted: 27th Apr 2008 19:32
Ply,

Yes I know. As I said, I left a lot out. Adding plrdistwithin to reset the state would fix the problem, just as I did with the health shopping script. It will work, just as the other did, though it may be going the long way around. I'm sure there is a cleaner way to do it.

I haven't looked into the shop keeper side of it, but it seems so much more complicated.

Best.

Conjured Entertainment
AGK Developer
19
Years of Service
User Offline
Joined: 12th Sep 2005
Location: Nirvana
Posted: 29th Apr 2008 22:59 Edited at: 29th Apr 2008 23:04
Nice work Flatlander.

I finished working the kinks out of my new system only to realize the 0-99 value limit after the fact.
No wonder it wasn't working right with values greater than one hundred.

Now, I am at the point of using 3 of the 5 global variable for my system of Bronze, Silver, and Gold.
Whereas, 100 pieces of bronze = 1 silver, and 100 silvers = 1 gold.

I want my display script to run independent of the store scripts, but it would be called by each of them to refresh the display.
The idea is to display a running balance at all times. (just like lives,ammo,health)
Anyway, I have to start all over now, because I had everything working off one variable thinking it had a higher limit.

To be continued...

Don't forget to visit Conjured Entertainment

Flatlander
FPSC Tool Maker
17
Years of Service
User Offline
Joined: 22nd Jan 2007
Location: The Flatlands
Posted: 30th Apr 2008 00:41 Edited at: 30th Apr 2008 03:31
Hey CE, I've been waiting patiently for your contribution.

Sorry you had the setback. Looking forward to the final outcome. I was also wondering if this thread was going to die an early death.
Maniac Modeler
16
Years of Service
User Offline
Joined: 15th Jan 2008
Location:
Posted: 30th Apr 2008 02:21
Wow I love the idea of having a store in FPSCreator! It opens up so many possibility's! Great work guys!
Conjured Entertainment
AGK Developer
19
Years of Service
User Offline
Joined: 12th Sep 2005
Location: Nirvana
Posted: 30th Apr 2008 03:32 Edited at: 30th Apr 2008 03:54
I ran into another problem but I solved it.
I had too many huds for one script that displayed all three variables.
So, I seperated them and used an infused chain to tie them together.

So far, I have globalvar=1 and globalvar=2 being displayed just like the numeric output for lives, health, and ammo.

I also have created a pickup script that increments as well as trips the next digit.
That means if I have 95 silver and pick up 13, it knows to increment the gold when the silver trips.
You end up with 1 gold and 8 silver just as you should.
All that is working great.

I should be finished tomorrow or the next day.

To be continued...

Don't forget to visit Conjured Entertainment

Attachments

Login to view attachments
Plystire
21
Years of Service
User Offline
Joined: 18th Feb 2003
Location: Staring into the digital ether
Posted: 30th Apr 2008 05:43
Awesome work, Conjured!

I am surprised that Lee would cap a variable like that. I wonder what his reasoning behind that is.


The one and only,
~PlystirE~

Conjured Entertainment
AGK Developer
19
Years of Service
User Offline
Joined: 12th Sep 2005
Location: Nirvana
Posted: 30th Apr 2008 05:55 Edited at: 30th Apr 2008 06:06
Quote: "I am surprised that Lee would cap a variable like that. I wonder what his reasoning behind that is. "


I'm not sure exactly, but I guess there is a good reason.

I plan on using a 3 variable string to create six digits, so our money can be one number capped at 999,999.

Don't forget to visit Conjured Entertainment

Plystire
21
Years of Service
User Offline
Joined: 18th Feb 2003
Location: Staring into the digital ether
Posted: 30th Apr 2008 06:58
Coming from a technical standpoint, it would have made more sense to cap them at 255... meaning that he used a "char" or 8-bit variable system. But no data-type that I've ever heard of is limited to the range 0-99.


The one and only,
~PlystirE~

Flatlander
FPSC Tool Maker
17
Years of Service
User Offline
Joined: 22nd Jan 2007
Location: The Flatlands
Posted: 30th Apr 2008 10:06 Edited at: 30th Apr 2008 11:12
This is what Lee said:

V1.0.9 BETA5 - 25/04/08
-----------------------

* Limit global and local variables between 0 and 99

-----------------------

To me that means that we can now have 100 Global variables. Although I haven't tested this I would say the data type is probably real -- meaning the availability of decimals. However if not then the data type is likely long integer.

I have tested the values that are larger than 100 and they do work for me. Download the store example. You can have up to 130 Kyats.
Plystire
21
Years of Service
User Offline
Joined: 18th Feb 2003
Location: Staring into the digital ether
Posted: 30th Apr 2008 15:02
Good to know Flatlander.

Having experience with the FPSC source, and seeing Lee's style of coding, he probably used an Integer or a Float(Real) for the variables.


The one and only,
~PlystirE~

Conjured Entertainment
AGK Developer
19
Years of Service
User Offline
Joined: 12th Sep 2005
Location: Nirvana
Posted: 30th Apr 2008 16:41 Edited at: 30th Apr 2008 16:45
Quote: "To me that means that we can now have 100 Global variables. "

That is what I thought at first until my scripts only worked up to values of 99.
Now, it seems that the value is limited from 0-99, which means no negative numbers or 3 digit numbers in the variables.

Quote: "Coming from a technical standpoint, it would have made more sense to cap them at 255... meaning that he used a "char" or 8-bit variable system. "

That is what I was thinking but...

Quote: "But no data-type that I've ever heard of is limited to the range 0-99. "

Me either.

Quote: "I have tested the values that are larger than 100 and they do work for me."

That is strange because they are not working for me.
If it will work, then what is the cap on the value?
I wish it would work on this end, and yes I am using beta 5.
I'll try again in case it was just that one script malfunctioning.
I'll try globalvar29 and see if it works.

Don't forget to visit Conjured Entertainment

Flatlander
FPSC Tool Maker
17
Years of Service
User Offline
Joined: 22nd Jan 2007
Location: The Flatlands
Posted: 30th Apr 2008 17:30 Edited at: 30th Apr 2008 17:48
Here is a script that handles minus numbers. A thug robbed me.

;Artificial Intelligence Script

;Header

desc = Thug robs you


;Triggers

:state=0:hudreset,hudx=94,hudy=95,hudimagefine=gamecorehudsStore_Hudsminus_10.png,hudname=minus_10,hudhide=1,hudmake=display,state=1

:state=1,plrdistwithin=90:state=10

:state=10:globalvar=10,decvar=10,state=15

:state=15:globalvar=10,state=20

:state=20,vargreater=-11,varless=0:state=101

:state=101:hudshow=minus_10,state=200

:state=200:destroy

;End of Script

Decided not to put this in code snippet so that I can bold the two important varialbles. However, be sure to always set the current variable with the action globalvar=x before you make any other actions on it or it won't work.

I decvar by 10. The tricky part is testing where the variable is so you can display a hud. vargreater=-11,varless=0

The following images shows that this script works. I want to remind everyone that I do not post a script unless I have thoroughly tested it.



Now you will see thug ran away and a -10 hud on the screen (lower right hand corner).



He left his shadow however.

:ROFL:
Flatlander
FPSC Tool Maker
17
Years of Service
User Offline
Joined: 22nd Jan 2007
Location: The Flatlands
Posted: 30th Apr 2008 17:52
If the variable can accept minus values then I assume that the data type is at least a small integer. (-32,768 through 32,767).

I suppose I can test this. I'm not sure if I will test for decimals. In order for me to test and debug, I need huds to let me know if it has worked. Of course I can use something I already have.
Flatlander
FPSC Tool Maker
17
Years of Service
User Offline
Joined: 22nd Jan 2007
Location: The Flatlands
Posted: 30th Apr 2008 18:28
I have tested the values to 35,000. It works at 35,000 so that is larger than a small integer data type value. Since I have not tested decimal data types we can at least assume a large integer data type. Here is the script and click on the VIEW button for the image.

Attachments

Login to view attachments
Conjured Entertainment
AGK Developer
19
Years of Service
User Offline
Joined: 12th Sep 2005
Location: Nirvana
Posted: 30th Apr 2008 18:36 Edited at: 30th Apr 2008 18:51
Quote: ":state=20,vargreater=-11,varless=0:state=101"

That is wierd because even if a zero is greater than -11 it is not less than itself.
So, it must have been a negative number indeed.


Yeah yeah the high values work for me too, but not when I try to display them.
I think my script is too long or is creating too many huds or something, because it will not work.
I have checked it for logical errors over and over again finding no typos or anything.

I can still get it to work off the 2 global variables using them in a chain, and I have set the display as a single number.
However, my current method is lacking even though it is fully functional.

My next attempt is to split up the huge script like I did the other two except use the one variable.
This time I will use one script to assign the ones and tens, and another script for the hundreds and thousands, and a third script for the tens thousands and hundreds thousands (if they exist).
I want the full display using only one variable if those things are that large.
I'm still going to need two global variables, but that is for all six digits and that will be better than using three.
I need the second global variable as a counter in all three scripts, so I can revert the value back to the first variable.
So I need three scripts, one for every two digits displayed, and a fourth script for the reversion. (unless I can squeeze it in #3)

To be continued...


Quote: ":state=20,vargreater=34999,varless=35001:state=101"

Why not...
:state=20,varequal=35000:state=101

?

Don't forget to visit Conjured Entertainment

Flatlander
FPSC Tool Maker
17
Years of Service
User Offline
Joined: 22nd Jan 2007
Location: The Flatlands
Posted: 30th Apr 2008 19:21 Edited at: 1st May 2008 10:54
Quote: "Quote: ":state=20,vargreater=34999,varless=35001:state=101"
Why not...
:state=20,varequal=35000:state=101
"


Of course and you're right, that would be more efficient. I was just copying from a previous script that would allow values between say 10 and 20 but I would then have a hud that displayed 10+. This is just testing the variables not demanding that the script should only be the way I had written. See my previous scripts.

Now that I have tested these features and proven them, I will bow out of this thread for awhile.

EDIT:

Changed "proficient" to "efficient"
Conjured Entertainment
AGK Developer
19
Years of Service
User Offline
Joined: 12th Sep 2005
Location: Nirvana
Posted: 30th Apr 2008 20:55 Edited at: 30th Apr 2008 21:10
Well I am still here, because every time I use two global variables in the same script; it doesn't work. (anybody else?)

I am at the point now of settling with what I have, which is two systems for cash...

1) Silver and Gold system, whereas 100 silver = 1 gold, both capped at 99

2) Single currency with a cap of 9,999

I'll post another short video of the second one since the first video illustrated the 1st method.

Don't forget to visit Conjured Entertainment

Attachments

Login to view attachments
Flatlander
FPSC Tool Maker
17
Years of Service
User Offline
Joined: 22nd Jan 2007
Location: The Flatlands
Posted: 30th Apr 2008 23:10
Well, I said I wasn't going to return for awhile. But since my code from a previous post has apparently not been view, I will repost part of it here. It contains two variables in one script. This is part of the total script.

======================================

:state=1:globalvar=5,setvar=0
:state=1,plrdistwithin=60:hudshow=sw_prompt_10,state=4

:state=4,plrusingaction=1:hudunshow=sw_prompt_10,state=5
:state=4,plrdistfurther=59:hudunshow=sw_prompt_10,state=1

:state=5:globalvar=10
:state=5,vargreater=9:state=6
:state=5,varless=10:hudunshow=buy_prompt_10,hudshow=no_money_prompt
:state=5,plrdistfurther=59:hudunshow=no_money_prompt,state=1

:state=6:hudunshow=buy_prompt_10
:state=6:globalvar=5,incvar=1,state=10

:state=10:globalvar=10,decvar=10,state=20

:state=20,varequal=0:hudunshow=money_10,state=200
:state=20,varless=0:hudunshow=money_10,state=200
:state=20,vargreater=9,varless=20:state=101

====================================================

There are two global variables: one is 5 and the other is 10. G5 acts as a boolean operator and except instead of -1 for true and 0 for false, it is a +1 for true. Each time you want to perform an action on a variable you have to make it the current variable. So looking at state 1 part that is bold, I make the global variable equal to 5 and then I set it to 0 which is false. This is telling other script that this weapon has not been selected.

Since this particular weapon costs 10 Kyats we have to check our money, which is store in variable #10 (G10). So in state 5 I first make the current variable #10. In the second statement of state=5 I check to see if our money is greater than 9. This is a condition and therefore cannot be on the same line as the action for making the current variable #10.

If there is enough money then we go to state=6. There we make the current variable #5; but this time we can have it on the same line as they are both "actions". Since the weapon was selected we need to change this variable to "1" or true which means that the weapon was selected.

We now go to state=10 so that we can decrement our money variable which is #10. But before we can do that we need to set the current variable back to 10. After we do that we can subtract the 10 and then state=20 determines which hud to show.
Conjured Entertainment
AGK Developer
19
Years of Service
User Offline
Joined: 12th Sep 2005
Location: Nirvana
Posted: 1st May 2008 01:28
Ok you get to use them however you want and when I try that it does not work.

I guess there is something going on as far as system compatibility.
Maybe mine is just flaking out bcause of my hardware or something.

I ususally set the gloabalvar beforethe next state, so I guess I will call it right before each increment like you do.

Maybe that will force it to work right.

Don't forget to visit Conjured Entertainment

Flatlander
FPSC Tool Maker
17
Years of Service
User Offline
Joined: 22nd Jan 2007
Location: The Flatlands
Posted: 1st May 2008 02:26 Edited at: 1st May 2008 10:52
If I remember right, I was having some difficulties with this at first. But apparently it does not have to be in the same state (I did globalvar=10 in state 10 although I did decrement the variable right after, I then called state 20 to do the comparisons. My instinct told me to get it as close to the actions as possible. I don't know, I guess just experiment until you get it. Doesn't seem like it should be a hardware or system problem.

BTW, I really like your Cash Crop concept. I can see putting it all in a trigger zone and scripting it for the player to lose health while in the "crop of money bushes" so he has to pick or find as many as possible. Maybe some could be fake. Then when he leaves the trigger zone because of not wanting to lose all his health he either can't go back in or if he does, he can't pick anymore or just simply everything is destroyed after leaving.

EDIT:


Changed "Cash Orchard" to "Cash Crop"

Login to post a reply

Server time is: 2024-11-24 09:35:38
Your offset time is: 2024-11-24 09:35:38