Jump to content
Search In
  • More options...
Find results that contain...
Find results in...

Help with script editing, please <3


Zappy
 Share

Recommended Posts

Alright, so I decided to start experimenting with the script so I can improve, pick up the language, learn how to solve problems and hopefully become fluent in VB.

Now, I've never touched anything like this before, not for very long that is. The most coding I've done is actionscript, so bear with me.

I'm trying to improve the "Crafting, Blackmithing, Alchemy, etc" script for my test game by adding an "amount" slider to both item1 and item2\. I believe I almost have it, but I seem to have trouble gathering data, declaring variables, etc.

>! ![](http://img641.imageshack.us/img641/479/image1wxq.png)

I was hoping it would just be as simple as using ".Data4" and ".Data5", but it seems that's not the case.

If anyone wants to walk me through this, I'd appreciate it very much. Eventually I'll learn and not NEED the assistance, but I a mentor for now.

(Does the server grab data from the client? I've worked with the client side of my modification, but I've undone all my changes due to some mistakes I wanted to clean up, so it's free of all "Amount" variables I'm using.)

Hope this makes sense x)
Thanks!

EDIT:

Scratch that. I've compiled  both my client and server, variables defined and no errors.
EXCEPT.
When I try to open the item editor in game, I get
"Runtime error 380"
"Invalid Property Value"

What would this be? An issue with the GUI setup? A problem with the code itself?
Where should I start looking to debug this error?
Link to comment
Share on other sites

Yep I have that. I had problems with that earlier, but figured that out before coming here for help.
Right now I'm having trouble with the runtime error 380… I'm not sure what could be causing it... hmmm..

What I'll do, is restore my old files, and then walk through and present the changes I made, in hopes that you'll easily spot the problems I caused x)
Link to comment
Share on other sites

For most of the UDTs, if you add a variable anywhere except at the bottom, you will have to delete all of the data and recreate it.

For instance, adding Data4 and Data5 anywhere except the bottom to ItemRec, you will have to delete all of your item data in your server folder, and re-create it by starting up the server again.
Link to comment
Share on other sites

Ah. Thank you guys, see these are the kinda things I would never figure out myself without assistance. Seems so cryptic. I'll fix that with haste ^_^
Thanks for the info! I'm understanding this more and more !
Link to comment
Share on other sites

Alright so. I fixed the error problem. Now my only problem is simply me not knowing exactly how to go about doing this.
```
Item1 = Item(GetPlayerInvItemNum(index, invNum)).Data1
                Item2 = Item(GetPlayerInvItemNum(index, invNum)).Data2
                Result = Item(GetPlayerInvItemNum(index, invNum)).Data3
                need1 = Item(GetPlayerInvItemNum(index, invNum)).data4
                need2 = Item(GetPlayerInvItemNum(index, invNum)).Data5

                ' Perform Recipe checks
                If Item1 < need1 Or Item2 < need2 Then
                    Call PlayerMsg(index, "This is an incomplete recipe...", White)
                    Exit Sub
                End If

                If GetPlayerEquipment(index, Weapon) <= 0 Then
                    Call PlayerMsg(index, "You don't have the proper tool equipped!", White)
                    Exit Sub
                End If

                If Item(GetPlayerEquipment(index, Weapon)).Tool = Item(GetPlayerInvItemNum(index, invNum)).ToolReq Then
                    ' Give the resulting item
                    If HasItem(index, Item1) And HasItem(index, Item2) Then
                        Call TakeInvItem(index, Item1, need1)
                        Call TakeInvItem(index, Item2, need2)
                        Call GiveInvItem(index, Result, 1)
                        Call TakeInvItem(index, GetPlayerInvItemNum(index, invNum), 0)
                        Call PlayerMsg(index, "You have successfully created " & Trim(Item(Result).Name) & ".", White)
                    Else
                        Call PlayerMsg(index, "You do not have all of the ingredients.", White)
                        Exit Sub
                    End If
                Else
                    Call PlayerMsg(index, "This is not the tool used in this recipe.", White)
                    Exit Sub
                End If
        End Select
    End If
End Sub

```
This is what I did to the operation. I assumed it would do exactly what I intended, but it doesn't.
I assume "Item1" and "Item2" aren't actually giving me value numbers, such as how many of that item the person is currently holding. How would I go about finding this out?
Anyone care to give me a lil' lesson? :o

Also, if it bugs you like it does me, .data4 is purposely lowercased. For some reason it FORCES me to lower case data4, but not Data5\. Not an issue, but visually displeasing.

I'd happily just accept a command index or something I can use to learn for myself if it can be provided <3
I've been looking everywhere and just can't seem to find one…
Link to comment
Share on other sites

@Soul:

> ```
> GetPlayerInvItemNum(index, invNum)
>
> ```
> This function returns item number in inventory slot invNum.

Ah okay so it IS giving me the number…
(Boy, this was a lot easier to figure out with a trace() in AS...)
Anywho, just clarifying.
You mean item number as in how many of an item the player is carrying, not what item# it is in the data files...? (eg: My gold is first, so it's item 1.)

My ores are set as currency, so they can all sit in the same inventory slot.
Link to comment
Share on other sites

Yay I did it! I get it now ^_^ and such a small amount of code!

```
    For i = 1 To MAX_INV
        If GetPlayerInvItemNum(index, i) = Item1 Then
            findItem1 = i
            Item1Val = GetPlayerInvItemValue(index, findItem1)

        End If
    Next
```
Thanks for all the tips guys!
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
×
  • Create New...