Using the mc plugin language to fix import errors - plugins

I am new to programming minecraft plugins, so I hired someone to create a skript for me. Apparently the code managed to have errors & I couldn't understand it after even diagnosing the problem by installing a completely seperate thing that the person I hired recommended. Here is the error I have been getting:
[Server thread/ERROR]: [Skript] ?c?lLine 1:?7 (x.sk)
?c Can't understand this event: 'import'
?6 Line: ?7import:
?r
[16:30:26] [Server thread/ERROR]: [Skript] ?c?lLine 10:?7 (x.sk)
?c Can't understand this event: 'on PlayerAchievementAwardedEvent'
?6 Line: ?7on PlayerAchievementAwardedEvent:
?r
[16:30:26] [Server thread/ERROR]: [Skript] ?c?lLine 53:?7 (x.sk)
?c Can't compare a player with an integer
?6 Line: ?7if arg-1 is not 1:
?r
[16:30:26] [Server thread/ERROR]: [Skript] ?c?lLine 57:?7 (x.sk)
?c 'else' has to be placed just after another 'if' or 'else if' section
?6 Line: ?7else:
?r
And this is the code I have been given:
import:
"org.bukkit.event.player.PlayerAchievementAwardedEvent"
on load:
load yaml "plugins\XAchievement\data\achievementsdata.yml" as "data"
on unload:
unload "data"
on PlayerAchievementAwardedEvent:
if yaml value "data.%event.getPlayer()%.max" from "data" doesn't exist:
set yaml value "data.%event.getPlayer()%.max" from "data" to 1
set {_x} to 1 / 90 + 0.20
set the event.getPlayer()'s walk speed to {_x}
else:
set {_x} to yaml value "data.%event.getPlayer()%.max" from "data"
set yaml value "data.%event.getPlayer()%.max" from "data" to {_x} + 1
set {_x} to {_x} + 1 / 90 + 0.20
set the event.getPlayer()'s walk speed to {_x}
save yaml "data"
send "&aYou gained an advancement and your speed has increased." to event.getPlayer()
command /speedsettings [<integer>]:
trigger:
if arg-1 is set:
if yaml value "data.%player%.max" from "data" exists:
set {_x} to yaml value "data.%player%.max" from "data"
if {_x} is greater than or equal to arg-1:
if arg-1 is not 1:
set {_y} to arg 1 / 90 + 0.20
set the player's walk speed to {_y}
send "&aYour speed is set to &e%arg-1%"
else:
set the player's walk speed to 0.20
send "&aYour speed is set to &e%arg-1%"
else:
send "&cMaximum speed: &6%{_x}%"
else:
send "&cYou can't speed up, your level is 1"
else:
send "&cSpeed error!"
command /setspeed [<player>] [<integer>]:
permission: skript.setspeed
permission message: &cDoesn't have permission!
trigger:
if arg-1 is set:
if arg-2 is set:
if yaml value "data.%arg-1%.max" from "data" exists:
set {_x} to yaml value "data.%arg-1%.max" from "data"
if {_x} is greater than or equal to arg-1:
if arg-1 is not 1:
set {_y} to arg 1 / 90 + 0.20
set the player's walk speed to {_y}
send "&aThe speed of the &e%arg-1% &ais set to &e%arg-2%&a."
else:
set the player's walk speed to 0.20
send "&aThe speed of the &e%arg-1% &ais set to &e%arg-2%&a."
else:
send "&cMaximum speed: &6%{_x}%"
else:
send "&cYou can't speed up, &6%arg-1%'s &clevel is 1"
else:
send "&cSpeed error!"
else:
send "&cPlayer error!"
If anyone can help me, thanks!

Related

Overnight script returning scripting error 201 at Set Field

I have a script setup to run overnight on my Filemaker server, but every night it returns this error:
Schedule "Recheck All Flags" scripting error (201) at "MasterDatabase : Recheck All Flags : ### : Set Field
Where ### is just a random number, probably the line in the script. In the above example let's just say it was 398.
I can't copy and paste the script to here, but it is very simple. It's one big loop over all records in the database and it checks a bunch of If statements. It looks like:
If [MasterDatabase::Start date = ""]
Set Field [MasterDatabase::Flagged for Discrepancy; "Yes"]
Commit Records/Requests [With dialog:Off]
End If
Why might this be failing when running on the server overnight?
Make sure you tell the server to go to the correct layout before the script starts, when the server starts up the script it will do the work on the layout that it is configured for the DB to open by default.
You can do something like:
If [ $$PLATFORM = "Server" ]
(Go to Layout X)
End If
The global variable $$PLATFORM can be defined in your On First Window Open Script like so:
Case (
PatternCount ( Get ( ApplicationVersion ) ; "Server" ) ;
"Server" ;
PatternCount ( Get ( ApplicationVersion ) ; "Data API" ) ;
"Data API" ;
Get ( SystemPlatform ) = 4 ;
"Web" ;
Choose (
Get ( Device ) ;
"Desktop" ; // 0 - Unknown
"Desktop" ; // 1 - Mac
"Desktop" ; // 2 - PC
"Tablet" ; // 3 - Tablet
"Phone" // 4 - Phone
)
)
If you already have that covered then make sure whatever user you are using for the PSOS has access to that layout, records scripts and fields.

Counting turtles after a chunk of code has executed

In my model currently, I have a monitor on the Interface that counts the total number of turtles (deer in my case) every tick. Is it possible to have another monitor that counts the number of deer after a certain line of code is executed? For example, here's a snippet of code:
to catch-fawns-source
let fawn-hunting-rate (fawn-harvest-rate-source)
if any? fawns-on source-patches
[ ask fawns-on source-patches [
if random-float 1.0001 < (fawn-hunting-rate)
[ set harvest (harvest + 1)
set fawn-harvest (fawn-harvest + 1)
set source-harvest (source-harvest + 1)
die ] ]
]
end
In this case, this is where I have fawns being harvested. This code is the same for my male and female adult and juvenile deer. So is there a way I could track my population specifically after that snippet of code (and the other identical ones for the juveniles and adults) is executed?
I'm not sure if I would need any sort of Netlogo extension (if there are any applicable to this) or if I could somehow add in another global variable and lines of code that accomplishes this task.
Thanks for all of your help as always!
I think you can get away with another global variable that you just update however often you want. For a very simple example, consider this setup:
globals [ most-recent-pop-check ]
to setup
ca
crt 10
set most-recent-pop-check count turtles
reset-ticks
end
Here, most-recent-pop-check will only be updated when needed, then you can just set a monitor to display that variable. In this example, the value will only change every 25 ticks- see comments for more detail:
to go
ask turtles [
; Turtles may die
if random-float 1 < 0.25 [
die
]
; Throw in some density-dependence to control population size
if random-float 1 < ( 0.5 * ( 1 - ( count turtles / 500 ) ) ) [
hatch random 2 + 1
]
]
; If the ticks are not 0, and if the remainder after dividing
; the ticks by 0 is 0, update the most-recent-pop-check
; variable to reflect the current turtle population.
if ticks != 0 and ticks mod 25 = 0 [
set most-recent-pop-check count turtles
]
tick
end
Of course, in your case rather than having the update occur based on the number of ticks, just have it occur whenever you run the code chunk you're after.

how can i find the exact tick in netlogo in which agents take an action?

I have agents that their devices may face failure randomly and based on the probability of failure. (working-devices? false)
when the device does not work, I should calculate the summary of waiting-time till now and then update the status of the device (working-devices? true).
My problem is in update part.
let assume the waiting-time = 1 and we are in tick = 10 that working-device? become false, and we do our model for 365 days(ticks).
In updating, I should let my status became true if tick > 11 ( 10 + 1 ).
11 means (the-tick + waiting time).
My questions is how can I understand in which tick the status became false?
and what is the best way to write my update procedure?
;; waiting-time is slider (for example ) 1
breed [ customers customer]
....
customers-own [device-working? real-waiting-time? ... ]
to setup
....
ask customers [
set real-waiting-time 0
set device-working? true
.....
]
end
to go
if ticks < 365 [
ask customers [if (device-working? = true)
[ impose update]
]
to impose
if random 100 > 95
[set device-working? false
set real-waiting-time real-waiting-time + waiting-time ]
end
to update
;; let the-tick when devices of customers faces failure
;; if tick > the-tick + waiting-time-slider and device-working? = false
;; [set device-working? true]
end
What you need to store is add another attribute for each customer that stores the tick at which it failed or when it is fixed. I have taken the latter approach and called that attribute end-waiting-time (NOT tested).
to impose
if random 100 > 95
[set device-working? false
set real-waiting-time real-waiting-time + waiting-time
set end-waiting-time ticks + waiting-time] ; this is the new line
end
to update
if device-working? = false tick and ticks = end-waiting-time
[ set device-working? true ]
end

Reinforcement learning in Netlogo: Error: No urn specified

I'm totally new to NetLogo, and am trying to create an agent-based reinforcement learning (RL) model. I have recreated a toy model to get help on.
Here, one agent is doing RL by interacting with two agents, one of whom is unreliable (and so interactions with this agent ARE NOT reinforced), and another which is reliable (and so interactions with this agent ARE reinforced).
But I keep getting the error: Extension exception: No urn specified
So, clearly, I need to figure out how to specify urns!
The project folder is available for you to checkout at: http://bit.ly/1m8TAxq
Bellow is the minimal, complete, verify code is as follows (though you will need the URN extension in the linked dropbox folder above to do so).
Any help would be tremendously appreciated.
extensions [ urn ] ;; the urn extension that contains the RL functions
breed [ agents agent ]
globals [ ;; Global variables
A1 ;; urn-ball name of agent 1 (RED)
A2 ;; urn-ball name of agent 2 (GREEN)
]
agents-own [ ;; Values assigned to each agent
main-urn ;; Name of the Polya urn used in RL
interactionPartner ;; Variable tracking who the learner is interacting with
knowledgeState ;; Variable tracking whether the learner knows the truth after each interaction
]
to setup ;; Setup the stage
clear-all
reset-ticks
setup-agents ;; Sets up the agents
end
to have-agents-setup-urns ;; Setting up agent polya urns for reinforcement learning (by observer)
ask agent 0 [
set main-urn urn:make-polya-urn initial-weight (list A1 A2)
;; There are two types of balls in the urn: A1, A2 corresponding to the two possible agents with whom the chooser may interact
]
end
to setup-agents ;; Setting up the agents in the population (by observer)
create-agents 3 [
setxy (-6 * cos ( who * 360 / population-size)) (12 * sin (who * 360 / population-size))
set shape "circle"
set size 4
]
ask agent 0 [ ;; This is the agent doing the reinforcement learning (BLUE)
set color [0 0 255 175]
]
ask agent 1 [ ;; This is the unreliable agent (RED)
set knowledgeState 0
set color [255 0 0 175]
]
ask agent 2 [ ;; This is the reliable agent (GREEN)
set knowledgeState 1
set color [0 255 0 175]
]
end
to step ;; The step function
ask turtles [do-game-play]
tick
end
to go ;; The go function simply calls step continuously
step
end
to do-game-play ;; The game play function (by observer)
ask agent 0 [
set interactionPartner urn:draw-ball main-urn ;; Draw from the agent urn to figure out with whom to interact.
if (interactionPartner = A1) [
set knowledgeState ( 0 ) ;; If the interactionPartner is agent 1 (who is unreliable), then set agent 0 knowledge state to 0.
]
if (interactionPartner = A2) [
set knowledgeState ( 1 ) ;; If the interactionPartner is agent 2 (who is reliable), then set agent 0 knowledge state to 1, and reinforce.
urn:reinforce main-urn A2 1
]
]
end

Panel doesn't execute )PNTS Section

I'm coding a ISPF Panel with "Point and shoot" elements. The elements say "yes" and "no" and the default cursor have to point to "yes".
1st Case:
Declaration of the fields: + TYPE(INPUT) PAS(ON)
When I use this declaration, the panel closes by pressing [enter] and generating rc = 0. However, the )PNTS section doesn't run.
2nd CASE:
Declaration of the fields: + TYPE (PS)
The )PNTS section runs by pressing [enter]. However, I cannot set the .cursor to the field "yes".
I tryed different ways with different field names (e.g. ZPS00001). I tryed to simulate Point and Shoot with Rexx, but nothing worked really fine.
Pressing enter will cause the point and shoot fields to be processed. However the cursor must be on one of the fields for the )PNTS section to set the value associated with a field. It would sound like panel may have not been coded correctly. PAS should be used for input or output fields and PS should be used for text fields. For instance if you have the following panel:
)ATTR
$ TYPE(PS)
! TYPE(OUTPUT) PAS(ON)
)BODY
+ --------------------- +
+ ===>_ZCMD +
+
$Field1 : _FLD +
$Field2 : _ABC +
$Field3 : !IN1 +
$Field4 : !IN2 +
)INIT
&INV1 = 111
&INV2 = 222
&INV3 = 333
)REINIT
REFRESH(*)
)PROC
)PNTS
FIELD(IN1) VAR(INV1) VAL(ON)
FIELD(IN2) VAR(INV2) VAL(OFF)
FIELD(ZPS00001) VAR(INV3) VAL(1)
FIELD(ZPS00002) VAR(INV3) VAL(2)
FIELD(ZPS00003) VAR(INV3) VAL(3)
FIELD(ZPS00004) VAR(INV3) VAL(4)
)END
With the following REXX exec:
/* REXX */
RCC = 0
INV1 = 0
INV2 = 1
DO WHILE RCC = 0
ADDRESS ISPEXEC 'DISPLAY PANEL(PAS)'
RCC = RC
SAY INV1 '-' INV2 '-' INV3
END
You can test the values of inv1, inv2 and inv3 based on where you put the cursor when you hit enter. You will get 1, 2, 3 or 4 if the cursor in on field1, field2, field3 or field4. If it is on IN1 or IN2 then you get ON or OFF. It all depends on where the cursor is positioned when ENTER is hit. Based on the example you can see point and shoot is not limited to Menus. Hope the example helps.
Marv Knight