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

Energy Tile


jangofett287
 Share

Recommended Posts

Right, I've looked in my main and used my knowlege of C++ and LUA (all programing languages have simmeralities) and had a look around here and this is what i think i should put in Main to make a energy regening tile:

```
sub ontouch(Energy)

If Int(GetPlayerSP(Energy)) < 100 then
Energy = 100
End If
End Sub
```
or should it be:
```
sub Scriptedtile1(Energy)

If Int(GetPlayerSP(Energy)) < 100 then
Energy = 100
End If
End Sub
```
Can someone with knowlage of this check please.
Link to comment
Share on other sites

```
sub Scriptedtile1(Energy) 'You're basically adding a new sub here, which means it won't be scripted tile anymore.

  If Int(GetPlayerSP(Energy)) < 100 then 'The () are there so the script knows which player it should check
      Energy = 100 'Not a valid sadscripting command
  End If
End Sub
```
Should be

```
Sub Scriptedtile(Index, script) 'Existing sub for Scripted Tiles
  Select Case Script 'The scripted tile attribute calls the script like this: Call Scriptedtile(index, x) where x is the number used to determine which script it should call
    Case 1 'int this case, x = 1
      If Int(GetPlayerSP(Index)) < 100 then
        Call SetPlayerSP(index, 100) 'Proper SS command for setting players SP
      End if
  End Select
End Sub
```
Link to comment
Share on other sites

new problem, I've added the tile to part of one of my maps, i step on it, and then use 1 energy (measured in percent) and it instantly drops to 4%!!! this is a big problem as my game relies on energy

EDIT:I think it shoul set energy to max energy rather than 100 energy as max energy gets higher as you level up
Link to comment
Share on other sites

@jangofett287:

> Nope, still not working!

Strange.

@[Šß:

> 超人 ŠhÃdÓw ñíñjä ¤Vålöñ¤ シ link=topic=51389.msg539135#msg539135 date=1252096513]
> Do you want just a tile to regenerate sp? I think this might work, my scriptign knowledge is slim to none

I think it's pretty obvious he wanted a tile to refill all of the energy. Besides, that script would require you to step on and of the tile repeatedly to regenerate sp.

The following error or errors occurred while posting this message:
Warning - while you were typing a new reply has been posted. You may wish to review your post.

What he said
Link to comment
Share on other sites

@jangofett287:

> wouldn't work, it would just add 10 to avalible energy on every touch, you would need a loop to do it that way

yea, no. not a loop, a timer, otherwise it would execute an infinate number of regens, even if it is full and you will probably cause some extremedy lag. also, u might want it to run a quick check to see if it is 9 or less sp full because it will grant you extra sp every time u step on it (just revealed a bug) so lets say you have 500 total sp and you have 499 current sp and you step on the tile, your total sp will become 509, and everytime after that, it will rise by 10!!! so, this script will make little noobs become epic amazing super sp noobs who don't ever need the SPEED stat again.
Try adding If GetPlayerSp(index)>GePlayerTotalSp(index) -11 then
That might just fix it :azn: and sry I rambled on…
Link to comment
Share on other sites

I've got it!

```
SubScriptedTile(Index, script)
SelectCaseScript
  Case 1
    If Int(GetPlayerSP(Index)) < 100 Then 
      Call SetPlayerSP(Index, GetPlayerMaxSP(Index)) 
    End If 
  EndSelect 
EndSub 
```should be:
```
SubScriptedTile(Index, Script)
SelectCaseScript
  Case 1
    If Int(GetPlayerSP(Index)) < GetPlayerMaxSP(Index) Then 
      Call SetPlayerSP(Index, PlayerMaxSP(Index)) 
    End If 
  EndSelect 
EndSub 
```
Link to comment
Share on other sites

Sub ScriptedTile(Index, script)
Select Case Script
  Case 1
    If GetPlayerSP(Index) < GetPlayerMaxSP(Index) Then 
      Call SetPlayerSP(Index, GetPlayerMaxSP(Index))
    End If 
  End Select 
End Sub

Copy that. Are you using IE? If so, code from syntax highlighting won't have spaces in it, which will end up breaking your main.txt.

@jangofett287:

> ```
> SubScriptedTile(Index, Script)
> SelectCaseScript
>   Case 1
>     If Int(GetPlayerSP(Index)) < GetPlayerMaxSP(Index) Then 
>       Call SetPlayerSP(Index, PlayerMaxSP(Index)) 
>     End If 
>   EndSelect 
> EndSub
> ```
>
> go on then, why are the spaces needed?

For the same reason that "carpet" and "car pet" are not the same thing. "SubScriptedTile" is not "Sub ScriptedTile" and "SelectCaseScript" is not "Select Case Script".
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...