Kimimaru Posted September 4, 2009 Author Share Posted September 4, 2009 I created a scripted tile, and I'm wondering if I can reuse it somehow. You cannot reuse it as it is now, and I can't find a way to reuse it effectively. I want to be able to reuse it by placing the same scripted tile in a different spot, not by having another scripted tile or anything. Here's some of the code:In **Sub ScriptedTile(Index, Script)**:```Case 5 If GetVar("Thing.ini", GetPlayerName(Index), "Status") <> "Got" Then Call PutVar("Thing.ini", GetPlayerName(Index), "Status", "1") End If Exit Sub```In **Sub HotScript(Index, KeyID)**:```Case 17If GetVar("Thing.ini", GetPlayerName(Index), "Status") = "1" Then Dim Randomize Randomize = Int(rand(10,1)) If Randomize = 1 Or Randomize = 2 Or Randomize = 3 Then Call GiveItem(Index, 2, -1) Call PlayerMsg(Index, "You got an item!", YELLOW) End If If Randomize = 4 Or Randomize = 5 Or Randomize = 6 Then Call GiveCurrency(index, 1, 20) Call PlayerMsg(Index, "You got some money!", YELLOW) End If If Randomize = 7 Or Randomize = 8 Or Randomize = 9 Then Call GiveItem(Index, 3, -1) Call PlayerMsg(Index, "You got another item!", YELLOW) End If If Randomize = 10 Then Call GiveItem(Index, 40, -1) Call PlayerMsg(Index, "You got a rare item!", YELLOW) End If Call PutVar("Thing.ini", GetPlayerName(Index), "Status", "Got") Exit Sub```It all works great as it is now.This executes after you press CTRL while you're on the scripted tile. I can't seem to find a way to reuse it. I can add in a few IF statements and put in different variables, but that won't stop you from going back to another scripted tile with the same script number and pressing CTRL.Any help would be greatly appreciated. Link to comment Share on other sites More sharing options...
balliztik1 Posted September 4, 2009 Share Posted September 4, 2009 Instead of storing the variable in "status", use coordinates, like so:```Case 5 If GetVar("Thing.ini", GetPlayerName(Index), Cstr(GetPlayerMap(index)) & "_" & Cstr(GetPlayerX(index)) & "_" & Cstr(GetPlayerY(index))) <> "Got" Then Call PutVar("Thing.ini", GetPlayerName(Index), Cstr(GetPlayerMap(index)) & "_" & Cstr(GetPlayerX(index)) & "_" & Cstr(GetPlayerY(index)), "1") End If Exit Sub``````Case 17If GetVar("Thing.ini", GetPlayerName(Index), Cstr(GetPlayerMap(index)) & "_" & Cstr(GetPlayerX(index)) & "_" & Cstr(GetPlayerY(index))) = "1" Then Dim Randomize Randomize = Int(rand(10,1)) If Randomize = 1 Or Randomize = 2 Or Randomize = 3 Then Call GiveItem(Index, 2, -1) Call PlayerMsg(Index, "You got an item!", YELLOW) End If If Randomize = 4 Or Randomize = 5 Or Randomize = 6 Then Call GiveCurrency(index, 1, 20) Call PlayerMsg(Index, "You got some money!", YELLOW) End If If Randomize = 7 Or Randomize = 8 Or Randomize = 9 Then Call GiveItem(Index, 3, -1) Call PlayerMsg(Index, "You got another item!", YELLOW) End If If Randomize = 10 Then Call GiveItem(Index, 40, -1) Call PlayerMsg(Index, "You got a rare item!", YELLOW) End If Call PutVar("Thing.ini", GetPlayerName(Index), Cstr(GetPlayerMap(index)) & "_" & Cstr(GetPlayerX(index)) & "_" & Cstr(GetPlayerY(index)), "Got") Exit Sub```This way, each tile stores its coordinates, rather than just based on scripted tile number. Link to comment Share on other sites More sharing options...
Kimimaru Posted September 4, 2009 Author Share Posted September 4, 2009 Wow, thanks! I'll test it out now. I was thinking of using coordinates, but not as the variables. Thanks again!EDIT: Works great! Link to comment Share on other sites More sharing options...
Kimimaru Posted September 4, 2009 Author Share Posted September 4, 2009 Okay, well it all works great now, but now I'm trying to add something to this. I want to make it so that if you press CTRL and don't have any free open inventory slots, then it tells you that you don't have any inventory slots open and exits the Sub.I know how to do this, however, you can also obtain currency by pressing CTRL. If you have a full inventory and happen to randomly get the currency, I want you to be able to obtain it, as long as you already have that same currency in your inventory. If you have a full inventory and get another item that isn't currency, then it should do the same as before; display the full inventory message and exit the Sub.Any help would be greatly appreciated. Link to comment Share on other sites More sharing options...
Diskmaster Posted September 5, 2009 Share Posted September 5, 2009 ```If CanTake(index, itemnum, 1) AND GetFreeSlots(Index) = 0 Then'your item script here'ElseIf GetFreeSlots(index)=0 ThenCall PlayerMsg(index, "this chest is empty", BRIGHTRED)Else'your item script here again'```of corse, that is how I would do it. It would first check if you have the item and no free slots, then, if you don't then it checks if you have 0 free slots… Link to comment Share on other sites More sharing options...
Kimimaru Posted September 5, 2009 Author Share Posted September 5, 2009 Thanks a lot for the help! Your code worked. I changed it a lot to suit my needs, though. Thanks again! Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now